public class IlvGrid extends Object implements Serializable
IlvGrid
implements a snap grid. A snap grid is
a grid composed of grid points that have magnetic properties. When a user
moves an object, this object snaps to one of the points that make up
the grid. The view and object interactors of JViews use the snap grid to
position objects. You can set up a snap grid on each view of a manager.
A grid can be made visible or invisible, active or not active. You can
redefine the appearance of the grid. In the default implementation,
the grid is rectangular. Its origin and its vertical and horizontal
spacing can be set.Constructor and Description |
---|
IlvGrid()
Creates a new grid.
|
IlvGrid(Color color,
IlvPoint origin,
double hspacing,
double vspacing,
boolean visible,
boolean active)
Creates a new grid.
|
Modifier and Type | Method and Description |
---|---|
protected void |
draw(Graphics dst,
IlvTransformer t,
Rectangle rect)
Draws the grid.
|
Color |
getColor()
Returns the color of the grid.
|
int |
getHorizontalShown()
Returns how often grid points are displayed on the horizontal axis.
|
double |
getHorizontalSpacing()
Returns the spacing of grid points on the horizontal axis.
|
IlvPoint |
getOrigin()
Returns the origin point of the grid.
|
int |
getVerticalShown()
Returns how often grid points are displayed on the vertical axis.
|
double |
getVerticalSpacing()
Returns the spacing of grid points on the vertical axis.
|
boolean |
isActive()
Indicates whether the grid is active.
|
boolean |
isVisible()
Sets the grid as visible or invisible.
|
void |
setActive(boolean active)
Sets the grid as active or inactive.
|
void |
setColor(Color color)
Changes the color of the grid.
|
void |
setHorizontalShown(int shown)
Changes how often grid points are displayed on the horizontal axis.
|
void |
setHorizontalSpacing(double spacing)
Changes the spacing of grid points on the horizontal axis.
|
void |
setOrigin(IlvPoint p)
Changes the origin of the grid.
|
void |
setVerticalShown(int shown)
Changes how often grid points are displayed on the vertical axis.
|
void |
setVerticalSpacing(double spacing)
Changes the spacing of grid points on the vertical axis.
|
void |
setVisible(boolean visible)
Changes the visibility state of the grid.
|
protected void |
snap(IlvPoint p)
Moves the specified point to a valid location on the grid.
|
public IlvGrid()
public IlvGrid(Color color, IlvPoint origin, double hspacing, double vspacing, boolean visible, boolean active)
color
- the color of the grid points.origin
- the coordinates of the upper-left corner of the grid in the
manager coordinates system.hspacing
- spacing of grid points along the horizontal axis.vspacing
- spacing of grid points along the vertical axis.visible
- Specifies whether the grid is visible (true
) of invisible.active
- Specifies whether the grid is active (true
) of inactive.IlvManagerView.setGrid(ilog.views.IlvGrid)
public final void setVisible(boolean visible)
visible
- if true the grid becomes visible, otherwise invisible.public final boolean isVisible()
public final void setActive(boolean active)
active
- if true the grid becomes active, otherwise inactive.public final boolean isActive()
public final void setColor(Color color)
color
- the new color used to draw the points.public final Color getColor()
public void setOrigin(IlvPoint p)
p
- the new origin.public IlvPoint getOrigin()
public final void setHorizontalSpacing(double spacing)
spacing
- the new spacing. Negative values are illegal.public final double getHorizontalSpacing()
public final void setVerticalSpacing(double spacing)
spacing
- the new spacing. Negative values are illegal.public final double getVerticalSpacing()
public final void setHorizontalShown(int shown)
shown
must be positive.public final int getHorizontalShown()
public final void setVerticalShown(int shown)
shown
must be positive.public final int getVerticalShown()
protected void snap(IlvPoint p)
IlvManagerView.snapToGrid
method to move the point p
to a valid location on the grid.
The default implementation moves the point to the closest grid point if
the grid is active. The method can be overridden to implement a different
behavior.p
- the point to snap.IlvManagerView.snapToGrid(ilog.views.IlvPoint)
protected void draw(Graphics dst, IlvTransformer t, Rectangle rect)
IlvManagerView
)
to draw the grid. It can be overridden to display another kind of grid.dst
- the Graphics object to perform the drawing of the grid.t
- the transformer used to draw to grid.rect
- The area where the grid will be drawn. Note that the
grid is drawn only at the intersection of this area with the clipping
area provided in the dst
parameter.
When the grid is used in an IlvManagerView
, this
parameter is the bounding rectangle of the view.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.