public void treeCollapsed (TreeExpansionEvent ev) { String evPathString = ev.getPath().toString(); evPathString = evPathString.substring(evPathString.indexOf("[")+1,evPathString.lastIndexOf("]")); evPathString = evPathString.substring(getTitle().length()+2,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = rootPath.substring(rootPath.indexOf("[")+1,rootPath.lastIndexOf("]")); String path = "["+rootPath +", "+evPathString+"]"; pcp.unsetExpandedStateProperty(path); }
void registerPanel(TreePanel panel) { String key = pStr2Key(panel.getRootPath().toString()); panels.put(key,panel); setPanelShowingProperty(panel.getRootPath().toString()); propertiesChanged=true; }
void registerPanel(TreePanel panel) { String key = pStr2Key(panel.getRootPath().toString()); panels.put(key,panel); setPanelShowingProperty(panel.getRootPath().toString()); propertiesChanged=true; }
public void treeCollapsed (TreeExpansionEvent ev) { String evPathString = ev.getPath().toString(); evPathString = evPathString.substring(evPathString.indexOf("[")+1,evPathString.lastIndexOf("]")); evPathString = evPathString.substring(getTitle().length()+2,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = rootPath.substring(rootPath.indexOf("[")+1,rootPath.lastIndexOf("]")); String path = "["+rootPath +", "+evPathString+"]"; pcp.unsetExpandedStateProperty(path); }
void recordGeometry(TreePanel panel) { String pTitle = panel.getRootPath().toString(); pTitle = pStr2Key(pTitle); JFrame frame = panel.getFrame(); if (frame!=null) { Rectangle rect=frame.getBounds(); String xCoord = (new Integer(rect.x)).toString(); String yCoord = (new Integer(rect.y)).toString(); String width = (new Integer(rect.width)).toString(); String height = (new Integer(rect.height)).toString(); if (pTitle.equals("Control_Panel")) pTitle = "Control_Panel.@Main"; String geometry = xCoord+" "+yCoord+" "+width+" "+height; if (IJ.debugMode) IJ.log("CP.recordGeometry: "+pTitle+" "+geometry); Prefs.set(pTitle, geometry); } }
void recordGeometry(TreePanel panel) { String pTitle = panel.getRootPath().toString(); pTitle = pStr2Key(pTitle); JFrame frame = panel.getFrame(); if (frame!=null) { Rectangle rect=frame.getBounds(); String xCoord = (new Integer(rect.x)).toString(); String yCoord = (new Integer(rect.y)).toString(); String width = (new Integer(rect.width)).toString(); String height = (new Integer(rect.height)).toString(); if (pTitle.equals("Control_Panel")) pTitle = "Control_Panel.@Main"; String geometry = xCoord+" "+yCoord+" "+width+" "+height; if (IJ.debugMode) IJ.log("CP.recordGeometry: "+pTitle+" "+geometry); Prefs.set(pTitle, geometry); } }
void close() { pFrame.dispatchEvent(new WindowEvent(pFrame,WindowEvent.WINDOW_CLOSING)); pcp.unsetPanelShowingProperty(getRootPath().toString()); }
/** Upon window closing, the panel removes itself from the vector of visible panels (member of pcp). * Then, if this is the only visible panel left, the properties are saved; else, if this is the * main panel, all other visible panels are also closed and properties * are saved */ public void windowClosing(WindowEvent e) { if (IJ.debugMode) IJ.log("CP.windowClosing: "+isMainPanel); if (isMainPanel) pcp.saveProperties(); pcp.unsetPanelShowingProperty(getRootPath().toString()); }
void restoreGeometry(TreePanel panel) { String pTitle = panel.getRootPath().toString(); pTitle = pStr2Key(pTitle); if (pTitle.equals("Control_Panel")) pTitle = "Control_Panel.@Main"; if (IJ.debugMode) IJ.log("CP.restoreGeometry: "+pTitle); String geom = Prefs.get(pTitle, null); if (geom!=null) { int[] coords = s2ints(geom); if (coords!=null && coords.length==4) panel.setBounds(coords[0],coords[1],coords[2],coords[3]); else { Point pnt = panel.getDefaultLocation(); if (pnt!=null) panel.getFrame().setLocation((int)pnt.getX(),(int)pnt.getY()); } } }
/** Upon window closing, the panel removes itself from the vector of visible panels (member of pcp). * Then, if this is the only visible panel left, the properties are saved; else, if this is the * main panel, all other visible panels are also closed and properties * are saved */ public void windowClosing(WindowEvent e) { if (IJ.debugMode) IJ.log("CP.windowClosing: "+isMainPanel); if (isMainPanel) pcp.saveProperties(); pcp.unsetPanelShowingProperty(getRootPath().toString()); }
void restoreGeometry(TreePanel panel) { String pTitle = panel.getRootPath().toString(); pTitle = pStr2Key(pTitle); if (pTitle.equals("Control_Panel")) pTitle = "Control_Panel.@Main"; if (IJ.debugMode) IJ.log("CP.restoreGeometry: "+pTitle); String geom = Prefs.get(pTitle, null); if (geom!=null) { int[] coords = s2ints(geom); if (coords!=null && coords.length==4) panel.setBounds(coords[0],coords[1],coords[2],coords[3]); else { Point pnt = panel.getDefaultLocation(); if (pnt!=null) panel.getFrame().setLocation((int)pnt.getX(),(int)pnt.getY()); } } }
void close() { pFrame.dispatchEvent(new WindowEvent(pFrame,WindowEvent.WINDOW_CLOSING)); pcp.unsetPanelShowingProperty(getRootPath().toString()); }
public void treeExpanded(TreeExpansionEvent ev) { TreePath evPath = ev.getPath(); //DefaultMutableTreeNode node = (DefaultMutableTreeNode)evPath.getLastPathComponent(); String evPathString = ev.getPath().toString(); evPathString = pcp.pStr2Key(evPathString); evPathString = evPathString.substring(getTitle().length()+1,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = pcp.pStr2Key(rootPath); //String path = rootPath+"."+evPathString; String path = rootPath+"."+evPathString; if (pcp.hasPanelShowingProperty(path)) { Hashtable panels = pcp.getPanels(); TreePanel p = (TreePanel)panels.get(path); if(p!=null) p.close(); } pcp.setExpandedStateProperty(path); }
public void treeExpanded(TreeExpansionEvent ev) { TreePath evPath = ev.getPath(); //DefaultMutableTreeNode node = (DefaultMutableTreeNode)evPath.getLastPathComponent(); String evPathString = ev.getPath().toString(); evPathString = pcp.pStr2Key(evPathString); evPathString = evPathString.substring(getTitle().length()+1,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = pcp.pStr2Key(rootPath); //String path = rootPath+"."+evPathString; String path = rootPath+"."+evPathString; if (pcp.hasPanelShowingProperty(path)) { Hashtable panels = pcp.getPanels(); TreePanel p = (TreePanel)panels.get(path); if(p!=null) p.close(); } pcp.setExpandedStateProperty(path); }
void setVisible() { if (pFrame!=null && !pFrame.isVisible()) { restoreExpandedNodes(); if (defaultLocation!=null) pFrame.setLocation(defaultLocation); pFrame.setVisible(true); // close expanded path to this panel in its parent panel (if visible and if the path is expanded) DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel pnl = pcp.getPanelForNode(parent); if (pnl!=null && pnl.isVisible()) { TreeNode[] rPath = root.getPath(); TreeNode[] pPath = pnl.getRootNode().getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[rPath.length-pPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)rPath[i+pPath.length-1]; //TreePath path = new TreePath(rPath); TreePath localPath = new TreePath(tPath); pnl.getTree().collapsePath(localPath); } } } if (pcp!=null) pcp.setPanelShowingProperty(getRootPath().toString()); }
void setVisible() { if (pFrame!=null && !pFrame.isVisible()) { restoreExpandedNodes(); if (defaultLocation!=null) pFrame.setLocation(defaultLocation); pFrame.setVisible(true); // close expanded path to this panel in its parent panel (if visible and if the path is expanded) DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel pnl = pcp.getPanelForNode(parent); if (pnl!=null && pnl.isVisible()) { TreeNode[] rPath = root.getPath(); TreeNode[] pPath = pnl.getRootNode().getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[rPath.length-pPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)rPath[i+pPath.length-1]; //TreePath path = new TreePath(rPath); TreePath localPath = new TreePath(tPath); pnl.getTree().collapsePath(localPath); } } } if (pcp!=null) pcp.setPanelShowingProperty(getRootPath().toString()); }