public class IlvGraphicPath extends IlvGraphic
IlvGraphicPath object is a set of polypoints that can be
drawn as a polyline or a polygon.
The way in which an IlvGraphicPath is presented depends on
the DrawRule attribute. This attribute is set to one of
the following properties:
STROKE_ONLY - the polypoints in this object are drawn
as polylines, that is, only the stroke is painted.FILL_ONLY - the object is drawn as a filled polygon,
only the fill is painted.STROKE_AND_FILL - the object is drawn as a filled
polygon with an outline, both the fill and stroke are painted.
The stroke color is set by calling setForeground, the fill
color by calling setBackground.
The main differences between an IlvGraphicPath object and
a set of IlvPolygon objects are that for
IlvGraphicPath:
FILL_ONLY and STROKE_AND_FILL mode,
each polypoint has an influence on the rendering of the other
polypoints:
depending on the position of its points, a polypoint can either appear
as an ordinary polygon or as a hole in another polygon.The default values for an IlvGraphicPath instance are as
follows:
Color.blackColor.blackSTROKE_ONLY
The following code example shows how to use IlvGraphicPath in a
simple Java application:
IlvPoint[] outer = new IlvPoint[5]; outer[0] = new IlvPoint(5, 5); outer[1] = new IlvPoint(60, 5); outer[2] = new IlvPoint(60, 60); outer[3] = new IlvPoint(5, 60); outer[4] = new IlvPoint(5, 5); IlvPoint[] inner = new IlvPoint[5]; inner[0] = new IlvPoint(10, 10); inner[1] = new IlvPoint(55, 10); inner[2] = new IlvPoint(55, 55); inner[3] = new IlvPoint(10, 55); inner[4] = new IlvPoint(10, 10); IlvPointArray[] squares = new IlvPointArray[2]; squares[0] = new IlvPointArray(outer, true); squares[1] = new IlvPointArray(inner, true); IlvGraphicPath sketch = new IlvGraphicPath(squares, true); sketch.setFillOn(true); sketch.setBackground(Color.green); sketch.setForeground(Color.red); sketch.setDrawRule(IlvGraphicPath.STROKE_AND_FILL); // Add the graphic object to the manager. manager.addObject(sketch,true);
The following image shows the graphic object created in the code example:
>
IlvGraphicPath 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.
IlvPointArray,
IlvPolygon,
IlvPolyline,
IlvManager,
IlvManagerView,
IlvRect,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
FILL_ONLY
Fill only drawing rule.
|
static int |
STROKE_AND_FILL
Stroke and fill drawing rule.
|
static int |
STROKE_ONLY
Stroke only drawing rule.
|
| Constructor and Description |
|---|
IlvGraphicPath(IlvGraphicPath source)
Creates a new
IlvGraphicPath by copying
an existing one. |
IlvGraphicPath(IlvInputStream stream)
Reads the object from an
IlvInputStream. |
IlvGraphicPath(IlvPoint[] points,
boolean copy)
Creates an
IlvGraphicPath containing only one polypoint. |
IlvGraphicPath(IlvPointArray[] paths,
boolean copy)
Creates an
IlvGraphicPath containing several polypoints. |
| Modifier and Type | Method and Description |
|---|---|
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 shape of the object.
|
IlvGraphic |
copy()
Copies the object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the object.
|
Color |
getBackground()
Returns the background color of the object.
|
int |
getDrawRule()
Returns the DrawRule of the object.
|
Color |
getForeground()
Returns the foreground color of the object.
|
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.
|
int |
getNumPaths()
Returns the number of
IlvPointArray
managed by this object. |
IlvPointArray[] |
getPaths()
Returns the array of
IlvPointArray
managed by this object. |
void |
setBackground(Color c)
Changes the background color of the object.
|
void |
setDrawRule(int val)
Changes the DrawRule of the object.
|
void |
setForeground(Color c)
Changes the foreground color of the object.
|
void |
setPaths(IlvPoint[] points,
boolean copy)
Sets the paths.
|
void |
setPaths(IlvPointArray[] paths,
boolean copy)
Sets the paths.
|
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, 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, makeSelection, move, move, moveResize, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, 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, zoomablepublic static final int STROKE_ONLY
public static final int FILL_ONLY
public static final int STROKE_AND_FILL
public IlvGraphicPath(IlvPoint[] points, boolean copy)
IlvGraphicPath containing only one polypoint.points - The array of points of the polypoint.copy - If true, the array of points and the
points are copied before being used by the class. If false,
the array is internally stored in the object and you must not use
the array anymore.public IlvGraphicPath(IlvPointArray[] paths, boolean copy)
IlvGraphicPath containing several polypoints.paths - The array of polypoints.copy - If true, the array of polypoints is
copied before being used by the class. If false,
the array is internally stored in the object and you must not use
the array anymore.public IlvGraphicPath(IlvGraphicPath source)
IlvGraphicPath by copying
an existing one.source - The copied object.public IlvGraphicPath(IlvInputStream stream) throws IlvReadFileException
IlvInputStream.stream - The input stream.IlvReadFileException - if the format is not correct.public IlvGraphic copy()
copy in class IlvGraphicIlvGraphicpublic void setDrawRule(int val)
val - Valid values for this parameter are :
STROKE_ONLY, where each polypoint is
displayed as a polyline using the foreground color. FILL_ONLY, where each polypoint is
displayed as a filled polygon using the background color.STROKE_AND_FILL, where each polypoint is displayed
as a filled polygon with an outline polyline.getDrawRule()public int getDrawRule()
STROKE_ONLY, FILL_ONLY or
STROKE_AND_FILL.setDrawRule(int)public int getNumPaths()
IlvPointArray
managed by this object.public void setPaths(IlvPoint[] points, boolean copy)
Note that changing the paths may change the bounding rectangle.
For this reason, if the object is contained inside a manager
you should modify the paths using the method
IlvManager.applyToObject(IlvGraphic, IlvApplyObject, Object, boolean)
of the manager containing the object.
points - The array of points of the polypoint.copy - If true, the array of points and the
points are copied before being used by the class. If false,
the array is internally stored in the object and you must not use
the array anymore.setPaths(IlvPointArray[], boolean),
getPaths()public void setPaths(IlvPointArray[] paths, boolean copy)
Note that changing the paths may change the bounding rectangle.
For this reason, if the object is contained inside a manager
you should modify the paths using the method
IlvManager.applyToObject(IlvGraphic, IlvApplyObject, Object, boolean)
of the manager containing the object.
paths - The array of polypoints.copy - If true, the array of polypoints is
copied before being used by the class. If false,
the array is internally stored in the object and you must not use
the array anymore.setPaths(IlvPoint[], boolean),
getPaths()public IlvPointArray[] getPaths()
IlvPointArray
managed by this object. Note that this method returns
the internal array managed by this object, so you should
not modify the array.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.IlvGraphicpublic 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.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.IlvClippingLinkConnectorpublic void draw(Graphics dst, IlvTransformer t)
draw in class IlvGraphicdst - The destination Graphics.t - The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic IlvRect boundingBox(IlvTransformer t)
boundingBox in class IlvGraphict - The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic void applyTransform(IlvTransformer t)
applyTransform in class IlvGraphict - The transformer to be applied.IlvGraphicpublic void setForeground(Color c)
IlvBlinkingColor.setForeground in class IlvGraphicc - The new color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setBackground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic Color getForeground()
public void setBackground(Color c)
IlvBlinkingColor.setBackground in class IlvGraphicc - The new color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setForeground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic Color getBackground()
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 IlvGraphicstream - The output stream.IOException - thrown when an exception occurs during
the write operation for this object.© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.