|
45 | 45 | import javafx.geometry.Pos; |
46 | 46 | import javafx.geometry.Rectangle2D; |
47 | 47 | import javafx.scene.Cursor; |
| 48 | +import javafx.scene.Group; |
48 | 49 | import javafx.scene.ImageCursor; |
49 | 50 | import javafx.scene.Scene; |
50 | 51 | import javafx.scene.canvas.Canvas; |
|
66 | 67 | import javafx.scene.layout.ColumnConstraints; |
67 | 68 | import javafx.scene.layout.FlowPane; |
68 | 69 | import javafx.scene.layout.GridPane; |
| 70 | +import javafx.scene.layout.Pane; |
69 | 71 | import javafx.scene.layout.Priority; |
70 | 72 | import javafx.scene.layout.RowConstraints; |
71 | 73 | import javafx.scene.layout.VBox; |
@@ -109,19 +111,21 @@ public void start(Stage stage) throws Exception { |
109 | 111 |
|
110 | 112 | // Main Contents: the background image |
111 | 113 | Canvas img = new Canvas(screenBounds.getWidth(), screenBounds.getHeight()); |
| 114 | + Pane p = new Pane(new Group(img)); |
112 | 115 | DoubleProperty scaleFactor = new SimpleDoubleProperty(1.0); |
| 116 | + ScrollPane scrImg = new ScrollPane(p); |
113 | 117 |
|
114 | 118 | scaleFactor.addListener(e -> updateView(img, scaleFactor.get())); |
115 | 119 | img.setOnMouseClicked(e -> { |
| 120 | + double sf = scaleFactor.get(); |
116 | 121 | addMarker((int) e.getX(), (int) e.getY(), currentMarker); |
117 | | - updateView(img, scaleFactor.get()); |
| 122 | + updateView(img, sf); |
| 123 | + p.setPrefWidth(origBg.getWidth() * sf); |
| 124 | + p.setPrefHeight(origBg.getHeight() * sf); |
118 | 125 | }); |
119 | 126 | img.setOnMouseEntered(e -> updateCursor(currentMarker)); |
120 | 127 | img.setOnMouseExited(e -> updateCursor(Cursor.DEFAULT)); |
121 | 128 |
|
122 | | - ScrollPane scrImg = new ScrollPane(); |
123 | | - scrImg.setContent(img); |
124 | | - |
125 | 129 | // Bottom Pane |
126 | 130 | GridPane pnlForm = new GridPane(); |
127 | 131 | pnlForm.setHgap(10); |
|
0 commit comments