public static void main(String[] args) throws Exception { XMLWindow xmlWindow = new XMLWindow(); xmlWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (args.length > 0) { String filename = args[0]; xmlWindow.setXML(new File(filename)); xmlWindow.setTitle("XML Window - " + filename); } else { BufferedReader in = new BufferedReader( new InputStreamReader(System.in, Constants.ENCODING)); final StringBuilder sb = new StringBuilder(); while (true) { String line = in.readLine(); if (line == null) break; sb.append(line); sb.append("\n"); } xmlWindow.setXML(sb.toString()); xmlWindow.setTitle("XML Window - <stdin>"); } xmlWindow.setLocation(200, 200); xmlWindow.setVisible(true); }
/** Displays XML from the given document. */ public void setDocument(Document doc) { this.doc = doc; getContentPane().removeAll(); if (doc == null) setVisible(false); else { // populate metadata window and size intelligently JTree tree = XMLCellRenderer.makeJTree(doc); for (int i=0; i<tree.getRowCount(); i++) tree.expandRow(i); getContentPane().add(new JScrollPane(tree)); pack(); Dimension dim = getSize(); final int pad = 20; dim.width += pad; dim.height += pad; Dimension ss = Toolkit.getDefaultToolkit().getScreenSize(); int maxWidth = 3 * ss.width / 4; int maxHeight = 3 * ss.height / 4; if (dim.width > maxWidth) dim.width = maxWidth; if (dim.height > maxHeight) dim.height = maxHeight; setSize(dim); } }
/** * Sets XML block associated with this window. This information will be * displayed in a tree structure when the Metadata button is clicked. */ public void setXML(String xml) { try { metaWindow.setXML(xml); } catch (ParserConfigurationException exc) { exc.printStackTrace(); } catch (SAXException exc) { exc.printStackTrace(); } catch (IOException exc) { exc.printStackTrace(); } metadata.setEnabled(metaWindow.getDocument() != null); }
/** Displays the OME-XML metadata window onscreen. */ public void showMetadataWindow() { // center window and show Rectangle r = getBounds(); Dimension w = metaWindow.getSize(); int x = r.x + (r.width - w.width) / 2; int y = r.y + (r.height - w.height) / 2; if (x < 5) x = 5; if (y < 5) y = 5; metaWindow.setLocation(x, y); metaWindow.setVisible(true); }
XMLWindow metaWindow = new XMLWindow("OME Metadata - " + getTitle()); metaWindow.setDefaultCloseOperation(XMLWindow.DISPOSE_ON_CLOSE); Exception exception = null; try { MetadataRetrieve retrieve = omexmlService.asRetrieve(omeMeta); metaWindow.setXML(omexmlService.getOMEXML(retrieve)); metaWindow.setVisible(true);
/** Displays OME-XML metadata in a tree in its own window. */ public XMLWindow displayOMEXML() throws FormatException, IOException { if (!options.isShowOMEXML()) return null; XMLWindow metaWindow = null; metaWindow = new XMLWindow("OME Metadata - " + process.getIdName()); Exception exc = null; try { ServiceFactory factory = new ServiceFactory(); OMEXMLService service = factory.getInstance(OMEXMLService.class); metaWindow.setXML(service.getOMEXML(process.getOMEMetadata())); WindowTools.placeWindow(metaWindow); metaWindow.setVisible(true); } catch (DependencyException e) { exc = e; } catch (ServiceException e) { exc = e; } catch (ParserConfigurationException e) { exc = e; } catch (SAXException e) { exc = e; } if (exc != null) throw new FormatException(exc); xmlWindow = metaWindow; // save reference to OME-XML window return metaWindow; }
metaWindow = new XMLWindow("OME Metadata - " + getTitle());
/** Displays XML from the given file. */ public void setXML(File file) throws ParserConfigurationException, SAXException, IOException { setDocument(null); // parse XML from file into DOM structure DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = docFact.newDocumentBuilder(); Document doc = db.parse(file); setDocument(doc); }
XMLWindow metaWindow = new XMLWindow("OME Metadata - " + getTitle()); metaWindow.setDefaultCloseOperation(XMLWindow.DISPOSE_ON_CLOSE); Exception exception = null; try { MetadataRetrieve retrieve = omexmlService.asRetrieve(omeMeta); metaWindow.setXML(omexmlService.getOMEXML(retrieve)); metaWindow.setVisible(true);
/** Displays the OME-XML metadata window onscreen. */ public void showMetadataWindow() { // center window and show Rectangle r = getBounds(); Dimension w = metaWindow.getSize(); int x = r.x + (r.width - w.width) / 2; int y = r.y + (r.height - w.height) / 2; if (x < 5) x = 5; if (y < 5) y = 5; metaWindow.setLocation(x, y); metaWindow.setVisible(true); }
/** Displays OME-XML metadata in a tree in its own window. */ public XMLWindow displayOMEXML() throws FormatException, IOException { if (!options.isShowOMEXML()) return null; XMLWindow metaWindow = null; metaWindow = new XMLWindow("OME Metadata - " + process.getIdName()); Exception exc = null; try { ServiceFactory factory = new ServiceFactory(); OMEXMLService service = factory.getInstance(OMEXMLService.class); metaWindow.setXML(service.getOMEXML(process.getOMEMetadata())); WindowTools.placeWindow(metaWindow); metaWindow.setVisible(true); } catch (DependencyException e) { exc = e; } catch (ServiceException e) { exc = e; } catch (ParserConfigurationException e) { exc = e; } catch (SAXException e) { exc = e; } if (exc != null) throw new FormatException(exc); xmlWindow = metaWindow; // save reference to OME-XML window return metaWindow; }
metaWindow = new XMLWindow("OME Metadata - " + getTitle());
/** Displays XML from the given file. */ public void setXML(File file) throws ParserConfigurationException, SAXException, IOException { setDocument(null); // parse XML from file into DOM structure DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = docFact.newDocumentBuilder(); Document doc = db.parse(file); setDocument(doc); }
public static void main(String[] args) throws Exception { XMLWindow xmlWindow = new XMLWindow(); xmlWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (args.length > 0) { String filename = args[0]; xmlWindow.setXML(new File(filename)); xmlWindow.setTitle("XML Window - " + filename); } else { BufferedReader in = new BufferedReader( new InputStreamReader(System.in, Constants.ENCODING)); final StringBuilder sb = new StringBuilder(); while (true) { String line = in.readLine(); if (line == null) break; sb.append(line); sb.append("\n"); } xmlWindow.setXML(sb.toString()); xmlWindow.setTitle("XML Window - <stdin>"); } xmlWindow.setLocation(200, 200); xmlWindow.setVisible(true); }
/** Displays XML from the given document. */ public void setDocument(Document doc) { this.doc = doc; getContentPane().removeAll(); if (doc == null) setVisible(false); else { // populate metadata window and size intelligently JTree tree = XMLCellRenderer.makeJTree(doc); for (int i=0; i<tree.getRowCount(); i++) tree.expandRow(i); getContentPane().add(new JScrollPane(tree)); pack(); Dimension dim = getSize(); final int pad = 20; dim.width += pad; dim.height += pad; Dimension ss = Toolkit.getDefaultToolkit().getScreenSize(); int maxWidth = 3 * ss.width / 4; int maxHeight = 3 * ss.height / 4; if (dim.width > maxWidth) dim.width = maxWidth; if (dim.height > maxHeight) dim.height = maxHeight; setSize(dim); } }
/** * Sets XML block associated with this window. This information will be * displayed in a tree structure when the Metadata button is clicked. */ public void setXML(String xml) { try { metaWindow.setXML(xml); } catch (ParserConfigurationException exc) { exc.printStackTrace(); } catch (SAXException exc) { exc.printStackTrace(); } catch (IOException exc) { exc.printStackTrace(); } metadata.setEnabled(metaWindow.getDocument() != null); }
/** Displays XML from the given string. */ public void setXML(String xml) throws ParserConfigurationException, SAXException, IOException { setDocument(null); // parse XML from string into DOM structure DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = docFact.newDocumentBuilder(); ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(Constants.ENCODING)); Document doc = db.parse(is); is.close(); setDocument(doc); }
/** Displays XML from the given string. */ public void setXML(String xml) throws ParserConfigurationException, SAXException, IOException { setDocument(null); // parse XML from string into DOM structure DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = docFact.newDocumentBuilder(); ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(Constants.ENCODING)); Document doc = db.parse(is); is.close(); setDocument(doc); }