1 10 11 package org.enhydra.jawe.actions; 12 13 import org.enhydra.jawe.*; 14 import org.enhydra.jawe.xml.*; 15 import org.enhydra.jawe.xml.elements.*; 16 import org.enhydra.jawe.xml.panels.*; 17 18 import java.awt.event.*; 19 import java.awt.*; 20 import javax.swing.*; 21 import java.util.*; 22 23 26 public class ShowOverview extends ActionBase { 27 28 private JDialog overviewDlg; 29 private JaWEOverviewPanel overviewPanel; 30 31 32 public ShowOverview (ProcessEditor pe) { 33 super(pe); 34 } 35 36 public void actionPerformed(ActionEvent e) { 37 if(overviewDlg == null) { 38 String title; 41 try { 42 title = ResourceManager.getLanguageDependentString("OverviewKey"); 43 } catch (MissingResourceException mre) { 44 title="Overview"; 45 } 46 Window w=editor.getWindow(); 47 if (w instanceof JFrame) { 48 overviewDlg = new JDialog((JFrame)w,title,false); 49 } 50 else { 51 overviewDlg = new JDialog((JDialog)w,title,false); 52 } 53 Container fContentPane = overviewDlg.getContentPane(); 54 55 fContentPane.setLayout(new BorderLayout()); 56 overviewPanel = new JaWEOverviewPanel(editor.getGraph()); 57 fContentPane.add(overviewPanel); 58 overviewDlg.setSize(new Dimension(180,180)); 59 overviewDlg.setLocationRelativeTo(w); 60 61 overviewDlg.addComponentListener(new ComponentListener(){ 63 public void componentShown(ComponentEvent evt){} 64 public void componentHidden(ComponentEvent evt){} 65 public void componentMoved(ComponentEvent evt){} 66 public void componentResized(ComponentEvent evt){ 67 overviewPanel.componentResized(null); 68 } 69 }); 70 overviewPanel.getGraph().addMouseListener(new OverviewMouseListener()); 71 73 } 74 overviewDlg.show(); 75 overviewPanel.componentResized(null); 76 } 77 78 class OverviewMouseListener extends MouseAdapter{ 81 public void mouseClicked(MouseEvent evt){ 82 AbstractGraph origGraph = editor.getGraph(); 83 Rectangle origVis = origGraph.getVisibleRect(); 84 Dimension ovDdim = overviewPanel.getGraph().getPreferredSize(); 85 double mul = origGraph.getWidth()/ovDdim.getWidth(); 86 int x = evt.getX(); 87 int y = evt.getY(); 88 double halfH = origVis.getHeight()/2; 89 double halfW = origVis.getWidth()/2; 90 double oldMiddleX = origVis.getX() + halfW; 91 double oldMiddleY = origVis.getY() + halfH; 92 double newMiddleX = x*mul; 93 double newMiddleY = y*mul; 94 origVis.translate((int)(newMiddleX-oldMiddleX),(int)(newMiddleY-oldMiddleY)); 95 origGraph.scrollRectToVisible(origVis); 96 } 97 } 98 100 } 101 | Popular Tags |