diva.canvas.toolbox
Class GridLayer

java.lang.Object
  extended by diva.canvas.CanvasLayer
      extended by diva.canvas.toolbox.GridLayer
All Implemented Interfaces:
CanvasComponent, VisibleComponent

public class GridLayer
extends CanvasLayer
implements VisibleComponent

A grid layer displays a rectangular grid. It can be made to display grid lines, grid vertices, or both. For grid lines, the stroke and the paint can be specified; for grid vertices, the shape drawn at the vertex and the paint can be specified. Reasonable default are also supplied.

Version:
$Revision: 1.3 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu), John Reekie (johnr@eecs.berkeley.edu)

Constructor Summary
GridLayer()
          Create a new GridLayer with a default one-pixel grid stroke and a light grey grid color.
GridLayer(Shape s, Paint p)
          Create a new GridLayer with the given vertex shape and paint.
GridLayer(Stroke s, Paint p)
          Create a new GridLayer with the given grid stroke and paint
 
Method Summary
 Paint getGridPaint()
          Get the grid line paint.
 Stroke getGridStroke()
          Get the grid line stroke.
 Paint getVertexPaint()
          Get the vertex point paint.
 Shape getVertexShape()
          Get the vertex point shape.
 boolean isVisible()
          Test the visibility flag of this layer.
 void paint(Graphics2D g)
          Paint this layer onto a 2D graphics object.
 void paint(Graphics2D g, Rectangle2D region)
          Paint this layer onto a 2D graphics object, within the given region.
 void setGridPaint(Paint p)
          Set the grid line paint.
 void setGridStroke(Stroke s)
          Set the grid line stroke.
 void setVertexPaint(Paint p)
          Set the vertex point paint.
 void setVertexShape(Shape s)
          Set the vertex point shape.
 void setVisible(boolean flag)
          Set the visibility flag of this layer.
 
Methods inherited from class diva.canvas.CanvasLayer
getCanvasPane, getLayerBounds, getParent, getToolTipText, getTransformContext, repaint, repaint, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext, repaint, repaint
 

Constructor Detail

GridLayer

public GridLayer()
Create a new GridLayer with a default one-pixel grid stroke and a light grey grid color.


GridLayer

public GridLayer(Stroke s,
                 Paint p)
Create a new GridLayer with the given grid stroke and paint


GridLayer

public GridLayer(Shape s,
                 Paint p)
Create a new GridLayer with the given vertex shape and paint. Grid lines will not be displayed.

Method Detail

getGridStroke

public Stroke getGridStroke()
Get the grid line stroke.


getGridPaint

public Paint getGridPaint()
Get the grid line paint.


getVertexShape

public Shape getVertexShape()
Get the vertex point shape.


getVertexPaint

public Paint getVertexPaint()
Get the vertex point paint.


isVisible

public boolean isVisible()
Test the visibility flag of this layer. Note that this flag does not indicate whether the layer is actually visible on the screen, as its pane or one if its ancestors may not be visible.

Specified by:
isVisible in interface VisibleComponent

paint

public void paint(Graphics2D g)
Paint this layer onto a 2D graphics object. If the layer is not visible, return immediately. Otherwise paint the grid lines if they have a non-null paint, and paint the grid vertices if they have a non-null paint.

FIXME: Vertexes are not yet supported.

Specified by:
paint in interface VisibleComponent

paint

public void paint(Graphics2D g,
                  Rectangle2D region)
Paint this layer onto a 2D graphics object, within the given region. If the layer is not visible, return immediately. Otherwise paint the grid lines if they have a non-null paint, and paint the grid vertices if they have a non-null paint.

Specified by:
paint in interface VisibleComponent

setGridStroke

public void setGridStroke(Stroke s)
Set the grid line stroke.


setGridPaint

public void setGridPaint(Paint p)
Set the grid line paint. If this is set to null, grid lines will not be displayed.


setVertexShape

public void setVertexShape(Shape s)
Set the vertex point shape. The default is a circle with radius equal to 10% of the smallest grid size in either dimension.


setVertexPaint

public void setVertexPaint(Paint p)
Set the vertex point paint. If this is set to null, vertices will not be displayed.


setVisible

public void setVisible(boolean flag)
Set the visibility flag of this layer. If the flag is false, then the layer will not be drawn on the screen.

Specified by:
setVisible in interface VisibleComponent


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.