📄 mainwindow.java
字号:
/** * Creates a new class diagram view. */ private class ActionViewCreateClassDiagram extends AbstractAction { ActionViewCreateClassDiagram() { super("Class diagram", new ImageIcon(Options.iconDir + "ClassDiagram.gif")); } public void actionPerformed(ActionEvent e) { NewClassDiagramView cdv = new NewClassDiagramView(MainWindow.this, fSession.system()); ViewFrame f = new ViewFrame("Class diagram", cdv, "ClassDiagram.gif"); // give some help information f.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent ev) { fStatusBar.showTmpMessage("Use left mouse button to move " + "classes, right button for popup menu."); } public void internalFrameDeactivated(InternalFrameEvent ev) { fStatusBar.clearMessage(); } }); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(cdv, BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new object diagram view. */ private class ActionViewCreateObjectDiagram extends AbstractAction { ActionViewCreateObjectDiagram() { super("Object diagram", new ImageIcon(Options.iconDir + "ObjectDiagram.gif")); } public void actionPerformed(ActionEvent e) { NewObjectDiagramView odv = new NewObjectDiagramView(MainWindow.this, fSession.system()); ViewFrame f = new ViewFrame("Object diagram", odv, "ObjectDiagram.gif"); // give some help information f.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent ev) { fStatusBar.showTmpMessage("Use left mouse button to move " + "objects, right button for popup menu."); } public void internalFrameDeactivated(InternalFrameEvent ev) { fStatusBar.clearMessage(); } }); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(odv, BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new class invariant view. */ private class ActionViewCreateClassInvariant extends AbstractAction { ActionViewCreateClassInvariant() { super("Class invariants", new ImageIcon(Options.iconDir + "InvariantView.gif")); } public void actionPerformed(ActionEvent e) { ClassInvariantView civ = new ClassInvariantView(MainWindow.this, fSession.system()); ViewFrame f = new ViewFrame("Class invariants", civ, "InvariantView.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(civ, BorderLayout.CENTER); addNewViewFrame(f); } }// /**// * Creates a new state tree view.// */// private class ActionViewCreateStateTreeView extends AbstractAction {// ActionViewCreateStateTreeView() {// super("State tree",// new ImageIcon(Options.iconDir + "InvariantView.gif"));// }//// public void actionPerformed(ActionEvent e) {// StateTreeView stv = new StateTreeView(fSession.system());// ViewFrame f = new ViewFrame("State tree", stv, "InvariantView.gif");// JComponent c = (JComponent) f.getContentPane();// c.setLayout(new BorderLayout());// c.add(stv, BorderLayout.CENTER);// addNewViewFrame(f);// }// } /** * Creates a new state evolution view. */ private class ActionViewCreateStateEvolution extends AbstractAction { ActionViewCreateStateEvolution() { super("State evolution", new ImageIcon(Options.iconDir + "LineChartView.gif")); } public void actionPerformed(ActionEvent e) { StateEvolutionView sev = new StateEvolutionView(fSession.system()); ViewFrame f = new ViewFrame("State evolution", sev, "LineChartView.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(sev, BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new object properties view. */ private class ActionViewCreateObjectProperties extends AbstractAction { ActionViewCreateObjectProperties() { super("Object properties", new ImageIcon(Options.iconDir + "ObjectProperties.gif")); } public void actionPerformed(ActionEvent e) { ObjectPropertiesView opv = new ObjectPropertiesView(MainWindow.this, fSession.system()); ViewFrame f = new ViewFrame("Object properties", opv, "ObjectProperties.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(opv, BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new class extent view. */ private class ActionViewCreateClassExtent extends AbstractAction { ActionViewCreateClassExtent() { super("Class extent", new ImageIcon(Options.iconDir + "ClassExtentView.gif")); } public void actionPerformed(ActionEvent e) { ClassExtentView cev = new ClassExtentView(MainWindow.this, fSession.system()); ViewFrame f = new ViewFrame("Class extent", cev, "ClassExtentView.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(cev, BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new sequence diagram view. */ private class ActionViewCreateSequenceDiagram extends AbstractAction { ActionViewCreateSequenceDiagram() { super("Sequence diagram", new ImageIcon(Options.iconDir + "SequenceDiagram.gif")); } public void actionPerformed(ActionEvent e) { SequenceDiagramView sv = new SequenceDiagramView(fSession.system()); ViewFrame f = new ViewFrame("Sequence diagram", sv, "SequenceDiagram.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(new JScrollPane(sv), BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new call stack view. */ private class ActionViewCreateCallStack extends AbstractAction { ActionViewCreateCallStack() { super("Call stack", new ImageIcon(Options.iconDir + "CallStack.gif")); } public void actionPerformed(ActionEvent e) { CallStackView csv = new CallStackView(fSession.system()); ViewFrame f = new ViewFrame("Call stack", csv, "CallStack.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(new JScrollPane(csv), BorderLayout.CENTER); addNewViewFrame(f); } } /** * Creates a new command list view. */ private class ActionViewCreateCommandList extends AbstractAction { ActionViewCreateCommandList() { super("Command list", new ImageIcon(Options.iconDir + "CmdList.gif")); } public void actionPerformed(ActionEvent e) { CommandView cv = new CommandView(fSession.system()); ViewFrame f = new ViewFrame("Command list", cv, "CmdList.gif"); JComponent c = (JComponent) f.getContentPane(); c.setLayout(new BorderLayout()); c.add(new JScrollPane(cv), BorderLayout.CENTER); addNewViewFrame(f); } } /** * Show class diagram. */ private class ActionViewClassDiagram extends AbstractAction { ActionViewClassDiagram() { super("Class diagram"); } public void actionPerformed(ActionEvent ev) { // FIXME: ClassDiagramView cdv = new ClassDiagramView(fSession.system().model()); } } /** * Close all internal frames. */ private class ActionViewCloseAll extends AbstractAction { ActionViewCloseAll() { super("Close all"); } public void actionPerformed(ActionEvent ev) { closeAllViews(); } } /** * Tile all internal frames. */ private class ActionViewTile extends AbstractAction { ActionViewTile() { super("Tile"); } public void actionPerformed(ActionEvent ev) { // How many frames do we have? JInternalFrame[] allframes = fDesk.getAllFrames(); int count = allframes.length; if (count == 0 ) return; // Determine the necessary grid size int sqrt = (int) Math.sqrt(count); int rows = sqrt; int cols = sqrt; if (rows * cols < count ) { cols++; if (rows * cols < count ) { rows++; } } // Define some initial values for size & location Dimension size = fDesk.getSize(); int w = size.width/cols; int h = size.height/rows; int x = 0; int y = 0; // Iterate over the frames, deiconifying any iconified frames and then // relocating & resizing each for (int i=0; i<rows; i++) { for (int j=0; j<cols && ((i*cols)+j<count); j++) { JInternalFrame f = allframes[(i*cols)+j]; if (f.isIcon() && ! f.isClosed() ) { try { f.setIcon(false); } catch (PropertyVetoException ex) { // ignored } } fDesk.getDesktopManager().resizeFrame(f, x, y, w, h); x += w; } y += h; // start the next row x = 0; } } } /** * Help about. */ private class ActionHelpAbout extends AbstractAction { ActionHelpAbout() { super("About..."); } public void actionPerformed(ActionEvent e) { AboutDialog dlg = new AboutDialog(MainWindow.this); dlg.setVisible(true); } } /** * Creates some initial views and tiles them. */ // private void createInitialViews() { // ActionEvent ev = // new ActionEvent(this, 0, null); // fActionViewCreateObjectCount.actionPerformed(ev); // fActionViewCreateLinkCount.actionPerformed(ev); // fActionViewCreateObjectDiagram.actionPerformed(ev); // fActionViewCreateClassInvariant.actionPerformed(ev); // fActionViewTile.actionPerformed(ev); // fDesk.revalidate(); // } public static MainWindow create(Session session) { // Object[] arr = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); // //Object[] arr = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); // for (int i = 0; i < arr.length; i++) { // System.out.println(arr[i]); // } final MainWindow win = new MainWindow(session); win.pack(); // win.createInitialViews(); win.setVisible(true); return win; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -