Package diva.canvas.toolbox
Class GridLayer
- java.lang.Object
-
- diva.canvas.CanvasLayer
-
- 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:
- $Id$
- Author:
- Michael Shilman, John Reekie
-
-
Constructor Summary
Constructors Constructor Description GridLayer()Create a new GridLayer with a default one-pixel grid stroke and a light grey grid color.GridLayer(java.awt.Shape s, java.awt.Paint p)Create a new GridLayer with the given vertex shape and paint.GridLayer(java.awt.Stroke s, java.awt.Paint p)Create a new GridLayer with the given grid stroke and paint
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.PaintgetGridPaint()Get the grid line paint.java.awt.StrokegetGridStroke()Get the grid line stroke.java.awt.PaintgetVertexPaint()Get the vertex point paint.java.awt.ShapegetVertexShape()Get the vertex point shape.booleanisVisible()Test the visibility flag of this layer.voidpaint(java.awt.Graphics2D g)Paint this layer onto a 2D graphics object.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)Paint this layer onto a 2D graphics object, within the given region.voidsetGridPaint(java.awt.Paint p)Set the grid line paint.voidsetGridStroke(java.awt.Stroke s)Set the grid line stroke.voidsetVertexPaint(java.awt.Paint p)Set the vertex point paint.voidsetVertexShape(java.awt.Shape s)Set the vertex point shape.voidsetVisible(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(java.awt.Stroke s, java.awt.Paint p)Create a new GridLayer with the given grid stroke and paint
-
GridLayer
public GridLayer(java.awt.Shape s, java.awt.Paint p)Create a new GridLayer with the given vertex shape and paint. Grid lines will not be displayed.
-
-
Method Detail
-
getGridStroke
public java.awt.Stroke getGridStroke()
Get the grid line stroke.
-
getGridPaint
public java.awt.Paint getGridPaint()
Get the grid line paint.
-
getVertexShape
public java.awt.Shape getVertexShape()
Get the vertex point shape.
-
getVertexPaint
public java.awt.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:
isVisiblein interfaceVisibleComponent- Returns:
- true if the object is visible.
-
paint
public void paint(java.awt.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:
paintin interfaceVisibleComponent- Parameters:
g- The 2D graphics object that this object it to be painted upon.
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.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:
paintin interfaceVisibleComponent- Parameters:
g- The 2D graphics object that this object it to be painted upon.region- The region.
-
setGridStroke
public void setGridStroke(java.awt.Stroke s)
Set the grid line stroke.
-
setGridPaint
public void setGridPaint(java.awt.Paint p)
Set the grid line paint. If this is set to null, grid lines will not be displayed.
-
setVertexShape
public void setVertexShape(java.awt.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(java.awt.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:
setVisiblein interfaceVisibleComponent- Parameters:
flag- True if this object is to be visible.
-
-