01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.Dimension;
04: import java.awt.event.ActionEvent;
05:
06: import org.enhydra.jawe.ActionBase;
07: import org.enhydra.jawe.JaWEComponent;
08: import org.enhydra.jawe.components.graph.Graph;
09: import org.enhydra.jawe.components.graph.GraphController;
10:
11: /**
12: * Zoom in (for 15%)
13: * @author Sasa Bojanic
14: */
15: public class ZoomIn extends ActionBase {
16:
17: public ZoomIn(JaWEComponent jawecomponent) {
18: super (jawecomponent);
19: }
20:
21: public void enableDisableAction() {
22: GraphController gc = (GraphController) jawecomponent;
23:
24: if (gc.getSelectedGraph() != null)
25: if (gc.getSelectedGraph().getScale() < 2) {
26: setEnabled(true);
27: return;
28: }
29:
30: setEnabled(false);
31: }
32:
33: public void actionPerformed(ActionEvent e) {
34: Graph selectedGraph = ((GraphController) jawecomponent)
35: .getSelectedGraph();
36: if (selectedGraph == null)
37: return;
38: //setResizeAction(null);
39: //editor.setScale(editor.getGraph().getScale()*1.15);
40: double scale = selectedGraph.getScale() / 0.85;
41: scale = Math.max(Math.min(scale, 2), 0.1);
42: selectedGraph.setScale(scale);
43: try {
44: Dimension prefSize = selectedGraph.getSize();
45: prefSize.width = (int) (prefSize.width / 0.85);
46: prefSize.height = (int) (prefSize.height / 0.85);
47: selectedGraph.setPreferredSize(prefSize);
48: } catch (Exception ex) {
49: }
50:
51: // With JGraph3.4.1 this causes problems
52: /*if (editor.getGraph().getSelectionCell() != null) {
53: editor.getGraph().scrollCellToVisible(editor.getGraph().getSelectionCell());
54: }*/
55:
56: GraphController gc = (GraphController) jawecomponent;
57: gc.getSettings().getAction("ZoomIn").getAction()
58: .enableDisableAction();
59: gc.getSettings().getAction("ZoomOut").getAction()
60: .enableDisableAction();
61: gc.getSettings().getAction("ActualSize").getAction()
62: .enableDisableAction();
63: }
64: }
|