y.view
Class DefaultBackgroundRenderer

java.lang.Object
  |
  +--y.view.DefaultBackgroundRenderer
All Implemented Interfaces:
BackgroundRenderer
Direct Known Subclasses:
RadialBackgroundRenderer

public class DefaultBackgroundRenderer
extends 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 assiociated view
 
Constructor Summary
DefaultBackgroundRenderer(Graph2DView view)
          Create a new DefaultBackgroundRenderer for a given view.
 
Method Summary
 Color getColor()
          Returns the color used to paint the background.
 Image getImage()
          Returns the image that will be displayed in the background or null if there is no image.
 Point getImageOrigin()
          Returns thew image origin (upper left corner) of the image.
 URL getImageResource()
          Returns the current image resource, or null if none was specified.
 byte getMode()
          Returns the mode in which the background should be painted.
 void paint(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(Graphics2D gfx)
          Concatenates the world transform to the graphics context transform.
 void setColor(Color bgColor)
          Sets the color used to paint the background.
 void setGraph2DView(Graph2DView view)
          Sets the view for this renderer.
 void setImage(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(URL imageURL)
          Sets the image resource from which the background image should be loaded.
 void setMode(byte mode)
          Sets the mode in which the backgorund should be painted.
protected  void undoWorldTransform(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 assiociated view

Constructor Detail

DefaultBackgroundRenderer

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

Method Detail

getImageResource

public URL getImageResource()
Returns the current image resource, or null if none was specified.


setGraph2DView

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


setImageResource

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


setImage

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


getImage

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


setColor

public void setColor(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 partions of the background that are not occupied by the image are painted in that color. By default the background color is white.


getColor

public 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 Point getImageOrigin()
Returns thew image origin (upper left corner) of the image.


setMode

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

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

getMode

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


paint

public void paint(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(Graphics2D gfx)
Concatenates the inverse of the world transform to the graphics context transform


redoWorldTransform

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


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

2003