yext.svg.view
Class SVGBackgroundRenderer

java.lang.Object
  extended by yext.svg.view.SVGBackgroundRenderer
All Implemented Interfaces:
BackgroundRenderer

public class SVGBackgroundRenderer
extends Object
implements BackgroundRenderer

A background renderer that displays scalable vector graphics.

This renderer assumes that a GraphicsContext can be retrieved from the Graphics2D instance it paints upon. The Graph2DView instance associated to said context has be the view whose background has to be painted.

See Also:
YRenderingHints.getGraphicsContext(java.awt.Graphics2D)
 

Field Summary
static byte BRICKED
          Mode constant.
static byte CENTERED
          Mode constant.
static byte DYNAMIC
          Mode constant.
static byte FULLSCREEN
          Mode constant.
static byte PLAIN
          Mode constant.
static byte SCALED
          Mode constant.
static byte TILED
          Mode constant.
 
Constructor Summary
SVGBackgroundRenderer()
          Initializes a new SVGBackgroundRenderer instance that displays a solid, white background.
SVGBackgroundRenderer(SVGModel model)
          Initializes a new SVGBackgroundRenderer instance that displays the specified SVG graphics.
SVGBackgroundRenderer(URL svgURL)
          Initializes a new SVGBackgroundRenderer instance that displays the SVG document referenced by the specified URL.
 
Method Summary
 Color getColor()
          Returns the color used to paint the background.
 YPoint getImageOrigin()
          Returns the image origin (upper left corner) of the displayed background graphic.
 byte getMode()
          Returns the mode in which the background should be painted.
 SVGModel getModel()
          Returns the underlying SVG model for this renderer.
 URL getSVGURL()
          Returns the URL of the SVG document that is displayed by this renderer.
 void paint(Graphics2D gfx, int x, int y, int w, int h)
          Paints the scalable vector graphics associated to this renderer upon the specified graphics instance.
 void setColor(Color color)
          Sets the color used to paint the background.
 void setImageOrigin(YPoint origin)
          Sets the origin (upper left corner) of the displayed background graphic.
 void setMode(byte mode)
          Sets the mode in which the background should be painted.
 void setModel(SVGModel model)
          Sets the underlying SVG model for this renderer.
 void setSVGURL(URL svgURL)
          Sets the URL of the SVG document to be displayed by this renderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FULLSCREEN

public static final byte FULLSCREEN
Mode constant. When in this mode, the background graphic has its upper left corner in the view's upper left corner and its size is scaled to the view's size. The background is static, i.e. zooming or scrolling in the view have no effect on the background. Resizing the view, though, has a scaling effect on the background graphic.

See Also:
getMode(), Constant Field Values

TILED

public static final byte TILED
Mode constant. When in this mode, the background graphic is drawn as tiles in the view. The background is static, i.e. zooming or scrolling in the view have no effect on the background.

See Also:
getMode(), Constant Field Values

BRICKED

public static final byte BRICKED
Mode constant. When in this mode, the background graphic is drawn as bricks in the view. The background is static, i.e. zooming or scrolling in the view have no effect on the background.

See Also:
getMode(), Constant Field Values

CENTERED

public static final byte CENTERED
Mode constant. When in this mode, the background graphic is displayed in the center of the view. The specified background color is used to draw visible regions that lie outside the bounds of the background graphic. The background is static, i.e. zooming or scrolling in the view have no effect on the background.

See Also:
getMode(), getColor(), Constant Field Values

PLAIN

public static final byte PLAIN
Mode constant. When in this mode the background graphic is drawn at a specified image origin in the view. The origin coordinates are interpreted as view (component) coordinates. The specified background color is used to draw visible regions that lie outside the bounds of the background graphic. The background is static, i.e. zooming or scrolling in the view have no effect on the background.

See Also:
getMode(), getImageOrigin(), getColor(), Constant Field Values

DYNAMIC

public static final byte DYNAMIC
Mode constant. When in this mode, the background graphic is considered to be part of the displayed contents and not a view decoration. This means that zooming or scrolling in the view will affect the background graphic in the same way as ordinary graph elements. The specified background color is used to draw visible regions that lie outside the bounds of the background graphic.

See Also:
getMode(), getColor(), Constant Field Values

