yext.svg.view
Class SVGPainter

java.lang.Object
  extended by y.view.AbstractCustomNodePainter
      extended by yext.svg.view.SVGPainter
All Implemented Interfaces:
GenericNodeRealizer.ContainsTest, GenericNodeRealizer.Painter

public class SVGPainter
extends AbstractCustomNodePainter
implements GenericNodeRealizer.ContainsTest

A delegate painter for GenericNodeRealizer that can display SVG graphics.

 

Constructor Summary
SVGPainter(SVGModel model)
          Creates a new SVGPainter that displays the given SVG model.
SVGPainter(URL svgURL)
          Creates a new SVGPainter that displays the SVG graphics loaded from the given URL.
 
Method Summary
 boolean contains(NodeRealizer context, double x, double y)
          Determines whether or not the specified point lies inside the specified realizer.
 SVGModel getModel()
          Returns the underlying SVG model of this class.
 boolean isUsingVisualBounds()
          Returns whether or not the visual bounds of the displayed vector graphic are used for contains tests.
protected  void paintNode(NodeRealizer context, Graphics2D graphics, boolean sloppy)
          Paints the SVG on the given graphics context.
 void setModel(SVGModel model)
          Sets the underlying SVG model of this class.
 void setUsingVisualBounds(boolean enabled)
          Specifies whether or not the visual bounds of the displayed vector graphic are used for contains tests.
 
Methods inherited from class y.view.AbstractCustomNodePainter
backupGraphics, createSelectionColor, getFillColor, getFillColor2, getFillPaint, getLineColor, getLinePaint, getLineStroke, initializeFill, initializeLine, paint, paintHotSpots, paintPorts, paintSloppy, paintText, restoreGraphics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGPainter

public SVGPainter(URL svgURL)
Creates a new SVGPainter that displays the SVG graphics loaded from the given URL.


SVGPainter

public SVGPainter(SVGModel model)
Creates a new SVGPainter that displays the given SVG model.

Method Detail

paintNode

protected void paintNode(NodeRealizer context,
                         Graphics2D graphics,
                         boolean sloppy)
Paints the SVG on the given graphics context. The SVG will be translated and scaled to fit within the bounds of the given realizer.

Specified by:
paintNode in class AbstractCustomNodePainter
Parameters:
sloppy - is currently ignored.

contains

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

Specified by:
contains in interface GenericNodeRealizer.ContainsTest
Parameters:
context - the realizer to check.
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 the specified realizer; false otherwise.
See Also:
isUsingVisualBounds(), setUsingVisualBounds(boolean)

getModel

public SVGModel getModel()
Returns the underlying SVG model of this class.


setModel

public void setModel(SVGModel model)
Sets the underlying SVG model of this class.

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

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 context realizer's rectangular bounding box is used for contains tests.
See Also:
setUsingVisualBounds(boolean), contains(y.view.NodeRealizer, 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 context realizer's rectangular bounding box is used for contains tests.
See Also:
isUsingVisualBounds(), contains(y.view.NodeRealizer, double, double)


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