ilog.views
Class IlvGrid

java.lang.Object
  extended by ilog.views.IlvGrid
All Implemented Interfaces:
Serializable

public class IlvGrid
extends Object
implements Serializable

The class 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.

See Also:
IlvManagerView.setGrid(ilog.views.IlvGrid), IlvManagerView.snapToGrid(ilog.views.IlvPoint), Serialized Form

Constructor Summary
IlvGrid()
          Creates a new grid.
IlvGrid(Color color, IlvPoint origin, float hspacing, float vspacing, boolean visible, boolean active)
          Creates a new grid.
 
Method Summary
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.
 float 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.
 float 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(float 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(float 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvGrid

public IlvGrid()
Creates a new grid. The origin of the grid is the point (0,0). The horizontal and vertical spacing are 10. The grid is active and visible.


IlvGrid

public IlvGrid(Color color,
               IlvPoint origin,
               float hspacing,
               float vspacing,
               boolean visible,
               boolean active)
Creates a new grid.

Parameters:
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.
See Also:
IlvManagerView.setGrid(ilog.views.IlvGrid)
Method Detail

setVisible

public final void setVisible(boolean visible)
Changes the visibility state of the grid.

Parameters:
visible - if true the grid becomes visible, otherwise invisible.

isVisible

public final boolean isVisible()
Sets the grid as visible or invisible.

Returns:
true if the grid is visible, false otherwise.

setActive

public final void setActive(boolean active)
Sets the grid as active or inactive.

Parameters:
active - if true the grid becomes active, otherwise inactive.

isActive

public final boolean isActive()
Indicates whether the grid is active.

Returns:
true if the grid is active, false otherwise.

setColor

public final void setColor(Color color)
Changes the color of the grid.

Parameters:
color - the new color used to draw the points.

getColor

public final Color getColor()
Returns the color of the grid.

Returns:
the color used to draw the points.

setOrigin

public void setOrigin(IlvPoint p)
Changes the origin of the grid.

Parameters:
p - the new origin.

getOrigin

public IlvPoint getOrigin()
Returns the origin point of the grid.


setHorizontalSpacing

public final void setHorizontalSpacing(float spacing)
Changes the spacing of grid points on the horizontal axis.

Parameters:
spacing - the new spacing. Negative values are illegal.

getHorizontalSpacing

public final float getHorizontalSpacing()
Returns the spacing of grid points on the horizontal axis.


setVerticalSpacing

public final void setVerticalSpacing(float spacing)
Changes the spacing of grid points on the vertical axis.

Parameters:
spacing - the new spacing. Negative values are illegal.

getVerticalSpacing

public final float getVerticalSpacing()
Returns the spacing of grid points on the vertical axis.


setHorizontalShown

public final void setHorizontalShown(int shown)
Changes how often grid points are displayed on the horizontal axis. A value of 1 means that every point is displayed, 2 means that one out of two points is displayed and so on. The parameter shown must be positive.


getHorizontalShown

public final int getHorizontalShown()
Returns how often grid points are displayed on the horizontal axis. A value of 1 means that every point is displayed, 2 means that one out of two points is displayed and so on.


setVerticalShown

public final void setVerticalShown(int shown)
Changes how often grid points are displayed on the vertical axis. A value of 1 means that every point is displayed, 2 means that one out of two points is displayed and so on. The parameter shown must be positive.


getVerticalShown

public final int getVerticalShown()
Returns how often grid points are displayed on the vertical axis. A value of 1 means that every point is displayed, 2 means that one out of two points is displayed and so on.


snap

protected void snap(IlvPoint p)
Moves the specified point to a valid location on the grid. This method is called by the 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.

Parameters:
p - the point to snap.
See Also:
IlvManagerView.snapToGrid(ilog.views.IlvPoint)

draw

protected void draw(Graphics dst,
                    IlvTransformer t,
                    Rectangle rect)
Draws the grid. This method is called by the view (IlvManagerView) to draw the grid. It can be overridden to display another kind of grid.

Parameters:
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 © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.