ilog.views.graphic
Class IlvLine

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvLine
All Implemented Interfaces:
IlvPolyPointsInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvArrowLine

public class IlvLine
extends IlvGraphic
implements IlvPolyPointsInterface

IlvLine represents a custom graphic object that shows a straight line between two given points.

The default values for an IlvLine instance are as follows:

Example

The following code example shows how to use an IlvLine in a simple Java application:

   IlvManager manager = new IlvManager();
   IlvLine myLine = new IlvLine(20,20,200,150);
   myLine.setForeground(Color.green);
   myLine.setLineWidth(7);
   manager.addObject(myLine, true);
 

The following image shows the graphic object created in the code example:

IlvLine

About Graphic Objects

IlvLine is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an IlvManager instance and displayed using one or more IlvManagerView instances in a Java Swing application. For information about generic features for graphic objects, see IlvGraphic.

See Also:
IlvPoint, IlvManager, IlvManagerView, Serialized Form

Constructor Summary
IlvLine()
          Creates a new line starting at (0, 0) and ending at (100, 100).
IlvLine(float fromx, float fromy, float tox, float toy)
          Creates a new line starting at fromx, fromy and ending at tox, toy.
IlvLine(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvLine(IlvLine source)
          Creates a new line by copying an existing one.
IlvLine(IlvPoint fromPoint, IlvPoint toPoint)
          Creates a new line starting at fromPoint and ending at toPoint.
 
Method Summary
 boolean allowsPointInsertion()
          Returns true if the interactors are allowed to add points, and false otherwise.
 boolean allowsPointMove(int index)
          Returns true if the interactors are allowed to move the point with the specified index, and false otherwise.
 boolean allowsPointRemoval()
          Returns true if the interactors are allowed to remove points, and false otherwise.
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
protected  void finalize()
          Overrides the method to clean some resources.
 int getEndCap()
          Returns the decoration applied at the end of the polyline.
 Color getForeground()
          Returns the color of the line.
 IlvPoint getFrom()
          Returns the origin point of the line.
 float[] getLineStyle()
          Returns the array representing the lengths of the dash segments.
 float getLineWidth()
          Returns the line width of the object.
 float getLineWidth(IlvTransformer t)
          Returns the line width that is actually displayed when the object is drawn with the specified transformer.
 float getMaximumLineWidth()
          Returns the maximum line width of the line.
 IlvPoint getPointAt(int index, IlvTransformer t)
          Returns a point of the line transformed with the specified transformer.
 int getPointsCardinal()
          Returns the number of points (that is, 2).
 IlvPoint getTo()
          Returns the destination point of the line.
 void insertPoint(int index, float x, float y, IlvTransformer t)
          The insertion of a point is not allowed in IlvLine.
 IlvSelection makeSelection()
          Creates a selection object for this object.
 void movePoint(int index, float x, float y, IlvTransformer t)
          Changes the position of a point.
 boolean pointsInBBox()
          Returns true because all points of the line are contained in the bounding box.
 void removePoint(int index, IlvTransformer t)
          The removal of a point is not allowed in IlvLine.
 void setEndCap(int endCap)
          Changes the decoration applied at the end of the polyline.
 void setForeground(Color color)
          Changes the color of the line.
 void setFrom(IlvPoint p)
          Changes the origin point of the line.
 void setLineStyle(float[] lineStyle)
          Changes the array representing the lengths of the dash segments.
 void setLineWidth(float lineWidth)
          Changes the line width of the object.
 void setMaximumLineWidth(float maximumLineWidth)
          Changes the maximum line width of the line.
 void setTo(IlvPoint p)
          Changes the destination point of the line.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isPersistent, isSelectable, isVisible, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvLine

public IlvLine()
Creates a new line starting at (0, 0) and ending at (100, 100).

Since:
JViews 6.0
See Also:
IlvLine(float, float, float, float)

IlvLine

public IlvLine(IlvPoint fromPoint,
               IlvPoint toPoint)
Creates a new line starting at fromPoint and ending at toPoint.

Parameters:
fromPoint - The starting point.
toPoint - The ending point.
Since:
JViews 8.0

IlvLine

public IlvLine(float fromx,
               float fromy,
               float tox,
               float toy)
Creates a new line starting at fromx, fromy and ending at tox, toy.

Parameters:
fromx - The starting x-coordinate.
fromy - The starting y-coordinate.
tox - The ending x-coordinate.
toy - The ending y-coordinate.

IlvLine

public IlvLine(IlvLine source)
Creates a new line by copying an existing one.

Parameters:
source - The source line to be copied.

IlvLine

public IlvLine(IlvInputStream stream)
        throws IlvReadFileException
Reads the object from an IlvInputStream.

Parameters:
stream - The input stream.
Throws:
IlvReadFileException - if the format is not correct.
Method Detail

copy

public IlvGraphic copy()
Copies the object. This method copies the object by calling the copy constructor.

Specified by:
copy in class IlvGraphic
Returns:
A copy of the object.
See Also:
IlvGraphic

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests if a point lies within the outline of the object.

Overrides:
contains in class IlvGraphic
Parameters:
p - The point to be tested.
tp - The point p transformed by the transformer t.
t - The transformation that was applied to the object when it was drawn.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the object.

Specified by:
draw in class IlvGraphic
Parameters:
dst - The destination Graphics.
t - The transformation used to draw the object.
See Also:
IlvGraphic.boundingBox(ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

pointsInBBox

public boolean pointsInBBox()
Returns true because all points of the line are contained in the bounding box.

Specified by:
pointsInBBox in interface IlvPolyPointsInterface

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.

Specified by:
boundingBox in interface IlvPolyPointsInterface
Specified by:
boundingBox in class IlvGraphic
Parameters:
t - The transformer used to draw the object.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.

Specified by:
applyTransform in class IlvGraphic
Parameters:
t - The transformer to be applied.
See Also:
IlvGraphic

getFrom

public IlvPoint getFrom()
Returns the origin point of the line.


getTo

public IlvPoint getTo()
Returns the destination point of the line.


setTo

public void setTo(IlvPoint p)
Changes the destination point of the line.

Parameters:
p - The new destination point.

setFrom

public void setFrom(IlvPoint p)
Changes the origin point of the line.

Parameters:
p - The new origin point.

getLineWidth

public float getLineWidth()
Returns the line width of the object. The default value is 0.


setLineWidth

public void setLineWidth(float lineWidth)
Changes the line width of the object.

Parameters:
lineWidth - The new line width.

getLineWidth

public float getLineWidth(IlvTransformer t)
Returns the line width that is actually displayed when the object is drawn with the specified transformer.

Parameters:
t - The transformer used to draw the object.

getEndCap

public int getEndCap()
Returns the decoration applied at the end of the polyline. The values are defined in the class IlvStroke. The default value is CAP_SQUARE.

See Also:
IlvStroke

setEndCap

public void setEndCap(int endCap)
Changes the decoration applied at the end of the polyline.

Parameters:
endCap - The new decoration style. The values are defined in the class IlvStroke. The default value is CAP_SQUARE.
See Also:
IlvStroke

getMaximumLineWidth

public float getMaximumLineWidth()
Returns the maximum line width of the line. If the maximum line width is specified and not equal to zero, the width of the line will stop zooming when the maximum line width is reached. The default value is zero (no limit).


setMaximumLineWidth

public void setMaximumLineWidth(float maximumLineWidth)
Changes the maximum line width of the line. If the maximum line width is specified and not equal to zero, then the width of the line will stop zooming when the maximum line width is reached. A value of zero means that there is no limit.

Parameters:
maximumLineWidth - The new maximum line width.

getLineStyle

public float[] getLineStyle()
Returns the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.


setLineStyle

public void setLineStyle(float[] lineStyle)
Changes the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.

Parameters:
lineStyle - The new line style.

setForeground

public void setForeground(Color color)
Changes the color of the line.

Overrides:
setForeground in class IlvGraphic
Parameters:
color - The new color.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

getForeground

public Color getForeground()
Returns the color of the line.

Returns:
The color of the object.

getPointAt

public IlvPoint getPointAt(int index,
                           IlvTransformer t)
Returns a point of the line transformed with the specified transformer.

Specified by:
getPointAt in interface IlvPolyPointsInterface
Parameters:
index - Should be 0 or 1.
t - The transformer.

getPointsCardinal

public int getPointsCardinal()
Returns the number of points (that is, 2).

Specified by:
getPointsCardinal in interface IlvPolyPointsInterface

movePoint

public void movePoint(int index,
                      float x,
                      float y,
                      IlvTransformer t)
Changes the position of a point.

Specified by:
movePoint in interface IlvPolyPointsInterface
Parameters:
index - The index of the point.
x - The new x-coordinate of the point.
y - The new y-coordinate of the point.
t - The transformation to be applied.
See Also:
allowsPointMove(int)

allowsPointInsertion

public final boolean allowsPointInsertion()
Returns true if the interactors are allowed to add points, and false otherwise.

The default implementation always returns true.

Specified by:
allowsPointInsertion in interface IlvPolyPointsInterface

allowsPointRemoval

public final boolean allowsPointRemoval()
Returns true if the interactors are allowed to remove points, and false otherwise.

The default implementation always returns true.

Specified by:
allowsPointRemoval in interface IlvPolyPointsInterface

allowsPointMove

public boolean allowsPointMove(int index)
Returns true if the interactors are allowed to move the point with the specified index, and false otherwise.

The default implementation always returns true.

Specified by:
allowsPointMove in interface IlvPolyPointsInterface
Parameters:
index - The index of the point.
Since:
JViews 5.0

insertPoint

public final void insertPoint(int index,
                              float x,
                              float y,
                              IlvTransformer t)
The insertion of a point is not allowed in IlvLine. Therefore, this method has an empty implementation, and should not be called.

Specified by:
insertPoint in interface IlvPolyPointsInterface
Parameters:
index - The index at which the new point will be inserted.
x - The x coordinate of the new point.
y - The y coordinate of the new point.
t - The transformer used to draw the polypoint.

removePoint

public final void removePoint(int index,
                              IlvTransformer t)
The removal of a point is not allowed in IlvLine. Therefore, this method has an empty implementation, and should not be called.

Specified by:
removePoint in interface IlvPolyPointsInterface
Parameters:
index - The index of the point to remove.
t - The transformer used to draw the polypoint.

makeSelection

public IlvSelection makeSelection()
Creates a selection object for this object. The default implementation creates an instance of IlvPolyPointsSelection.

Overrides:
makeSelection in class IlvGraphic
See Also:
IlvDrawSelection

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. You should not call this method directly; instead, you should use the write methods of the manager.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvGraphic
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

finalize

protected void finalize()
                 throws Throwable
Overrides the method to clean some resources.

Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.