/** * Construct new configuration information source * * @param xmlFile xml file associated with configuration info */ public PropertyConfig(String prefix, String tag) { // Get the prefix.tag property (and all of its children) from Cytoscape properties this.prefix = prefix; Properties props = CytoscapeInit.getProperties(); String xml = props.getProperty(prefix + "." + tag); // System.out.println("Property "+prefix+"."+tag+" from Cytoscape = "+xml); this.root = xmlParse(xml, tag); if (this.root == null) this.root = new PropertyConfigNode(tag); }
/** Store current configuration data structure into property sheet */ public void store() { // The configuration data is stored in a non-binary tree where // each node in the tree can have children and a value. In order // to serialize this, and avoid potential naming problems, I've // added indices to indicate children. Properties props = CytoscapeInit.getProperties(); String config = getProperty(root); // System.out.println("Setting property "+prefix+"."+root.getName()+" to "+config); props.setProperty(prefix + "." + root.getName(), config); }
/** Contains a CyNetworkView. */ protected void createContainer(final CyNetworkView view) { if (networkViewMap.containsKey(view.getNetwork().getIdentifier())) return; // create a new InternalFrame and put the CyNetworkViews Component into // it final JInternalFrame iframe = new JInternalFrame(view.getTitle(), true, true, true, true); iframe.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { Cytoscape.destroyNetworkView(view); } }); desktopPane.add(iframe); // code added to support layered canvas for each CyNetworkView if (view instanceof DGraphView) { final InternalFrameComponent internalFrameComp = new InternalFrameComponent(iframe.getLayeredPane(), (DGraphView) view); iframe.getContentPane().add(internalFrameComp); internalFrameComponentMap.put(view.getNetwork().getIdentifier(), internalFrameComp); } else { logger.info("NetworkViewManager.createContainer() - DGraphView not found!"); iframe.getContentPane().add(view.getComponent()); } iframe.pack(); int x = 0; int y = 0; JInternalFrame refFrame = null; JInternalFrame[] allFrames = desktopPane.getAllFrames(); if (allFrames.length > 1) { refFrame = allFrames[0]; } if (refFrame != null) { x = refFrame.getLocation().x + 20; y = refFrame.getLocation().y + 20; } if (x > (desktopPane.getWidth() - MINIMUM_WIN_WIDTH)) { x = desktopPane.getWidth() - MINIMUM_WIN_WIDTH; } if (y > (desktopPane.getHeight() - MINIMUM_WIN_HEIGHT)) { y = desktopPane.getHeight() - MINIMUM_WIN_HEIGHT; } if (x < 0) { x = 0; } if (y < 0) { y = 0; } iframe.setBounds(x, y, 400, 400); // maximize the frame if the specified property is set try { String max = CytoscapeInit.getProperties().getProperty("maximizeViewOnCreate"); if ((max != null) && Boolean.parseBoolean(max)) iframe.setMaximum(true); } catch (PropertyVetoException pve) { logger.warn("Unable to maximize internal frame: " + pve.getMessage()); } iframe.setVisible(true); iframe.addInternalFrameListener(this); iframe.setResizable(true); networkViewMap.put(view.getNetwork().getIdentifier(), iframe); componentMap.put(iframe, view.getNetwork().getIdentifier()); firePropertyChange( CytoscapeDesktop.NETWORK_VIEW_FOCUSED, null, view.getNetwork().getIdentifier()); }