public abstract class IlvPolyPoints extends IlvGraphic implements IlvPolyPointsInterface
IlvPolyPoints
is an abstract class for all graphic objects that
describe an object bound by several points.
In addition to the standard constructors, the following methods should be overridden to create a customized balloon:
pointsInBBox
draw
The following code example shows how to create a simple customized
IlvPolyPoints
class:
class myPolygon extends IlvPolyPoints { private Color fill = Color.red; private Color stroke = Color.blue; public myPolygon(IlvPoint[] points) { super(points); } public myPolygon(IlvPoint points[], boolean copy) { super(points, copy); } public myPolygon(myPolygon source) { super(source); } public myPolygon(IlvInputStream stream) throws IlvReadFileException { super(stream); } public IlvGraphic copy() { return new myPolygon(this); } public void draw(Graphics dst, IlvTransformer t) { IlvGraphicUtil.FillOutlinedPolygon(dst, getPoints(), getPoints().length, fill, stroke, t); } public boolean pointsInBBox() { return true; } }
The following code example shows how to use the customized
IlvPolyPoints
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); myPolygon polygon = new myPolygon(points, true); manager.addObject(polygon, true);
The following image shows the graphic object created in the code example:
>
IlvPolyPoints
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 FormConstructor and Description |
---|
IlvPolyPoints(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvPolyPoints(IlvPoint[] points)
Creates a new
IlvPolyPoints . |
IlvPolyPoints(IlvPoint[] points,
boolean copy)
Creates a new
IlvPolyPoints . |
IlvPolyPoints(IlvPolyPoints source)
Creates a new
IlvPolyPoints by copying an existing one. |
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 the given transformer to this
IlvPolyPoints . |
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.
|
protected void |
computeBBox(IlvRect bbox)
Recomputes the bounding rectangle of the object.
|
IlvPoint |
getPointAt(int index,
IlvTransformer t)
Returns the point at the specified index.
|
protected IlvPoint[] |
getPoints()
Returns the internal array of points.
|
int |
getPointsCardinal()
Returns the number of points.
|
boolean |
inBBox(IlvPoint p)
Tests if a point lies inside the bounding box of the object.
|
void |
insertPoint(int index,
double x,
double y,
IlvTransformer t)
Inserts a point at a specified index.
|
boolean |
intersects(IlvRect rect,
IlvRect trect,
IlvTransformer t)
Tests if a rectangle overlaps the object.
|
IlvSelection |
makeSelection()
Creates the selection object for this class.
|
void |
movePoint(int index,
double x,
double y,
IlvTransformer t)
Changes the position of a point.
|
void |
recomputeBBox()
Recomputes the cached bounding rectangle of the object.
|
void |
removePoint(int index,
IlvTransformer t)
Removes a point at a specified index.
|
void |
translate(double dx,
double dy)
Translates the object by the vector (
dx, dy ). |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
addActionListener, addNamedPropertyListener, allViewsRemoved, baseTextDirectionChanged, blinkingStateOn, boundingBox, callDraw, componentOrientationChanged, contains, copy, draw, 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, 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, setForeground, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
pointsInBBox
public IlvPolyPoints(IlvPoint[] points)
IlvPolyPoints
.
Note that this constructor will copy the array and
the points in the array, so you can reuse the same
array for other operations.points
- The array of points.public IlvPolyPoints(IlvPoint[] points, boolean copy)
IlvPolyPoints
.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 further.public IlvPolyPoints(IlvPolyPoints source)
IlvPolyPoints
by copying an existing one.source
- The source object.public IlvPolyPoints(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- The input stream.IlvReadFileException
- if the format is not correct.write(ilog.views.io.IlvOutputStream)
protected IlvPoint[] getPoints()
protected void computeBBox(IlvRect bbox)
bbox
- The rectangle to store the resulting bounding box.public void recomputeBBox()
public boolean inBBox(IlvPoint p)
p
- The point to test.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.public boolean intersects(IlvRect rect, IlvRect trect, IlvTransformer t)
intersects
in class IlvGraphic
rect
- The rectangle to be tested.trect
- The rectangle rect
transformed by the
transformer t
.t
- The transformation that was applied to the object when it
was drawn.true
if the rectangle overlaps this graphic object.IlvGraphic
public IlvRect boundingBox(IlvTransformer t)
boundingBox
in interface IlvPolyPointsInterface
boundingBox
in class IlvGraphic
t
- The transformer.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public void applyTransform(IlvTransformer t)
IlvPolyPoints
.applyTransform
in class IlvGraphic
t
- The transformer to be applied.IlvGraphic
public void translate(double dx, double dy)
dx, dy
).
The vector must be given in untransformed coordinates.translate
in class IlvGraphic
dx
- The horizontal translation factor.dy
- The vertical translation factor.IlvGraphic
,
IlvGraphic.applyTransform(IlvTransformer)
public IlvPoint getPointAt(int index, IlvTransformer t)
getPointAt
in interface IlvPolyPointsInterface
index
- The index of the point.t
- The transformer used to draw the object.public int getPointsCardinal()
getPointsCardinal
in interface IlvPolyPointsInterface
public 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 boolean allowsPointRemoval()
true
if the interactors are allowed to remove points,
and false
otherwise.
The default implementation returns true
if the
current number of points is larger than or equal to 2.
allowsPointRemoval
in interface IlvPolyPointsInterface
getPointsCardinal()
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 void insertPoint(int index, double x, double y, IlvTransformer t)
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 object.public void removePoint(int index, IlvTransformer t)
removePoint
in interface IlvPolyPointsInterface
index
- The index of the point to be removed.t
- The transformer used to draw the object.public void movePoint(int index, double x, double y, IlvTransformer t)
movePoint
in interface IlvPolyPointsInterface
index
- The index of the point to be moved.x
- The new x position in untransformed coordinates.y
- The new y position in untransformed coordinates.t
- The transformer used to draw the object.public IlvSelection makeSelection()
IlvPolyPointsSelection
.makeSelection
in class IlvGraphic
IlvPolyPointsSelection
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.