From 127366247b6eb6df69d4604ac4923861929aa837 Mon Sep 17 00:00:00 2001 From: Jean-Yves Tinevez Date: Wed, 4 Sep 2024 15:43:59 +0200 Subject: [PATCH] Try to make the zoom box of the grapher reusable. --- .../views/grapher/display/DataDisplayZoom.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java index 37c01fcb7..5792ad9f0 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java @@ -32,13 +32,14 @@ import java.awt.Graphics; import javax.swing.ImageIcon; +import javax.swing.JPanel; import org.mastodon.graph.Edge; import org.mastodon.graph.Vertex; -import org.mastodon.ui.keymap.KeyConfigScopes; import org.mastodon.model.HasLabel; import org.mastodon.spatial.HasTimepoint; import org.mastodon.ui.keymap.KeyConfigContexts; +import org.mastodon.ui.keymap.KeyConfigScopes; import org.mastodon.views.grapher.datagraph.ScreenTransform; import org.mastodon.views.grapher.display.OffsetAxes.OffsetAxesListener; import org.mastodon.views.trackscheme.display.TrackSchemeZoom; @@ -65,9 +66,10 @@ public class DataDisplayZoom< V extends Vertex< E > & HasTimepoint & HasLabel, E extends AbstractNamedBehaviour implements DragBehaviour, OffsetAxesListener, TransformListener< ScreenTransform > { - private static final String TOGGLE_ZOOM = "box zoom"; - private static final String[] TOGGLE_ZOOM_KEYS = new String[] { "Z" }; + public static final String TOGGLE_ZOOM = "box zoom"; + + public static final String[] TOGGLE_ZOOM_KEYS = new String[] { "Z" }; /* * Command descriptions for all provided commands @@ -90,7 +92,7 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) public static < V extends Vertex< E > & HasTimepoint & HasLabel, E extends Edge< V > > void install( final Behaviours behaviours, final DataDisplayPanel< V, E > panel ) { - final DataDisplayZoom< V, E > zoom = new DataDisplayZoom<>( panel ); + final DataDisplayZoom< V, E > zoom = new DataDisplayZoom<>( panel, panel.getTransformEventHandler() ); // Create and register overlay. zoom.transformChanged( panel.getScreenTransform().get() ); @@ -107,7 +109,7 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) public static final Color ZOOM_GRAPH_OVERLAY_COLOR = Color.BLUE.darker(); - private final DataDisplayPanel< V, E > panel; + private final JPanel panel; private final InertialScreenTransformEventHandler transformEventHandler; @@ -119,11 +121,11 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) private final ZoomOverlay overlay; - private DataDisplayZoom( final DataDisplayPanel< V, E > panel ) + private DataDisplayZoom( final JPanel panel, final InertialScreenTransformEventHandler transformEventHandler ) { super( TOGGLE_ZOOM ); this.panel = panel; - this.transformEventHandler = panel.getTransformEventHandler(); + this.transformEventHandler = transformEventHandler; dragging = false; screenTransform = new ScreenTransform();