yext.svg.view
Class SVGNodeRealizer

java.lang.Object
  extended by y.view.NodeRealizer
      extended by yext.svg.view.SVGNodeRealizer
All Implemented Interfaces:
NodeLayout

public class SVGNodeRealizer
extends NodeRealizer

A node realizer that displays a node as scalable vector graphics. The scalable vector graphics must be given in SVG format.

The visual representation of a SVGNodeRealizer is essentially determined by its associated SVG content. As a consequence, the implementation of paintNode(java.awt.Graphics2D) ignores the following properties:

This node realizer is based on the SVG implementation provided by the Batik project.

 

Field Summary
 
Fields inherited from class y.view.NodeRealizer
height, HOTSPOT_E, HOTSPOT_N, HOTSPOT_NE, HOTSPOT_NONE, HOTSPOT_NW, HOTSPOT_S, HOTSPOT_SE, HOTSPOT_SW, HOTSPOT_W, width, x, y
 
Constructor Summary
SVGNodeRealizer()
          Initializes a new SVGNodeRealizer instance without associated SVG graphics.
SVGNodeRealizer(NodeRealizer argNodeRealizer)
          Initializes a new SVGNodeRealizer instance whose attributes are copied from the given prototype realizer.
SVGNodeRealizer(SVGModel model)
          Initializes a new SVGNodeRealizer instance that displays the given scalable vector graphics.
SVGNodeRealizer(URL svgURL)
          Initializes a new SVGNodeRealizer instance that displays the referenced SVG document.
 
