|
|||||||||
| Home >> All >> jpicedt >> graphic >> [ grid overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
jpicedt.graphic.grid
Class Grid

java.lang.Objectjpicedt.graphic.grid.Grid
- public class Grid
- extends java.lang.Object
A grid for PECanvas, defined in model-coordinate (natural unit = 1mm)
- Provides the ability to find a nearest-neighbour point on the grid, given a point in model-coordinate, using current snap-step value
- Offers several paint schemes (grid step)
- Since:
- PicEdt 1.0 ; completely refactored jpicedt 1.3.2
| Field Summary | |
private java.awt.BasicStroke |
axisLineStroke
|
static java.awt.Color |
colorDEFAULT
default colour used to paint grid lines |
static java.lang.String |
DASH
paint grid lines using dashed lines |
private float[] |
dashArray
draw crosses at grid points in gridStyleDash |
private float |
dashPhase
|
private java.awt.Color |
gridColor
colour used to paint grid lines |
private java.lang.String |
gridLineStyle
style used to paint grid lines |
private static float |
gridLineWidth
default stroke for grid lines |
private static double |
gridStep
distance b/w to consecutive grid lines |
private boolean |
isVisible
is grid visible ? |
static boolean |
isVisibleDEFAULT
default for visible state |
static java.lang.String |
KEY_GRID_COLOR
key used to fetch the grid colour from the Properties object |
static java.lang.String |
KEY_LINE_STYLE
key used to fetch the line style from the Properties object |
static java.lang.String |
KEY_SNAP_ON
key used to fetch the snap state from the Properties object |
static java.lang.String |
KEY_SNAP_STEP
key used to fetch the snap step from the Properties object |
static java.lang.String |
KEY_VISIBLE
key used to fetch the visible state from the Properties object |
private java.awt.geom.Line2D.Double |
line
cache used by the "paint" method |
private java.awt.BasicStroke |
lineStroke
|
static java.lang.String |
lineStyleDEFAULT
default style used to paint grid lines |
static java.lang.String[] |
PREDEFINED_SNAP_STEP_STRINGS
|
static double[] |
PREDEFINED_SNAP_STEPS
|
private double |
scale
cache for Graphics2D scale factor (used to compute BasicStroke, which is updated each time the zoom changes) this includes the zoom factor and the DPMM factor |
private boolean |
snapOn
is snapping active ? |
static boolean |
snapOnDEFAULT
is snapping active ? |
private double |
snapStep
current snap step |
static double |
snapStepDEFAULT
default snap step |
static java.lang.String |
SOLID
paint grid lines using solid lines |
| Constructor Summary | |
Grid()
Construct a new Grid with default values |
|
Grid(boolean isVisible,
boolean isSnapOn,
double snapStep,
java.awt.Color gridColor,
java.lang.String lineStyle)
Construct a new Grid |
|
Grid(java.util.Properties preferences)
Construct a new Grid from the given Properties, using the following key/value pairs : - key = KEY_VISIBLE, value = true/false - key = KEY_SNAP_ON, value = true/false - key = KEY_SNAP_STEP, value = a double - key = KEY_GRID_COLOR, value = integer (RGB) representation of the colour - key = KEY_LINE_STYLE, value = one of the predefined string (SOLID or DASH) |
|
| Method Summary | |
java.awt.Color |
getColor()
|
java.lang.String |
getLineStyle()
|
double |
getSnapStep()
|
static int |
getSnapStepIndex(double snapStep)
Utilities to retrieve an index from a given snapStep in PREDEFINED_SNAP_STEPS |
boolean |
isSnapOn()
|
boolean |
isVisible()
|
jpicedt.graphic.PicPoint |
nearestNeighbour(jpicedt.graphic.PicPoint srcPt,
jpicedt.graphic.PicPoint dstPt)
Compute the nearest-neighbour of the given src point on this grid, using the current snap-step value, and store the result in dst. |
void |
paint(java.awt.Graphics2D g,
java.awt.geom.Rectangle2D clip,
double scale)
paint this grid using a grid-step of "gridstep" mm to compute line-spacing. The graphic context is in user-coordinate, i.e. |
void |
setColor(java.awt.Color gridColor)
set the colour used to paint the grid |
void |
setLineStyle(java.lang.String lineStyle)
set the style used to paint grid lines |
void |
setSnapOn(boolean state)
sets whether snap is active or not |
void |
setSnapStep(double snapStep)
sets the snap-step to the given value |
void |
setVisible(boolean state)
set whether this grid is visible or not |
private void |
syncStroke(double scale)
synchronize current strokes with AffineTransform's scale factor when zoom's changed |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
PREDEFINED_SNAP_STEP_STRINGS
public static final java.lang.String[] PREDEFINED_SNAP_STEP_STRINGS
PREDEFINED_SNAP_STEPS
public static final double[] PREDEFINED_SNAP_STEPS
KEY_VISIBLE
public static final java.lang.String KEY_VISIBLE
- key used to fetch the visible state from the Properties object
- See Also:
- Constant Field Values
isVisible
private boolean isVisible
- is grid visible ?
isVisibleDEFAULT
public static final boolean isVisibleDEFAULT
- default for visible state
- See Also:
- Constant Field Values
gridStep
private static final double gridStep
- distance b/w to consecutive grid lines
- See Also:
- Constant Field Values
KEY_GRID_COLOR
public static final java.lang.String KEY_GRID_COLOR
- key used to fetch the grid colour from the Properties object
- See Also:
- Constant Field Values
gridColor
private java.awt.Color gridColor
- colour used to paint grid lines
colorDEFAULT
public static final java.awt.Color colorDEFAULT
- default colour used to paint grid lines
KEY_LINE_STYLE
public static final java.lang.String KEY_LINE_STYLE
- key used to fetch the line style from the Properties object
- See Also:
- Constant Field Values
SOLID
public static final java.lang.String SOLID
- paint grid lines using solid lines
- See Also:
- Constant Field Values
DASH
public static final java.lang.String DASH
- paint grid lines using dashed lines
- See Also:
- Constant Field Values
gridLineStyle
private java.lang.String gridLineStyle
- style used to paint grid lines
lineStyleDEFAULT
public static final java.lang.String lineStyleDEFAULT
- default style used to paint grid lines
- See Also:
- Constant Field Values
KEY_SNAP_ON
public static final java.lang.String KEY_SNAP_ON
- key used to fetch the snap state from the Properties object
- See Also:
- Constant Field Values
snapOn
private boolean snapOn
- is snapping active ?
snapOnDEFAULT
public static final boolean snapOnDEFAULT
- is snapping active ?
- See Also:
- Constant Field Values
KEY_SNAP_STEP
public static final java.lang.String KEY_SNAP_STEP
- key used to fetch the snap step from the Properties object
- See Also:
- Constant Field Values
snapStep
private double snapStep
- current snap step
snapStepDEFAULT
public static final double snapStepDEFAULT
- default snap step
- See Also:
- Constant Field Values
line
private java.awt.geom.Line2D.Double line
- cache used by the "paint" method
scale
private double scale
- cache for Graphics2D scale factor (used to compute BasicStroke, which is updated each time the zoom changes)
this includes the zoom factor and the DPMM factor
gridLineWidth
private static final float gridLineWidth
- default stroke for grid lines
- See Also:
- Constant Field Values
lineStroke
private java.awt.BasicStroke lineStroke
axisLineStroke
private java.awt.BasicStroke axisLineStroke
dashArray
private float[] dashArray
- draw crosses at grid points in gridStyleDash
dashPhase
private float dashPhase
| Constructor Detail |
Grid
public Grid()
- Construct a new Grid with default values
Grid
public Grid(boolean isVisible,
boolean isSnapOn,
double snapStep,
java.awt.Color gridColor,
java.lang.String lineStyle)
- Construct a new Grid
Grid
public Grid(java.util.Properties preferences)
- Construct a new Grid from the given Properties, using the following key/value pairs :
- key = KEY_VISIBLE, value = true/false
- key = KEY_SNAP_ON, value = true/false
- key = KEY_SNAP_STEP, value = a double
- key = KEY_GRID_COLOR, value = integer (RGB) representation of the colour
- key = KEY_LINE_STYLE, value = one of the predefined string (SOLID or DASH)
| Method Detail |
setColor
public void setColor(java.awt.Color gridColor)
- set the colour used to paint the grid
getColor
public java.awt.Color getColor()
setLineStyle
public void setLineStyle(java.lang.String lineStyle)
- set the style used to paint grid lines
getLineStyle
public java.lang.String getLineStyle()
setVisible
public void setVisible(boolean state)
- set whether this grid is visible or not
isVisible
public boolean isVisible()
setSnapOn
public void setSnapOn(boolean state)
- sets whether snap is active or not
isSnapOn
public boolean isSnapOn()
getSnapStep
public double getSnapStep()
setSnapStep
public void setSnapStep(double snapStep)
- sets the snap-step to the given value
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D clip, double scale)
- paint this grid using a grid-step of "gridstep" mm to compute line-spacing.
The graphic context is in user-coordinate, i.e. in model-coordinates (left to right, bottom to top, mm)
syncStroke
private void syncStroke(double scale)
- synchronize current strokes with AffineTransform's scale factor when zoom's changed
nearestNeighbour
public jpicedt.graphic.PicPoint nearestNeighbour(jpicedt.graphic.PicPoint srcPt, jpicedt.graphic.PicPoint dstPt)
- Compute the nearest-neighbour of the given src point on this grid, using the current snap-step value,
and store the result in dst.
If snap is turned off, simply returns pt.
If dst is null, a new PicPoint is allocated and the result is stored in this new point.
If src and dst are the same objects, the input point is correctly overwritten with the result.
getSnapStepIndex
public static int getSnapStepIndex(double snapStep)
- Utilities to retrieve an index from a given snapStep in PREDEFINED_SNAP_STEPS
|
|||||||||
| Home >> All >> jpicedt >> graphic >> [ grid overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
jpicedt.graphic.grid.Grid