public class IlvSpline extends IlvPolyPoints
IlvSpline
represents a line that displays a Bezier spline.
The default values for an IlvSpline
instance are as
follows:
Color.black
Color.black
false
true
IlvStroke.JOIN_MITER
0
false
IlvGraphicUtil.COMPATIBLE_SMOOTHNESS
The following code example shows how to use IlvSpline
in a simple Java application:
IlvManager manager = new IlvManager(); IlvPoint[] points = new IlvPoint[6]; points[0] = new IlvPoint(40, 40); points[1] = new IlvPoint(50, 20); points[2] = new IlvPoint(90, 40); points[3] = new IlvPoint(70, 70); points[4] = new IlvPoint(90, 90); points[5] = new IlvPoint(40, 90); IlvSpline defaultSpline = new IlvSpline(points, true); IlvSpline customSpline = new IlvSpline(points, true); customSpline.setStrokeOn(true); customSpline.setForeground(Color.green); customSpline.setLineWidth(5); customSpline.setBackground(Color.red); customSpline.setFillOn(true); customSpline.setClosed(true); customSpline.setSmoothness(1); customSpline.moveResize(new IlvRect(100,80,40,40)); IlvPoint center = customSpline.getCenter(new IlvTransformer()); customSpline.rotate(center, 130); manager.addObject(defaultSpline, true); manager.addObject(customSpline, true);
The following image shows the graphic objects created in the code example:
>
IlvSpline
is a custom graphic object, that is, a subclass of
IlvGraphic
. Graphic objects are controlled using an instance of
IlvManager
or one of its subclasses, and displayed using one or
more IlvManagerView
instances in a Java Swing application.
For information about generic features for graphic objects, see
IlvGraphic.
IlvManager
,
IlvManagerView
,
IlvStroke
,
IlvGraphicUtil
,
Serialized FormConstructor and Description |
---|
IlvSpline(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvSpline(IlvPoint[] points)
Creates a new spline.
|
IlvSpline(IlvPoint[] points,
boolean copy)
Creates a new
IlvSpline . |
IlvSpline(IlvPoint[] points,
boolean copy,
boolean closed)
Creates a new
IlvSpline . |
IlvSpline(IlvSpline source)
Creates a new spline by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.
|
protected void |
computeBBox(IlvRect bbox)
Recomputes 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.
|
Color |
getBackground()
Returns the color of the
IlvSpline . |
int |
getEndCap()
Returns the decoration applied at the end of the polyline.
|
Color |
getForeground()
Returns the foreground color of the spline.
|
IlvPoint |
getIntersectionWithOutline(IlvPoint innerPoint,
IlvPoint outerPoint,
IlvTransformer t)
Returns the intersection of the line segment from inner point to outer
point with the shape of the graphic object.
|
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
displayed when the object is drawn
with the specified transformer.
|
double |
getMaximumLineWidth()
Returns the maximum line width of the spline.
|
double |
getSmoothness()
Returns the smoothness of the spline.
|
boolean |
isClosed()
Returns
true if the spline is closed. |
boolean |
isFillOn()
Returns
true if the inside of the
spline will be filled. |
boolean |
isStrokeOn()
Returns
true if the
spline is stroked. |
IlvSelection |
makeSelection()
Creates the selection object for this class.
|
boolean |
pointsInBBox()
Returns
false since all points are
not contained inside
the bounding rectangle of the object. |
void |
setBackground(Color color)
Changes the background color of the
IlvSpline . |
void |
setClosed(boolean set)
When set to
true , specifies that the
spline is closed. |
void |
setEndCap(int endCap)
Changes the decoration applied at the end of the polyline.
|
void |
setFillOn(boolean set)
If
true , specifies that the inside of the
spline will be filled. |
void |
setForeground(Color color)
Changes the foreground color of the spline.
|
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 spline.
|
void |
setSmoothness(double smoothness)
Sets the smoothness of the spline.
|
void |
setStrokeOn(boolean set)
When set to
true , specifies that the
spline is stroked. |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
allowsPointInsertion, allowsPointMove, allowsPointRemoval, applyTransform, getPointAt, getPoints, getPointsCardinal, inBBox, insertPoint, intersects, movePoint, recomputeBBox, removePoint, translate
addActionListener, addNamedPropertyListener, allViewsRemoved, baseTextDirectionChanged, blinkingStateOn, boundingBox, callDraw, componentOrientationChanged, getAndAssociateObjectInteractor, getBaseTextDirection, getBlinkingAction, getBlinkingObjectOwner, getBlinkingOffPeriod, getBlinkingOnPeriod, getCenter, getComponentOrientation, getDefaultInteractor, getGraphicBag, GetGraphicObject, getLocale, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getResolvedBaseTextDirection, getToolTipBaseTextDirection, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, getULocale, getZOrderIndex, hasProperty, inside, 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, setBaseTextDirection, setBaseTextDirectionDuringConstruction, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomable
public IlvSpline(IlvPoint[] points)
points
- The control points of the spline.
This array and the points will be copied by the constructor.public IlvSpline(IlvPoint[] points, boolean copy)
IlvSpline
.points
- The array of points.copy
- If true
, the array of points and its points
of the first parameter will be copied. Otherwise this
array will be used by the object and you must not use this
array anymore.public IlvSpline(IlvPoint[] points, boolean copy, boolean closed)
IlvSpline
.points
- The array of points.closed
- true
if the spline has to be closed.copy
- If true
, the array of points and its points
of the first parameter will be copied. Otherwise this
array will be used by the object and you must not use this
array anymore.public IlvSpline(IlvSpline source)
public IlvSpline(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- The input stream.IlvReadFileException
- if the format is not correct.IlvReadFileException
public IlvGraphic copy()
copy
in class IlvGraphic
IlvGraphic
protected void computeBBox(IlvRect bbox)
computeBBox
in class IlvPolyPoints
bbox
- The rectangle to store the resulting bounding box.public boolean pointsInBBox()
false
since all points are
not contained inside
the bounding rectangle of the object.public IlvRect boundingBox(IlvTransformer t)
boundingBox
in interface IlvPolyPointsInterface
boundingBox
in class IlvPolyPoints
t
- The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
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 IlvPoint getIntersectionWithOutline(IlvPoint innerPoint, IlvPoint outerPoint, IlvTransformer t)
innerPoint
is not inside the graphic object,
or if outerPoint
is not outside the graphic object, it
must return a valid point. For instance, if there is no intersection,
it can return the start point.
This implementation calculates the precise intersection if the spline
smoothness is not IlvGraphicUtil.COMPATIBLE_SMOOTHNESS
and the line width is small. If the line width is very large, rounding errors
will become visible.
getIntersectionWithOutline
in class IlvGraphic
innerPoint
- A point usually inside the graphic object, given in
manager view coordinates.outerPoint
- A point usually outside of the graphic object, given in
manager view coordinates.t
- The transformation used to draw the object.IlvClippingLinkConnector
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 IlvSelection makeSelection()
IlvSplineSelection
.makeSelection
in class IlvPolyPoints
IlvSplineSelection
public void setForeground(Color color)
IlvBlinkingColor
.setForeground
in class IlvGraphic
color
- The new foreground color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setBackground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getForeground()
public void setBackground(Color color)
IlvSpline
. It is the
color used to fill the spline.
This property supports
IlvBlinkingColor
.setBackground
in class IlvGraphic
color
- The new background color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setForeground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getBackground()
IlvSpline
. It is the color
used to fill the spline.public boolean isFillOn()
true
if the inside of the
spline will be filled.setFillOn(boolean)
public void setFillOn(boolean set)
true
, specifies that the inside of the
spline will be filled.setFillOn
in class IlvGraphic
set
- Set to true
to enable the fill style for this
graphic object.isFillOn()
public boolean isStrokeOn()
true
if the
spline is stroked.setStrokeOn(boolean)
public void setStrokeOn(boolean set)
true
, specifies that the
spline is stroked.setStrokeOn
in class IlvGraphic
set
- Set to true
to enable the stroke in your
customized graphic object.isStrokeOn()
public void setClosed(boolean set)
true
, specifies that the
spline is closed.public boolean isClosed()
true
if the spline is closed.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)
public float[] getLineStyle()
public void setLineStyle(float[] lineStyle)
public void setSmoothness(double smoothness)
A special value IlvGraphicUtil.AUTO_SMOOTHNESS
can be set
to use an algorithm that automatically detects an appropriate smoothness
for each bend.
The default value is IlvGraphicUtil.COMPATIBLE_SMOOTHNESS
.
With this value, a spline looks exactly as in JViews 3.0,
that is, a spline with more than two bends (four control points) will not
look smooth.
Changing the smoothness influences the bounding box of the object.
Therefore it should only be done using an IlvApplyObject
passed to IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
smoothness
- The smoothness.getSmoothness()
public double getSmoothness()
setSmoothness(double)
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
.
Note that even if this is a public method, you should not
call it directly. You should use the write
methods of the manager.write
in interface IlvPersistentObject
write
in class IlvPolyPoints
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.