| Summary: | InfiniteCanvas#fitToSize() should delay its computation when the zoom factor is invalid. | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Matthias Wienand <matthias.wienand> |
| Component: | GEF FX | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 0.2.0 | ||
| Target Milestone: | 4.0.0 / 3.11.0 (Neon) M5 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Delaying the operation seems unintuitive. Therefore, I enhanced the Javadoc, explaining in which situations the operation can be performed, and how this can be verified beforehand. Moreover, if the operation is called while the InfiniteCanvas is in an invalid state, an IllegalStateException is thrown. Additionally, I added two parameters that can be used to restrict the zoom level to a certain range. The code is published on the master branch, therefore, I resolve this ticket as fixed for 3.11.0M5. |
In some situations, the InfiniteCanvas#fitToSize() method computes an invalid zoom factor. Scrolling and zooming should then be delayed to a later point at which the computation works. The following snippet demonstrates the issue (the red rectangle stays at the top left, although it should fill the whole window): package org.eclipse.gef4.fx.examples.snippets; import org.eclipse.gef4.fx.nodes.InfiniteCanvas; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class InfiniteCanvasFitToSizeSnippet extends Application { public static void main(String[] args) { launch(); } @Override public void start(Stage primaryStage) throws Exception { InfiniteCanvas canvas = new InfiniteCanvas(); canvas.getContentGroup().getChildren() .add(new Rectangle(50, 50, Color.RED)); canvas.fitToSize(); Scene scene = new Scene(canvas, 400, 400); primaryStage.setScene(scene); primaryStage.sizeToScene(); primaryStage.show(); } }