public class JaxoDefaultGrid extends java.lang.Object implements JaxoPaintableGrid, java.lang.Cloneable
STYLE_CROSS, STYLE_DOT, STYLE_LINE, STYLE_LINE_HONEYCOMB, TYPE_HEXAGONAL, TYPE_RECTANGULAR| Constructor and Description |
|---|
JaxoDefaultGrid(int gsize,
int gtype)
Constructor.
|
JaxoDefaultGrid(int gsize,
int gtype,
java.awt.Dimension canvasDim)
Constructor: Sets the dimension, type and value from
the arguments.
|
JaxoDefaultGrid(int gsize,
int gtype,
int gridStyle,
java.awt.Color color)
Constructor: Sets the dimension to the current screen size
and take the other argument values.
|
JaxoDefaultGrid(int gsize,
int gtype,
int gridStyle,
java.awt.Color color,
java.awt.Dimension canvasDim)
Constructor: Sets the dimension, type and value from
the arguments.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(javax.swing.event.ChangeListener l)
ChangeEvents will be fired everytime the actual image of
the grid changes (not on canvasSize changes).
|
java.lang.Object |
clone()
Standard clone with all properties at the same values.
|
void |
copyFrom(JaxoDefaultGrid g)
Copies all properties from the argument.
|
protected void |
fireStateChanged()
Notifies all listeners of a state change.
|
java.awt.Color |
getBackground()
Background of the grid (filling the whole canvas).
|
java.awt.Dimension |
getCanvasSize()
Size of the grid canvas.
|
java.awt.Color |
getGridColor()
Color of the grid.
|
int |
getGridSize()
Returns the current size of the grid.
|
int |
getGridStyle()
Grid style (STYLE_XYZ constant).
|
int |
getGridType()
Returns the type of the grid.
|
int |
getTransparency()
Base on the 'transparent' property and the 'background' and
'gridColor' properties, assuming SRC_OVER rule.
|
boolean |
isPainted()
Determine if this grid gets painted.
|
boolean |
isSnapped(java.awt.Point p)
Determines if 'p' is on the grid.
|
boolean |
isSnapping()
Check if points are currently snapped to the grid.
|
static JaxoDefaultGrid |
newDefaultGrid()
A new grid with the values from the preferences.
|
void |
paint(java.awt.Graphics2D g)
Paints the grid.
|
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a change listener.
|
void |
setBackground(java.awt.Color value)
Sets the grid background color.
|
void |
setCanvasSize(java.awt.Dimension value)
Sets the size of the grid canvas.
|
void |
setGridColor(java.awt.Color value)
Sets the color of the grid points.
|
void |
setGridSize(int value)
Sets the size of the grid to the given value.
|
void |
setGridStyle(int value)
Set style, and repaint.
|
void |
setGridType(int value)
Sets the type of the grid (TYPE_XYZ).
|
void |
setPainted(boolean painted)
Determine if this grid gets painted.
|
void |
setSnapping(boolean snapping)
Switch on/off the snapping of this grid.
|
java.awt.Point |
snappedPoint(java.awt.Point p)
Closest point to 'p' on the grid.
|
void |
snapPoint(java.awt.Point p)
Change 'p' to the closest point on the grid.
|
public JaxoDefaultGrid(int gsize,
int gtype)
gsize - The grid size to be set.gtype - The grid type to be set.public JaxoDefaultGrid(int gsize,
int gtype,
int gridStyle,
java.awt.Color color)
gsize - The grid size to be set.gtype - The grid type to be set.gridStyle - The grid style to be setcolor - The grid color to be setpublic JaxoDefaultGrid(int gsize,
int gtype,
java.awt.Dimension canvasDim)
gsize - The grid size to be set.gtype - The grid type to be set.canvasDim - The canvasSize.public JaxoDefaultGrid(int gsize,
int gtype,
int gridStyle,
java.awt.Color color,
java.awt.Dimension canvasDim)
gsize - The grid size to be set.gtype - The grid type to be set.gridStyle - The grid style to be set.color - The grid color to be set.canvasDim - The current canvas size.public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - If the object's class does
not support the Cloneable interface.public void copyFrom(JaxoDefaultGrid g)
g - The grid to take the properties from.public void addChangeListener(javax.swing.event.ChangeListener l)
addChangeListener in interface JaxoPaintableGridl - The listener to add.public void removeChangeListener(javax.swing.event.ChangeListener l)
removeChangeListener in interface JaxoPaintableGridl - The listener to remove.protected void fireStateChanged()
public boolean isSnapped(java.awt.Point p)
p.equals(snappedPoint(p)).public final java.awt.Point snappedPoint(java.awt.Point p)
snappedPoint in interface JaxoGridp - The point to snap.public final void snapPoint(java.awt.Point p)
public final int getTransparency()
getTransparency in interface java.awt.Transparencypublic final void paint(java.awt.Graphics2D g)
paint in interface JaxoPaintableGridg - The graphics context to paint the grid.public java.awt.Dimension getCanvasSize()
getCanvasSize in interface JaxoPaintableGridpublic void setCanvasSize(java.awt.Dimension value)
setCanvasSize in interface JaxoPaintableGridvalue - The size to set.public final void setGridSize(int value)
setGridSize in interface JaxoPaintableGridvalue - The grid size to be set.public final int getGridSize()
getGridSize in interface JaxoPaintableGridpublic final void setGridType(int value)
setGridType in interface JaxoPaintableGridvalue - The gridtype to be set.public final int getGridType()
getGridType in interface JaxoPaintableGridpublic final java.awt.Color getGridColor()
getGridColor in interface JaxoPaintableGridpublic void setGridColor(java.awt.Color value)
setGridColor in interface JaxoPaintableGridvalue - The color to set.public final java.awt.Color getBackground()
public void setBackground(java.awt.Color value)
value - The color to set.public final int getGridStyle()
getGridStyle in interface JaxoPaintableGridpublic void setGridStyle(int value)
setGridStyle in interface JaxoPaintableGridvalue - The style to set.public static final JaxoDefaultGrid newDefaultGrid()
public boolean isPainted()
isPainted in interface JaxoPaintableGridpublic void setPainted(boolean painted)
setPainted in interface JaxoPaintableGridpainted - true if this grid should get painted, false otherwise.public boolean isSnapping()
isSnapping in interface JaxoPaintableGridpublic void setSnapping(boolean snapping)
setSnapping in interface JaxoPaintableGridsnapping - true if this grid should snap points, false otherwise.Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.