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:
Color.black
0
0
100
100
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
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.
IlvPoint
,
IlvManager
,
IlvManagerView
,
Serialized FormConstructor and Description |
---|
IlvLine()
Creates a new line starting at
(0, 0) and ending
at (100, 100) . |
IlvLine(double fromx,
double fromy,
double tox,
double 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 . |
Modifier and Type | Method and Description |
---|---|
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.
|
double |
getLineWidth()
Returns the line width of the object.
|
double |
getLineWidth(IlvTransformer t)
Returns the line width that is
actually displayed when the object is drawn
with the specified transformer.
|
double |
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,
double x,
double 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,
double x,
double 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(double lineWidth)
Changes the line width of the object.
|
void |
setMaximumLineWidth(double 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 . |
addActionListener, addNamedPropertyListener, allViewsRemoved, baseTextDirectionChanged, blinkingStateOn, boundingBox, callDraw, componentOrientationChanged, getAndAssociateObjectInteractor, getBaseTextDirection, getBlinkingAction, getBlinkingObjectOwner, getBlinkingOffPeriod, getBlinkingOnPeriod, getCenter, getComponentOrientation, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getLocale, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getResolvedBaseTextDirection, getToolTipBaseTextDirection, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, getULocale, getZOrderIndex, hasProperty, inside, intersects, invalidateBBoxCache, invalidateBidiCache, isBaseTextDirectionSensitive, isComponentOrientationSensitive, isDataFlavorSupported, isEditable, isInApplyToObject, isLocaleSensitive, isMovable, isPersistent, isSelectable, isVisible, localeChanged, move, move, moveResize, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setBaseTextDirection, setBaseTextDirectionDuringConstruction, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomable
public IlvLine()
(0, 0)
and ending
at (100, 100)
.IlvLine(double, double, double, double)
public IlvLine(IlvPoint fromPoint, IlvPoint toPoint)
fromPoint
and ending at
toPoint
.fromPoint
- The starting point.toPoint
- The ending point.public IlvLine(double fromx, double fromy, double tox, double toy)
fromx
, fromy
and ending at tox
, toy
.fromx
- The starting x-coordinate.fromy
- The starting y-coordinate.tox
- The ending x-coordinate.toy
- The ending y-coordinate.public IlvLine(IlvLine source)
source
- The source line to be copied.public IlvLine(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- The input stream.IlvReadFileException
- if the format is not correct.public IlvGraphic copy()
copy
in class IlvGraphic
IlvGraphic
public boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
contains
in class IlvGraphic
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.true
if the point lies inside this graphic object.IlvGraphic
public void draw(Graphics dst, IlvTransformer t)
draw
in class IlvGraphic
dst
- The destination Graphics.t
- The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer)
,
IlvGraphic.boundingBox(IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public boolean pointsInBBox()
true
because all points of the line
are contained in the bounding box.pointsInBBox
in interface IlvPolyPointsInterface
public IlvRect boundingBox(IlvTransformer t)
boundingBox
in interface IlvPolyPointsInterface
boundingBox
in class IlvGraphic
t
- The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public void applyTransform(IlvTransformer t)
applyTransform
in class IlvGraphic
t
- The transformer to be applied.IlvGraphic
public IlvPoint getFrom()
public IlvPoint getTo()
public void setTo(IlvPoint p)
p
- The new destination point.public void setFrom(IlvPoint p)
p
- The new origin point.public double getLineWidth()
0
.public void setLineWidth(double lineWidth)
lineWidth
- The new line width.public double getLineWidth(IlvTransformer t)
t
- The transformer used to draw the object.public int getEndCap()
IlvStroke
.
The default value is CAP_SQUARE
.IlvStroke
public void setEndCap(int endCap)
endCap
- The new decoration style. The values
are defined in the class IlvStroke
.
The default value is CAP_SQUARE
.IlvStroke
public double getMaximumLineWidth()
public void setMaximumLineWidth(double maximumLineWidth)
maximumLineWidth
- The new maximum line width.public float[] getLineStyle()
public void setLineStyle(float[] lineStyle)
lineStyle
- The new line style.public void setForeground(Color color)
IlvBlinkingColor
.setForeground
in class IlvGraphic
color
- The new color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setBackground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getForeground()
public IlvPoint getPointAt(int index, IlvTransformer t)
getPointAt
in interface IlvPolyPointsInterface
index
- Should be 0
or 1
.t
- The transformer.public int getPointsCardinal()
2
).getPointsCardinal
in interface IlvPolyPointsInterface
public void movePoint(int index, double x, double y, IlvTransformer t)
movePoint
in interface IlvPolyPointsInterface
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.allowsPointMove(int)
public final boolean allowsPointInsertion()
true
if the interactors are allowed to add points, and
false
otherwise.
The default implementation always returns true
.
allowsPointInsertion
in interface IlvPolyPointsInterface
public final boolean allowsPointRemoval()
true
if the interactors are allowed to remove points,
and false
otherwise.
The default implementation always returns true
.
allowsPointRemoval
in interface IlvPolyPointsInterface
public boolean allowsPointMove(int index)
true
if the interactors are allowed to move the point
with the specified index, and false
otherwise.
The default implementation always returns true
.
allowsPointMove
in interface IlvPolyPointsInterface
index
- The index of the point.public final void insertPoint(int index, double x, double y, IlvTransformer t)
IlvLine
. Therefore,
this method has an empty implementation, and should not be called.insertPoint
in interface IlvPolyPointsInterface
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.public final void removePoint(int index, IlvTransformer t)
IlvLine
. Therefore,
this method has an empty implementation, and should not be called.removePoint
in interface IlvPolyPointsInterface
index
- The index of the point to remove.t
- The transformer used to draw the polypoint.public IlvSelection makeSelection()
IlvPolyPointsSelection
.makeSelection
in class IlvGraphic
IlvDrawSelection
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
.
You should not call this
method directly; instead, you should use the write
methods of the manager.write
in interface IlvPersistentObject
write
in class IlvGraphic
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.