|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jaxodraw.gui.grid.JaxoDefaultGrid
public class JaxoDefaultGrid
Paints a grid on the canvas.
Field Summary | |
---|---|
static int |
STYLE_CROSS
Cross style. |
static int |
STYLE_DOT
Dot style. |
static int |
STYLE_LINE
Line style. |
static int |
STYLE_LINE_HONEYCOMB
Honeycomb style. |
static int |
TYPE_HEXAGONAL
Hexagonal type. |
static int |
TYPE_RECTANGULAR
Rectangular type. |
Fields inherited from interface java.awt.Transparency |
---|
BITMASK, OPAQUE, TRANSLUCENT |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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 points. |
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 |
isSnapped(java.awt.Point p)
Determines if 'p' is on 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). |
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. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_RECTANGULAR
public static final int TYPE_HEXAGONAL
public static final int STYLE_DOT
public static final int STYLE_CROSS
public static final int STYLE_LINE
public static final int STYLE_LINE_HONEYCOMB
Constructor Detail |
---|
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.Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.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)
l
- The listener to add.public void removeChangeListener(javax.swing.event.ChangeListener l)
l
- The listener to remove.protected void fireStateChanged()
public boolean isSnapped(java.awt.Point p)
p.equals(snappedPoint(p))
.
isSnapped
in interface JaxoGrid
p
- The point to snap.
public final java.awt.Point snappedPoint(java.awt.Point p)
snappedPoint
in interface JaxoGrid
p
- The point to snap.
public final void snapPoint(java.awt.Point p)
snapPoint
in interface JaxoGrid
p
- The point to snap.public final int getTransparency()
getTransparency
in interface java.awt.Transparency
public final void paint(java.awt.Graphics2D g)
g
- The graphics context to paint the grid.public java.awt.Dimension getCanvasSize()
public void setCanvasSize(java.awt.Dimension value)
value
- The size to set.public final void setGridSize(int value)
value
- The gridSize to be set.public final int getGridSize()
public final void setGridType(int value)
value
- The gridtype to be set.public final int getGridType()
public final java.awt.Color getGridColor()
public void setGridColor(java.awt.Color value)
value
- 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()
public void setGridStyle(int value)
value
- The style to set.public static final JaxoDefaultGrid newDefaultGrid()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |