Search this API

y.view
Class DefaultBackgroundRenderer

java.lang.Object
  extended by y.view.DefaultBackgroundRenderer
All Implemented Interfaces:
BackgroundRenderer
Direct Known Subclasses:
RadialBackgroundRenderer

public class DefaultBackgroundRenderer
extends java.lang.Object
implements BackgroundRenderer

Implements a background renderer that displays an image or a solid color as background of a Graph2DView.

 

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 TILED
          Mode constant.
protected  Graph2DView view
          The associated view
 
Constructor Summary
DefaultBackgroundRenderer(Graph2DView view)
          Creates a new DefaultBackgroundRenderer for a given view.
 
Method Summary
 java.awt.Color getColor()
          Returns the color used to paint the background.
 java.awt.Image getImage()
          Returns the image that will be displayed in the background or null if there is no image.
 java.awt.Point getImageOrigin()
          Returns the image origin (upper left corner) of the image.
 java.net.URL getImageResource()
          Returns the current image resource.
 byte getMode()
          Returns the mode in which the background should be painted.
 Graph2DView getView()
          Returns the view of this renderer.
 void paint(java.awt.Graphics2D gfx, int x, int y, int w, int h)
          Paints the background in the given rectangular area on the given graphics context.
protected  void redoWorldTransform(java.awt.Graphics2D gfx)
          Concatenates the world transform to the graphics context transform.
 void setColor(java.awt.Color bgColor)
          Sets the color used to paint the background.
 void setGraph2DView(Graph2DView view)
          Sets the view for this renderer.
 void setImage(java.awt.Image bgImage)
          Sets the image that will be displayed in the background.
 void setImageOrigin(double x, double y)
          Sets the origin (upper left corner) of the image.
 void setImageResource(java.net.URL imageURL)
          Sets the image resource from which the background image should be loaded.
 void setMode(byte mode)
          Sets the mode in which the background should be painted.
protected  void undoWorldTransform(java.awt.Graphics2D gfx)
          Concatenates the inverse of the world transform to the graphics context transform
 
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 image has always it's upper left corner in the views upper left corner and it's size is always scaled to the size of the view. The background is static, i.e. zooming or scrolling on the view have no effect on the background. Resizing the view though has a scaling effect on the background image.

See Also:
Constant Field Values

TILED

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

See Also:
Constant Field Values

BRICKED

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

See Also:
Constant Field Values

CENTERED

public static final byte CENTERED
Mode constant. When in this mode the background image 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 image. The background is static, i.e. zooming or scrolling on the view have no effect on the background.

See Also:
Constant Field Values

PLAIN

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

See Also:
Constant Field Values

DYNAMIC

public static final byte DYNAMIC
Mode constant. When in this mode the background image is considered part of the displayed contents and not as a view decoration. This means that an object that lies on a specific point of the image, will stay there even if zooming or scrolling is performed on the view. The specified background color is used to draw visible regions that lie outside the bounds of the background image.

See Also:
Constant Field Values

view

protected Graph2DView view
The associated view

Constructor Detail

DefaultBackgroundRenderer

public DefaultBackgroundRenderer(Graph2DView view)
Creates a new DefaultBackgroundRenderer for a given view.

Parameters:
view - the view for this renderer.
Method Detail

getImageResource

public java.net.URL getImageResource()
Returns the current image resource.

Returns:
the current image resource or null if none was specified.
See Also:
setImageResource(java.net.URL), setImage(java.awt.Image)

getView

public Graph2DView getView()
Returns the view of this renderer.

Returns:
the view of this renderer.

setGraph2DView

public void setGraph2DView(Graph2DView view)
Sets the view for this renderer.

Parameters:
view - the view for this renderer.

setImageResource

public void setImageResource(java.net.URL imageURL)
Sets the image resource from which the background image should be loaded.

Note: Invoking this method with a valid resource url will also set the image property.

Parameters:
imageURL - the URL identifying the background image that is used. May not be null.
Throws:
java.lang.NullPointerException - if the specified URL is null.
See Also:
getImageResource(), setImage(java.awt.Image), getImage()

setImage

public void setImage(java.awt.Image bgImage)
Sets the image that will be displayed in the background. By default, no image is associated with this renderer.

Note: Invoking this method will reset the imageResource property to null.

Parameters:
bgImage - the image that will be displayed in the background.
See Also:
getImage(), setImageResource(java.net.URL), getImageResource()

getImage

public java.awt.Image getImage()
Returns the image that will be displayed in the background or null if there is no image.

See Also:
setImage(java.awt.Image)

setColor

public void setColor(java.awt.Color bgColor)
Sets the color used to paint the background. If no image is associated with this renderer the whole background will be painted in that color. Otherwise portions of the background that are not occupied by the image are painted in that color. By default the background color is white.


getColor

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


setImageOrigin

public void setImageOrigin(double x,
                           double y)
Sets the origin (upper left corner) of the image. The default is (0,0)


getImageOrigin

public java.awt.Point getImageOrigin()
Returns the image origin (upper left corner) of the image.


setMode

public void setMode(byte mode)
Sets the mode in which the background should be painted. The mode can be one of the mode constants of this class. By default the mode is PLAIN

See Also:
FULLSCREEN, TILED, BRICKED, CENTERED, PLAIN, DYNAMIC

getMode

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


paint

public void paint(java.awt.Graphics2D gfx,
                  int x,
                  int y,
                  int w,
                  int h)
Paints the background in the given rectangular area on the given graphics context.

Specified by:
paint in interface BackgroundRenderer

undoWorldTransform

protected void undoWorldTransform(java.awt.Graphics2D gfx)
Concatenates the inverse of the world transform to the graphics context transform


redoWorldTransform

protected void redoWorldTransform(java.awt.Graphics2D gfx)
Concatenates the world transform to the graphics context transform.


© Copyright 2000-2018,
yWorks GmbH.
All rights reserved.