public static double extractCgmScale( String cgmText, String cgmLocation ) throws SVGException { Matcher m = cgmScalePattern.matcher( cgmText ); if ( m.find( ) ) { return parseDouble( m.group( 1 ) ); } else { throw new SVGException( "Failed to parse CGM scale: cgm-location = " + cgmLocation ); } }
new Timer(100, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long diff = System.currentTimeMillis() - start_time; icon.getSvgUniverse().setCurTime(diff % (10 * 1000)); try { icon.getSvgUniverse().updateTime(); } catch (SVGException ex) { ex.printStackTrace(); } icon.paintIcon(null, g2, 0, 0); //or repaint it somehow! } }).start();
public static int[] extractCgmBounds( String cgmText, String cgmLocation ) throws SVGException { Matcher m = cgmBoundsPattern.matcher( cgmText ); if ( m.find( ) ) { return ints( parseInt( m.group( 1 ).trim( ) ), parseInt( m.group( 2 ).trim( ) ), parseInt( m.group( 3 ).trim( ) ), parseInt( m.group( 4 ).trim( ) ) ); } else { throw new SVGException( "Failed to parse CGM bounds: cgm-location = " + cgmLocation ); } }
public void mouseClicked(MouseEvent evt) { SVGDiagram diagram = svgDisplayPanel.getDiagram(); if (diagram == null) return; System.out.println("Picking at cursor (" + evt.getX() + ", " + evt.getY() + ")"); try { List paths = diagram.pick(new Point2D.Float(evt.getX(), evt.getY()), null); for (int i = 0; i < paths.size(); i++) { ArrayList path = (ArrayList)paths.get(i); System.out.println(pathToString(path)); } } catch (SVGException ex) { ex.printStackTrace(); } } }
@Override public void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (viewXform != null) { try { viewXform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } super.pick(xPoint, boundingBox, retVec); }
private void panel_svgAreaMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_panel_svgAreaMouseReleased {//GEN-HEADEREND:event_panel_svgAreaMouseReleased SVGDiagram diagram = svgDisplayPanel.getDiagram(); List pickedElements; try { pickedElements = diagram.pick(new Point(evt.getX(), evt.getY()), null); } catch (SVGException ex) { ex.printStackTrace(); return; } System.out.println("Pick results:"); for (Iterator it = pickedElements.iterator(); it.hasNext();) { ArrayList path = (ArrayList)it.next(); System.out.print(" Path: "); for (Iterator it2 = path.iterator(); it2.hasNext();) { SVGElement ele = (SVGElement)it2.next(); System.out.print("" + ele.getId() + "(" + ele.getClass().getName() + ") "); } System.out.println(); } }//GEN-LAST:event_panel_svgAreaMouseReleased
@Override public void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (viewXform != null) { try { viewXform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } super.pick(xPoint, boundingBox, retVec); }
public void paintComponent(Graphics gg) { Graphics2D g = (Graphics2D)gg; if (bgColor != null) { Dimension dim = getSize(); g.setColor(bgColor); g.fillRect(0, 0, dim.width, dim.height); } g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); if (diagram != null) { try { diagram.render(g); } catch (SVGException e) { e.printStackTrace(); } } }
/** * Most resources your component will want to access will be resources on your classpath. * This method will interpret the passed string as a path in the classpath and use * Class.getResource() to determine the URI of the SVG. */ public void setSvgResourcePath(String resourcePath) throws SVGException { URI old = this.svgURI; try { svgURI = new URI(getClass().getResource(resourcePath).toString()); //System.err.println("SVGPanel: new URI " + svgURI + " from path " + resourcePath); firePropertyChange("svgURI", old, svgURI); repaint(); } catch (Exception e) { throw new SVGException("Could not resolve path " + resourcePath, e); // svgURI = old; } }
/** * Sets the dimensions of the device being rendered into. This is used by * SVGRoot when its x, y, width or height parameters are specified as * percentages. */ public void setDeviceViewport(Rectangle deviceViewport) { this.deviceViewport.setBounds(deviceViewport); if (root != null) { try { root.build(); } catch (SVGException ex) { ex.printStackTrace(); } } } }
void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (xform != null) { try { xform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } for (Iterator it = children.iterator(); it.hasNext();) { SVGElement ele = (SVGElement)it.next(); if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement)ele; rendEle.pick(xPoint, boundingBox, retVec); } } }
/** * Most resources your component will want to access will be resources on your classpath. * This method will interpret the passed string as a path in the classpath and use * Class.getResource() to determine the URI of the SVG. */ public void setSvgResourcePath(String resourcePath) throws SVGException { URI old = this.svgURI; try { svgURI = new URI(getClass().getResource(resourcePath).toString()); //System.err.println("SVGPanel: new URI " + svgURI + " from path " + resourcePath); firePropertyChange("svgURI", old, svgURI); repaint(); } catch (Exception e) { throw new SVGException("Could not resolve path " + resourcePath, e); // svgURI = old; } }
void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (xform != null) { try { xform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } for (Iterator it = children.iterator(); it.hasNext();) { SVGElement ele = (SVGElement) it.next(); if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; rendEle.pick(xPoint, boundingBox, retVec); } } }
/** * Most resources your component will want to access will be resources on your classpath. * This method will interpret the passed string as a path in the classpath and use * Class.getResource() to determine the URI of the SVG. */ public void setSvgResourcePath(String resourcePath) throws SVGException { URI old = this.svgURI; try { svgURI = new URI(getClass().getResource(resourcePath).toString()); //System.err.println("SVGPanel: new URI " + svgURI + " from path " + resourcePath); firePropertyChange("svgURI", old, svgURI); repaint(); } catch (Exception e) { throw new SVGException("Could not resolve path " + resourcePath, e); // svgURI = old; } }
/** * Most resources your component will want to access will be resources on your classpath. * This method will interpret the passed string as a path in the classpath and use * Class.getResource() to determine the URI of the SVG. */ public void setSvgResourcePath(String resourcePath) throws SVGException { URI old = this.svgURI; try { svgURI = new URI(getClass().getResource(resourcePath).toString()); //System.err.println("SVGPanel: new URI " + svgURI + " from path " + resourcePath); firePropertyChange("svgURI", old, svgURI); repaint(); } catch (Exception e) { throw new SVGException("Could not resolve path " + resourcePath, e); // svgURI = old; } }
@Override void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (xform != null) { try { xform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } for (SVGElement ele : children) { if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; rendEle.pick(xPoint, boundingBox, retVec); } } }
@Override void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException { Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); if (xform != null) { try { xform.inverseTransform(point, xPoint); } catch (NoninvertibleTransformException ex) { throw new SVGException(ex); } } for (SVGElement ele : children) { if (ele instanceof RenderableElement) { RenderableElement rendEle = (RenderableElement) ele; rendEle.pick(xPoint, boundingBox, retVec); } } }
throw new SVGException("Unknown transform type");
} else throw new SVGException("Unknown transform type");
} else throw new SVGException("Unknown transform type");