Added zoom level display to image editor

This commit is contained in:
Brendan Robert 2015-03-15 11:19:56 -05:00
parent 684f06dbdc
commit fe2a00c46c
4 changed files with 30 additions and 12 deletions

View File

@ -73,6 +73,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
}
public void changeCurrentPattern(FillPattern pattern) {
if (pattern == null) return;
currentFillPattern = pattern.getBytePattern();
hiBitMatters = pattern.hiBitMatters;
lastActionX = -1;

View File

@ -4,6 +4,7 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Group;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
@ -37,19 +38,22 @@ public abstract class ImageEditorTabController {
protected ComboBox<Image> imageSelector; // Value injected by FXMLLoader
@FXML // fx:id="imageWidthField"
protected TextField imageWidthField; // Value injected by FXMLLoader
@FXML
protected Label zoomLabel;
@FXML
public void initalize() {
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
assert imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'ApplicationUI.fxml'";
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
assert imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'imageEditorTab.fxml'";
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
assert zoomLabel != null : "fx:id=\"zoomLabel\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
}
abstract public void rebuildImageSelector();

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.badvision.outlaweditor.ui.EntitySelectorCell;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
@ -108,10 +109,15 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
}
}
private void updateZoomLabel() {
zoomLabel.setText(String.format("%1.1fx",currentImageEditor.getZoomScale()));
}
@Override
public void imageZoomIn(ActionEvent event) {
if (currentImageEditor != null) {
currentImageEditor.zoomIn();
updateZoomLabel();
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
}
}
@ -120,6 +126,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
public void imageZoomOut(ActionEvent event) {
if (currentImageEditor != null) {
currentImageEditor.zoomOut();
updateZoomLabel();
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
}
}
@ -208,8 +215,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
currentImageEditor.setEntity(i);
currentImageEditor.buildEditorUI(imageEditorScrollAnchorPane);
currentImageEditor.buildPatternSelector(imagePatternMenu);
imageEditorZoomGroup.setScaleX(1.0);
imageEditorZoomGroup.setScaleY(1.0);
// imageEditorZoomGroup.setScaleX(1.0);
// imageEditorZoomGroup.setScaleY(1.0);
imageNameField.textProperty().addListener(rebuildListener);
imageCategoryField.textProperty().addListener(rebuildListener);
if (oldEditorState != null) {

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.effect.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
@ -67,6 +68,11 @@
</ScrollPane>
<Button layoutX="433.0" layoutY="5.0" mnemonicParsing="false" onAction="#imageZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="5.0" />
<Button layoutX="435.0" layoutY="37.0" mnemonicParsing="false" onAction="#imageZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="37.0" />
<Label fx:id="zoomLabel" alignment="CENTER" layoutX="428.0" layoutY="69.0" prefHeight="16.0" prefWidth="39.0" text="1x" textFill="WHITE" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="69.0">
<effect>
<DropShadow blurType="ONE_PASS_BOX" color="#000240" height="12.0" radius="5.0" spread="0.5" width="10.0" />
</effect>
</Label>
</children>
</AnchorPane>
</children>