/** * Allow internal frames to go behind other frames (i.e. code windows). * * @author susiefu */ protected void moveToBackLayer() { editFrame.setLayer(1); buttonFrame.setLayer(1); triangleFrame.setLayer(1); editFrame.moveToFront(); triangleFrame.moveToFront(); buttonFrame.moveToFront(); }
/** Adds the given componet to the given layer. */ public void addEditorWindow(EditorWindowIndirectRef windowRef) { final JInternalFrame window = (JInternalFrame) windowRef; Dimension desktopSize = desktopPane.getSize(); Dimension preferredSize = window.getPreferredSize(); int x = desktopSize.width / 2 - preferredSize.width / 2; int y = desktopSize.height / 2 - preferredSize.height / 2; window.setBounds(x, y, preferredSize.width, preferredSize.height); // This line sometimes hangs, so I'm putting it in a watch process // so it can be stopped by the user. Not ideal. // Window owner = (Window) getTopLevelAncestor(); // // new WatchedProcess(owner) { // public void watch() { getDesktopPane().add(window); window.setLayer(100); window.moveToFront(); try { window.setVisible(true); } catch (Exception e) { if (e instanceof ClassCastException || e instanceof NullPointerException) { // skip. These is being caused apparently the workbench // having labeled nodes and edges. Can't find a // workaround--probably a Java bug. jdramsey } else { e.printStackTrace(); } } // prevents the component from being hidden. // window.addComponentListener(new PositionListener()); // } // }; }
public static void init( JInternalFrame comp, Thing thing, Container parent, ActionContext actionContext) { JComponentCreator.init(comp, thing, parent, actionContext); String title = JavaCreator.createText(thing, "title", actionContext); if (title != null) { comp.setTitle(title); } Boolean closable = JavaCreator.createBoolean(thing, "closable"); if (closable != null) { comp.setClosable(closable); } Boolean closed = JavaCreator.createBoolean(thing, "closed"); if (closed != null) { try { comp.setClosed(closed); } catch (PropertyVetoException e) { e.printStackTrace(); } } Cursor cursor = AwtCreator.createCursor(thing, "cursor", actionContext); if (cursor != null) { comp.setCursor(cursor); } Integer defaultCloseOperation = null; String d = thing.getString("defaultCloseOperation"); if ("DO_NOTHING_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.DO_NOTHING_ON_CLOSE; } else if ("HIDE_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.HIDE_ON_CLOSE; } else if ("DISPOSE_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.DISPOSE_ON_CLOSE; } if (defaultCloseOperation != null) { comp.setDefaultCloseOperation(defaultCloseOperation); } Boolean focusCycleRoot = JavaCreator.createBoolean(thing, "focusCycleRoot"); if (focusCycleRoot != null) { comp.setFocusCycleRoot(focusCycleRoot); } Icon frameIcon = SwingCreator.createIcon(thing, "frameIcon", actionContext); if (frameIcon != null) { comp.setFrameIcon(frameIcon); } Boolean setIcon = JavaCreator.createBoolean(thing, "setIcon"); if (setIcon != null) { try { comp.setIcon(setIcon); } catch (PropertyVetoException e) { e.printStackTrace(); } } Boolean iconifiable = JavaCreator.createBoolean(thing, "iconifiable"); if (iconifiable != null) { comp.setIconifiable(iconifiable); } Integer layer = JavaCreator.createInteger(thing, "layer"); if (layer != null) { comp.setLayer(layer); } Boolean maximizable = JavaCreator.createBoolean(thing, "maximizable"); if (maximizable != null) { comp.setMaximizable(maximizable); } Boolean maximum = JavaCreator.createBoolean(thing, "maximum"); if (maximum != null) { try { comp.setMaximum(maximum); } catch (PropertyVetoException e) { e.printStackTrace(); } } Boolean resizable = JavaCreator.createBoolean(thing, "resizable"); if (resizable != null) { comp.setResizable(resizable); } Boolean selected = JavaCreator.createBoolean(thing, "selected"); if (selected != null) { try { comp.setSelected(selected); } catch (PropertyVetoException e) { e.printStackTrace(); } } }
/** * Initialises the class and internal logger. Uses the supplied arguments to receive data from the * application and add data to the charts dynamically. * * @param title The title of the charts on display. Whether the displayed data is for <code>new * </code> or <code>old</code> links. That is whether the data is for newly discovered links * or existing (old) links already stored within the database. * @param parent The instance of <code>COMPortClient</code> that acts as the data source for the * charts. */ public LinkChart(String title, COMPortClient parent) { super("Charts", true, true, true, true); super.setLayer(1); identifier = title.toLowerCase(); // Obtain an instance of Logger for the class log = LoggerFactory.getLogger(className); owner = parent; // Setup a hashtable to hold the values for up, down and unknown link states Hashtable<String, Integer> linkStats = new Hashtable<String, Integer>(); if (identifier.equals("old")) { this.setTitle("Recognised Link Status on " + owner.getPortName() + ":"); // Get the current figures from the link table linkStats = ((LinkTable) owner.getLinkTable().getModel()).getInitialFigures(); } else if (identifier.equals("new")) { this.setTitle("Discovered Link Status on " + owner.getPortName() + ":"); linkStats = ((LinkTable) owner.getNewLinkTable().getModel()).getInitialFigures(); } else { // If the identifier was set to something other than old or new then it's not right. log.warning("An instance of LinkChart has been created for an unknown purpose."); return; } // Initialise the dataset for the pie chart dpdCurrentData = new DefaultPieDataset(); dpdCurrentData.insertValue(0, "Link Down", linkStats.get("down")); dpdCurrentData.insertValue(1, "Link Up", linkStats.get("up")); dpdCurrentData.insertValue(2, "Link State Unknown", linkStats.get("unknown")); // Initialise the dataset for the line chart dcdPreviousData = new DefaultCategoryDataset(); dcdPreviousData.addValue( linkStats.get("down"), "Link Down", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue( linkStats.get("up"), "Link Up", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue( linkStats.get("unknown"), "Link State Unknown", Calendar.getInstance().getTime().toString()); // Set the variables we need for holding the charts JFreeChart jfcCurrentStatus; // This will be displayed as a pie chart JFreeChart jfcPreviousStatus; // This will be displayed as a line chart ChartPanel cpCurrent; // Chartpanels hold the JFreeChart ChartPanel cpPrevious; // Use the factory to create the charts jfcCurrentStatus = ChartFactory.createPieChart("Current Status", dpdCurrentData, true, true, false); jfcPreviousStatus = ChartFactory.createLineChart( "Previous Status", "Time received", "Number of Links", dcdPreviousData, PlotOrientation.VERTICAL, true, true, false); // Add them to the chart panels cpCurrent = new ChartPanel(jfcCurrentStatus); cpPrevious = new ChartPanel(jfcPreviousStatus); // Add the chart panels to the content pane this.add(cpCurrent, BorderLayout.EAST); this.add(cpPrevious, BorderLayout.WEST); // Change the layout to show them next to each other this.setLayout(new GridLayout(1, 2)); // Add a listener to the window this.addInternalFrameListener(new CloseLinkChart(this)); log.finest("Adding frame to the desktop"); // Set the window properties and display it Client.getJNWindow().addToDesktop(this); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setSize(650, 400); this.setVisible(true); owner.addChartWindow(title, this); }