Method Summary
 boolean contains(double x, double y)
          Determines whether or not the specified point lies inside this realizer.
 NodeRealizer createCopy(NodeRealizer nr)
          Creates and returns a new SVGNodeRealizer instance whose attributes are copied from the given realizer.
 boolean findIntersection(double ix, double iy, double ox, double oy, Point2D result)
           
 SVGModel getModel()
          Returns the underlying SVG model for this SVGNodeRealizer.
 URL getSVGURL()
          Returns the URL of the SVG graphics that will be displayed by this realizer.
 boolean isUsingVisualBounds()
          Returns whether or not the visual bounds of the displayed vector graphic are used for contains tests.
 void paintNode(Graphics2D gfx)
          Paints the node as scalable vector graphics on the given graphics context.
 void read(ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
 void setModel(SVGModel model)
          Sets the underlying SVG model for this SVGNodeRealizer.
 void setSVGURL(URL svgURL)
          Sets the URL of the SVG graphics that will be displayed by this realizer.
 void setToOriginalSize()
          Sets the size of this realizer to the natural size of the svg graphics being displayed.
 void setUsingVisualBounds(boolean enabled)
          Specifies whether or not the visual bounds of the displayed vector graphic are used for contains tests.
 void write(ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class y.view.NodeRealizer
addLabel, addPort, boundsChanged, calcUnionRect, calcUnionRect, calcUnionRectImpl, calcUnionRectLabels, calcUnionRectPorts, createCopy, createNodeLabel, findBBIntersection, getAutoBoundsFeature, getBoundingBox, getCenterX, getCenterY, getFillColor, getFillColor2, getHeight, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getMouseInputEditorProvider, getNode, getPort, getPortCandidates, getSizeConstraintProvider, getSloppySelectionColor, getWidth, getX, getY, hotSpotHit, intersects, invalidatePortPositions, isInBox, isSelected, isTransparent, isVisible, labelBoundsChanged, labelCount, moveBy, paint, paintHotSpots, paintLayer, paintLayerSloppy, paintPorts, paintSloppy, paintText, portCount, removeLabel, removeLabel, removePort, removePort, repaint, setCenter, setCenterX, setCenterY, setEdgesDirty, setFillColor, setFillColor2, setFrame, setFrame, setHeight, setHotSpotColor, setLabel, setLabelText, setLayer, setLayer, setLineColor, setLineType, setLocation, setSelected, setSize, setSloppySelectionColor, setTransparent, setVisible, setWidth, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGNodeRealizer

public SVGNodeRealizer()
Initializes a new SVGNodeRealizer instance without associated SVG graphics. Use setSVGURL(java.net.URL) or setModel(SVGModel) to specify the vector graphics to display.


SVGNodeRealizer

public SVGNodeRealizer(SVGModel model)
Initializes a new SVGNodeRealizer instance that displays the given scalable vector graphics.

Parameters:
model - the scalable vector graphics to display. May not be null!

SVGNodeRealizer

public SVGNodeRealizer(URL svgURL)
Initializes a new SVGNodeRealizer instance that displays the referenced SVG document. The size of this node will be determined by the bounds of the referenced graphics.

Parameters:
svgURL - the URL of the SVG document to display.

SVGNodeRealizer

public SVGNodeRealizer(NodeRealizer argNodeRealizer)
Initializes a new SVGNodeRealizer instance whose attributes are copied from the given prototype realizer.

Parameters:
argNodeRealizer - the prototype realizer whose attributes are copied.
Method Detail

createCopy

public NodeRealizer createCopy(NodeRealizer nr)
Creates and returns a new SVGNodeRealizer instance whose attributes are copied from the given realizer.

Specified by:
createCopy in class NodeRealizer
Parameters:
nr - the prototype realizer whose attributes are copied.

findIntersection

public boolean findIntersection(double ix,
                                double iy,
                                double ox,
                                double oy,
                                Point2D result)
Overrides:
findIntersection in class NodeRealizer

getSVGURL

public URL getSVGURL()
Returns the URL of the SVG graphics that will be displayed by this realizer.


setSVGURL

public void setSVGURL(URL svgURL)
Sets the URL of the SVG graphics that will be displayed by this realizer. The given URL must point to a resource in SVG format.


getModel

public SVGModel getModel()
Returns the underlying SVG model for this SVGNodeRealizer.


setModel

public void setModel(SVGModel model)
Sets the underlying SVG model for this SVGNodeRealizer.

Parameters:
model - the SVG model to use. May not be null!

setToOriginalSize

public void setToOriginalSize()
Sets the size of this realizer to the natural size of the svg graphics being displayed. This method will do nothing if the svg graphics do not include any shapes for which bounds can be calculated.


isUsingVisualBounds

public boolean isUsingVisualBounds()
Returns whether or not the visual bounds of the displayed vector graphic are used for contains tests.

Defaults to false.

Returns:
true if the visual bounds of the displayed vector graphic are used for contains tests and false if the realizer's rectangular bounding box is used for contains tests.
See Also:
setUsingVisualBounds(boolean), contains(double, double)

setUsingVisualBounds

public void setUsingVisualBounds(boolean enabled)
Specifies whether or not the visual bounds of the displayed vector graphic are used for contains tests.

Defaults to false.

Parameters:
enabled - if true the visual bounds of the displayed vector graphic are used for contains tests; otherwise the realizer's rectangular bounding box is used for contains tests.
See Also:
isUsingVisualBounds(), contains(double, double)

contains

public boolean contains(double x,
                        double y)
Determines whether or not the specified point lies inside this realizer.

Overrides:
contains in class NodeRealizer
Parameters:
x - the x-coordinate of the point to check.
y - the y-coordinate of the point to check.
Returns:
true if the specified point lies inside this realizer; false otherwise.
See Also:
isUsingVisualBounds(), setUsingVisualBounds(boolean)

paintNode

public void paintNode(Graphics2D gfx)
Paints the node as scalable vector graphics on the given graphics context.

Specified by:
paintNode in class NodeRealizer

write

public void write(ObjectOutputStream out)
           throws IOException
Deprecated. Use the GraphML format instead.

Writes out this realizer in a serialized form. Note that unlike previous versions, SVGNodeRealizer now serializes the complete information contained in the SVG DOM as well as the URL associated to the realizer. As a side effect, serialization/deserialization no longer depends on the location and content of the original SVG file (if that existed at all).

Overrides:
write in class NodeRealizer
Throws:
IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Deprecated. Use the GraphML format instead.

Reads in the serialized form of this realizer. Note that unlike previous versions, SVGNodeRealizer now deserializes the complete information for the SVG DOM as well as the URL associated to the realizer. As a side effect, serialization/deserialization no longer depends on the location and content of the original SVG file (if that existed at all).

Overrides:
read in class NodeRealizer
Throws:
IOException
ClassNotFoundException


© Copyright 2002-2015,
yWorks GmbH.
All rights reserved.