SCALED

public static final byte SCALED
Mode constant. When in this mode the background graphic is displayed in the center of the view but scaled in such a way that the graphic matches (at least) one dimension of the view's size while still preserving the original aspect ratio of the background graphic. The specified background color is used to draw visible regions that lie outside the bounds of the background graphic. The background is static, i.e. zooming or scrolling in the view have no effect on the background. Resizing the view, though, has a scaling effect on the background graphic.

See Also:
getMode(), getColor(), Constant Field Values
Constructor Detail

SVGBackgroundRenderer

public SVGBackgroundRenderer()
Initializes a new SVGBackgroundRenderer instance that displays a solid, white background.


SVGBackgroundRenderer

public SVGBackgroundRenderer(URL svgURL)
Initializes a new SVGBackgroundRenderer instance that displays the SVG document referenced by the specified URL.

Parameters:
svgURL - the URL of the SVG document to display.
See Also:
getSVGURL(), setSVGURL(java.net.URL)

SVGBackgroundRenderer

public SVGBackgroundRenderer(SVGModel model)
Initializes a new SVGBackgroundRenderer instance that displays the specified SVG graphics.

Parameters:
model - the SVG graphics to display. May not be null!
Throws:
IllegalArgumentException - if the specified model is null.
See Also:
setModel(SVGModel)
Method Detail

setMode

public void setMode(byte mode)
Sets the mode in which the background should be painted.

By default the mode is PLAIN.

Parameters:
mode - one of
Throws:
IllegalArgumentException - if the specified mode does not equal one of the mode constants of this class.
See Also:
getMode()

getMode

public byte getMode()
Returns the mode in which the background should be painted.

By default the mode is PLAIN.

Returns:
one of
See Also:
setMode(byte)

setColor

public void setColor(Color color)
Sets the color used to paint the background.

By default the background color is white.

Parameters:
color - the color used to paint the background.
See Also:
getColor()

getColor

public Color getColor()
Returns the color used to paint the background.

By default the background color is white.

Returns:
the color used to paint the background.
See Also:
setColor(java.awt.Color)

setImageOrigin

public void setImageOrigin(YPoint origin)
Sets the origin (upper left corner) of the displayed background graphic. For mode DYNAMIC, the specified coordinates are interpreted as as world (graph) coordinates. For modes PLAIN and TILED, the specified coordinates are interpreted as view (component) coordinates. For all other modes image origin is ignored.

The default is (0,0).

Parameters:
origin - the upper left corner of the displayed background graphic. May not be null!
Throws:
IllegalArgumentException - if the specified point is null.
See Also:
getImageOrigin(), getMode(), setMode(byte)

getImageOrigin

public YPoint getImageOrigin()
Returns the image origin (upper left corner) of the displayed background graphic. For mode DYNAMIC, the specified coordinates are interpreted as as world (graph) coordinates. For modes PLAIN and TILED, the specified coordinates are interpreted as view (component) coordinates. For all other modes image origin is ignored.

The default is (0,0).

See Also:
setImageOrigin(YPoint), getMode(), setMode(byte)

getSVGURL

public URL getSVGURL()
Returns the URL of the SVG document that is displayed by this renderer.

Returns:
the URL of the SVG document that is displayed or null if background graphic has not been initialized from an URL.
See Also:
setSVGURL(java.net.URL), getModel()

setSVGURL

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

Parameters:
svgURL - the URL of the SVG document to display.
See Also:
getSVGURL()

getModel

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

See Also:
setModel(yext.svg.view.SVGModel)

setModel

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

Parameters:
model - the SVG graphics to display. May not be null!
Throws:
IllegalArgumentException - if the specified model is null.
See Also:
getModel()

paint

public void paint(Graphics2D gfx,
                  int x,
                  int y,
                  int w,
                  int h)
Paints the scalable vector graphics associated to this renderer upon the specified graphics instance.

This method assume that a GraphicsContext can be retrieved from the graphics instance it paints upon. The Graph2DView instance associated to said context has be the view whose background is painted.

Specified by:
paint in interface BackgroundRenderer
Parameters:
gfx - the graphics instance to paint upon.
See Also:
getMode(), YRenderingHints.getGraphicsContext(java.awt.Graphics2D)


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