public class Grid
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
colorDEFAULT
default colour used to paint grid lines
|
static java.lang.String |
DASH
paint grid lines using dashed lines
|
static double |
gridStepDEFAULT |
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_GRID_STEP
key used to fetch the grid step 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
|
static java.lang.String |
lineStyleDEFAULT
default style used to paint grid lines
|
static java.lang.String[] |
PREDEFINED_GRID_STEP_STRINGS |
static double[] |
PREDEFINED_GRID_STEPS |
static java.lang.String[] |
PREDEFINED_SNAP_STEP_STRINGS |
static double[] |
PREDEFINED_SNAP_STEPS |
static java.lang.String[] |
PREDEFINED_STYLES |
static boolean |
snapOnDEFAULT
is snapping active ?
|
static double |
snapStepDEFAULT
default snap step
|
static java.lang.String |
SOLID
paint grid lines using solid lines
|
Constructor and Description |
---|
Grid()
Construct a new Grid with default values
|
Grid(boolean isVisible,
boolean isSnapOn,
double snapStep,
double gridStep,
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)
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getColor() |
double |
getGridStep() |
static int |
getGridStepIndex(double gridStep)
Utilities to retrieve an index from a given gridStep in PREDEFINED_SNAP_STEPS
|
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() |
PicPoint |
nearestNeighbour(PicPoint srcPt,
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 |
setGridStep(double gridStep)
sets the grid (display)-step to the given value
|
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
|
public static final java.lang.String[] PREDEFINED_SNAP_STEP_STRINGS
public static final double[] PREDEFINED_SNAP_STEPS
public static final java.lang.String[] PREDEFINED_GRID_STEP_STRINGS
public static final double[] PREDEFINED_GRID_STEPS
public static final java.lang.String KEY_VISIBLE
public static final boolean isVisibleDEFAULT
public static final java.lang.String KEY_GRID_STEP
public static final double gridStepDEFAULT
public static final java.lang.String KEY_GRID_COLOR
public static final java.awt.Color colorDEFAULT
public static final java.lang.String KEY_LINE_STYLE
public static final java.lang.String SOLID
public static final java.lang.String DASH
public static final java.lang.String lineStyleDEFAULT
public static final java.lang.String[] PREDEFINED_STYLES
public static final java.lang.String KEY_SNAP_ON
public static final boolean snapOnDEFAULT
public static final java.lang.String KEY_SNAP_STEP
public static final double snapStepDEFAULT
public Grid()
public Grid(boolean isVisible, boolean isSnapOn, double snapStep, double gridStep, java.awt.Color gridColor, java.lang.String lineStyle)
isVisible
- whether the grid has to be displayed or notisSnapOn
- whether the snap behaviour is active or notsnapStep
- step used to compute the nearest-neighbour of a click pointgridStep
- distance b/w grid lines in mmgridColor
- the grid colourlineStyle
- SOLID or DASH (tells what style to apply to grid lines)public Grid(java.util.Properties preferences)
isVisible
- whether the grid has to be displayed or notisSnapOn
- whether the snap behaviour is active or notsnapStep
- step used to compute the nearest-neighbour of a click pointgridColor
- the grid colourlineStyle
- SOLID or DASH (tells what style to apply to grid lines)public void setColor(java.awt.Color gridColor)
public java.awt.Color getColor()
public void setLineStyle(java.lang.String lineStyle)
SOLID
- or DASHpublic java.lang.String getLineStyle()
public void setVisible(boolean state)
public boolean isVisible()
public void setSnapOn(boolean state)
public boolean isSnapOn()
public double getSnapStep()
public void setSnapStep(double snapStep)
public double getGridStep()
public void setGridStep(double gridStep)
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D clip, double scale)
sclae
- the current scale factor, used to scale down line thickness so that lines are displayed
with a constant thickness, whatever AffineTransform is currently set to the graphic context.public PicPoint nearestNeighbour(PicPoint srcPt, PicPoint dstPt)
ptSrc
- the source point in model-coordinates.ptDst
- a point that stores the resultpublic static int getSnapStepIndex(double snapStep)
public static int getGridStepIndex(double gridStep)
Submit a bug : syd@jpicedt.org