|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.graphic.grid.Grid
public class Grid
A grid for PECanvas, defined in model-coordinate (natural unit = 1mm)
Field Summary | |
---|---|
static Color |
colorDEFAULT
default colour used to paint grid lines |
static String |
DASH
paint grid lines using dashed lines |
static double |
gridStepDEFAULT
|
static boolean |
isVisibleDEFAULT
default for visible state |
static String |
KEY_GRID_COLOR
key used to fetch the grid colour from the Properties object |
static String |
KEY_GRID_STEP
key used to fetch the grid step from the Properties object |
static String |
KEY_LINE_STYLE
key used to fetch the line style from the Properties object |
static String |
KEY_SNAP_ON
key used to fetch the snap state from the Properties object |
static String |
KEY_SNAP_STEP
key used to fetch the snap step from the Properties object |
static String |
KEY_VISIBLE
key used to fetch the visible state from the Properties object |
static String |
lineStyleDEFAULT
default style used to paint grid lines |
static String[] |
PREDEFINED_GRID_STEP_STRINGS
|
static double[] |
PREDEFINED_GRID_STEPS
|
static String[] |
PREDEFINED_SNAP_STEP_STRINGS
|
static double[] |
PREDEFINED_SNAP_STEPS
|
static String[] |
PREDEFINED_STYLES
|
static boolean |
snapOnDEFAULT
is snapping active ? |
static double |
snapStepDEFAULT
default snap step |
static 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,
double gridStep,
Color gridColor,
String lineStyle)
Construct a new Grid |
|
Grid(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 | |
---|---|
Color |
getColor()
|
double |
getGridStep()
|
static int |
getGridStepIndex(double gridStep)
Utilities to retrieve an index from a given gridStep in PREDEFINED_SNAP_STEPS |
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 srcPt point on this grid, using the current snap-step value, and store the result in dstPt. |
void |
paint(Graphics2D g,
Rectangle2D clip,
double scale)
paint this grid using a grid-step of "gridstep" mm to compute line-spacing. |
void |
setColor(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(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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] PREDEFINED_SNAP_STEP_STRINGS
public static final double[] PREDEFINED_SNAP_STEPS
public static final String[] PREDEFINED_GRID_STEP_STRINGS
public static final double[] PREDEFINED_GRID_STEPS
public static final String KEY_VISIBLE
public static final boolean isVisibleDEFAULT
public static final String KEY_GRID_STEP
public static final double gridStepDEFAULT
public static final String KEY_GRID_COLOR
public static final Color colorDEFAULT
public static final String KEY_LINE_STYLE
public static final String SOLID
public static final String DASH
public static final String lineStyleDEFAULT
public static final String[] PREDEFINED_STYLES
public static final String KEY_SNAP_ON
public static final boolean snapOnDEFAULT
public static final String KEY_SNAP_STEP
public static final double snapStepDEFAULT
Constructor Detail |
---|
public Grid()
public Grid(boolean isVisible, boolean isSnapOn, double snapStep, double gridStep, Color gridColor, 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(Properties preferences)
KEY_VISIBLE
, value = true/falseKEY_SNAP_ON
, value = true/falseKEY_SNAP_STEP
, value = a doubleKEY_GRID_COLOR
, value = integer (RGB) representation of the colourKEY_LINE_STYLE
, value = one of the predefined string (SOLID or DASH)
preferences
- Property holding the following information:
KEY_VISIBLE
whether the grid has to be displayed or notKEY_SNAP_ON
whether the snap behaviour is active or notKEY_SNAP_STEP
step used to compute the nearest-neighbour of a click pointKEY_GRID_COLOR
the grid colourKEY_LINE_STYLE
SOLID or DASH (tells what style to apply to grid lines)Method Detail |
---|
public void setColor(Color gridColor)
public Color getColor()
public void setLineStyle(String lineStyle)
lineStyle
- SOLID or DASHpublic 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(Graphics2D g, Rectangle2D clip, double scale)
scale
- 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)
srcPt
- the source point in model-coordinates.dstPt
- a point that stores the result
public static int getSnapStepIndex(double snapStep)
public static int getGridStepIndex(double gridStep)
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |