|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvGraphic
ilog.views.graphic.IlvPolyPoints
ilog.views.graphic.IlvSpline
public class IlvSpline
IlvSpline represents a line that displays a Bezier spline.
The default values for an IlvSpline instance are as
follows:
Color.blackColor.blackfalsetrueIlvStroke.JOIN_MITER0ffalseIlvGraphicUtil.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(40f, 40f);
points[1] = new IlvPoint(50f, 20f);
points[2] = new IlvPoint(90f, 40f);
points[3] = new IlvPoint(70f, 70f);
points[4] = new IlvPoint(90f, 90f);
points[5] = new IlvPoint(40f, 90f);
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(1f);
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 Form| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
float |
getLineWidth()
Returns the line width of the object. |
float |
getLineWidth(IlvTransformer t)
Returns the line width that is displayed when the object is drawn with the specified transformer. |
float |
getMaximumLineWidth()
Returns the maximum line width of the spline. |
float |
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 c)
Changes the foreground color of the spline. |
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 spline. |
void |
setSmoothness(float 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. |
| Methods inherited from class ilog.views.graphic.IlvPolyPoints |
|---|
allowsPointInsertion, allowsPointMove, allowsPointRemoval, applyTransform, getPointAt, getPoints, getPointsCardinal, inBBox, insertPoint, intersects, movePoint, recomputeBBox, removePoint |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
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| Method Detail |
|---|
public IlvGraphic copy()
copy in class IlvGraphicIlvGraphicprotected void computeBBox(IlvRect bbox)
computeBBox in class IlvPolyPointsbbox - 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 IlvPolyPointsInterfaceboundingBox in class IlvPolyPointst - 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 IlvGraphicp - 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 IlvGraphicinnerPoint - 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 IlvGraphicdst - The destination Graphics.t - The transformation used to draw the object.IlvGraphic.boundingBox(ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic IlvSelection makeSelection()
IlvSplineSelection.
makeSelection in class IlvPolyPointsIlvSplineSelectionpublic void setForeground(Color c)
setForeground in class IlvGraphicc - The new foreground color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setBackground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic Color getForeground()
public void setBackground(Color color)
IlvSpline. It is the
color used to fill the spline.
setBackground in class IlvGraphiccolor - The new background color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setForeground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic 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 IlvGraphicset - 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 IlvGraphicset - 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 float getLineWidth()
0.
public void setLineWidth(float lineWidth)
lineWidth - The new line width.public float getLineWidth(IlvTransformer t)
t - The transformer used to draw the object.public int getEndCap()
IlvStroke.
The default value is CAP_SQUARE.
IlvStrokepublic void setEndCap(int endCap)
endCap - The new decoration style. The values
are defined in the class IlvStroke.
The default value is CAP_SQUARE.IlvStrokepublic float getMaximumLineWidth()
public void setMaximumLineWidth(float maximumLineWidth)
public float[] getLineStyle()
public void setLineStyle(float[] lineStyle)
public void setSmoothness(float 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 float getSmoothness()
setSmoothness(float)
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 IlvPersistentObjectwrite in class IlvPolyPointsstream - The output stream.
IOException - thrown when an exception occurs during
the write operation for this object.
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||