public class IlvPolygon extends IlvPolyPoints
IlvPolygon represents a polygon.
The default values for an IlvPolygon instance are as
follows:
Color.blackColor.blackfalsetrue
The following code example shows how to use IlvPolygon
in a simple Java application:
IlvManager manager = new IlvManager();
IlvPoint[] points = new IlvPoint[7];
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);
points[6] = new IlvPoint(40, 40);
IlvPolygon defaultPolygon = new IlvPolygon(points, true);
IlvPolygon customPolygon = new IlvPolygon(points, true);
customPolygon.setStrokeOn(true);
customPolygon.setBackground(Color.blue);
customPolygon.setForeground(Color.green);
customPolygon.moveResize(new IlvRect(100,80,40,40));
IlvPoint center = customPolygon.getCenter(new IlvTransformer());
customPolygon.rotate(center, 130);
manager.addObject(defaultPolygon, true);
manager.addObject(customPolygon, true);
The following image shows the graphic objects created in the code example:
>
IlvPolygon 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,
Serialized Form| Constructor and Description |
|---|
IlvPolygon(IlvInputStream stream)
Reads the object from an
IlvInputStream. |
IlvPolygon(IlvPoint[] points)
Creates a new polygon.
|
IlvPolygon(IlvPoint[] points,
boolean copy)
Creates a new
IlvPolygon. |
IlvPolygon(IlvPoint[] points,
boolean copy,
boolean outlined,
boolean filled)
Creates a new
IlvPolygon. |
IlvPolygon(IlvPolygon source)
Creates a new polygon by copying an existing one.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
Color |
getBackground()
Returns the background color of the
IlvPolygon. |
Color |
getForeground()
Returns the foreground color of the polygon.
|
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.
|
boolean |
isFillOn()
Returns
true if the inside of the
polygon will be filled. |
boolean |
isStrokeOn()
Returns
true if the shape of the
polygon is stroked. |
IlvSelection |
makeSelection()
Creates the selection object for this class.
|
boolean |
pointsInBBox()
Returns
true if all points of the polypoint object are contained
in the bounding box. |
void |
setBackground(Color color)
Changes the background color of the
IlvPolygon. |
void |
setFillOn(boolean set)
If
true, specifies that the inside of the
polygon will be filled. |
void |
setForeground(Color color)
Changes the foreground color of the polygon.
|
void |
setStrokeOn(boolean set)
When set to
true, specifies that the shape of the
polygon is stroked. |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream. |
allowsPointInsertion, allowsPointMove, allowsPointRemoval, applyTransform, boundingBox, computeBBox, getPointAt, getPoints, getPointsCardinal, inBBox, insertPoint, intersects, movePoint, recomputeBBox, removePoint, translateaddActionListener, 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, zoomablepublic IlvPolygon(IlvPoint[] points)
points - The points of the polygon.public IlvPolygon(IlvPoint[] points, boolean copy)
IlvPolygon.points - The array of points.copy - If true then the array of points and the 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 IlvPolygon(IlvPoint[] points, boolean copy, boolean outlined, boolean filled)
IlvPolygon.points - The array of points.copy - If true then the array of points and the 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.outlined - true if the polygon have to be stroked.filled - true if the polygon have to be filled.setStrokeOn(boolean),
setFillOn(boolean)public IlvPolygon(IlvPolygon source)
source - The copied object.public IlvPolygon(IlvInputStream stream) throws IlvReadFileException
IlvInputStream.stream - The input stream.IlvReadFileException - if the format is not correct.IlvReadFileExceptionpublic IlvGraphic copy()
copy in class IlvGraphicIlvGraphicpublic boolean pointsInBBox()
true if all points of the polypoint object are contained
in the bounding box. Since this is the case for the class
IlvPolygon, this method simply returns true.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 void setForeground(Color color)
IlvBlinkingColor.setForeground in class IlvGraphiccolor - The new foreground color.getForeground()public Color getForeground()
setForeground(java.awt.Color)public void setBackground(Color color)
IlvPolygon. It
is the color used to outline the polygon.
This property supports
IlvBlinkingColor.setBackground in class IlvGraphiccolor - The new background color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setForeground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic Color getBackground()
IlvPolygon. It
is the color used to outline the polygon.public boolean isFillOn()
true if the inside of the
polygon will be filled.setFillOn(boolean)public void setFillOn(boolean set)
true, specifies that the inside of the
polygon 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 shape of the
polygon is stroked.setStrokeOn(boolean)public void setStrokeOn(boolean set)
true, specifies that the shape of the
polygon is stroked.setStrokeOn in class IlvGraphicset - Set to true to enable the stroke in your
customized graphic object.isStrokeOn()public IlvSelection makeSelection()
IlvPolyPointsSelection.makeSelection in class IlvPolyPointsIlvPolyPointsSelectionpublic 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.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.