diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java index 57fea37..80adea3 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java @@ -1,5 +1,7 @@ package application; +import application.actions.ZoomInAction; +import application.actions.ZoomOutAction; import application.editor.Editor; import application.views.NavigationWindow; import com.mxgraph.model.mxCell; @@ -13,11 +15,20 @@ import com.mxgraph.view.mxGraph; import javax.swing.*; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; +import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW; + public class ApplicationWindow extends JFrame { + private static final long serialVersionUID = -8690140317781055614L; + + private static final String ACTION_ZOOM_IN = "zoomIn"; + private static final String ACTION_ZOOM_OUT = "zoomOut"; + public static final String title = "Visual Modeling Tool"; private Editor editor = null; @@ -67,6 +78,13 @@ }); getContentPane().add(graphComponent); new mxRubberband(graphComponent); + + // Add keyboard shortcut for zoom-in and zoom-out + graphComponent.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_SEMICOLON, InputEvent.CTRL_DOWN_MASK), ACTION_ZOOM_IN); + graphComponent.getActionMap().put(ACTION_ZOOM_IN, new ZoomInAction(graphComponent)); + graphComponent.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK), ACTION_ZOOM_OUT); + graphComponent.getActionMap().put(ACTION_ZOOM_OUT, new ZoomOutAction(graphComponent)); + graph.setAllowDanglingEdges(false); graph.setCellsDisconnectable(true);