public class IlvGeneralPath extends IlvGraphic implements IlvPolyPointsInterface
IlvGeneralPath is a graphic object that can take any
two dimensional shape.
The shape of an IlvGeneralPath instance is controlled using a
Java Shape instance; its fill and stroke styles are
customized using Java Stroke and Paint objects;
you can use gradient paint effects for IlvGeneralPath
instances.
The default values for an IlvGeneralPath instance are as
follows:
trueColor.blackfalseColor.blackRectangle.Double(0,0,100,100)
The following code example shows how to use IlvGeneralPath in a
simple Java application:
int DEFAULT_WIDTH = 70;
int DEFAULT_HEIGHT = 30;
IlvPoint corner = new IlvPoint(50,50);
IlvManager manager = new IlvManager();
//Create a customized circle.
Shape shape = new Rectangle2D.Double(corner.x, corner.y,
DEFAULT_WIDTH, DEFAULT_HEIGHT);
IlvGeneralPath path = new IlvGeneralPath(shape);
path.setFillPaint(
new GradientPaint(
new Point((int)corner.x + DEFAULT_WIDTH/2,
(int)corner.y),
Color.yellow,
new Point((int)corner.x + DEFAULT_WIDTH/2,
(int)corner.y + DEFAULT_HEIGHT),
Color.red));
path.setStrokePaint(Color.blue);
//Add the graphic objects to the manager.
manager.addObject(path,true);
The following image shows the graphic object created in the code example:
>
IlvGeneralPath 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 |
|---|
IlvGeneralPath()
Creates an
IlvGeneralPath instance with a Rectangle as shape. |
IlvGeneralPath(IlvGeneralPath source)
Creates a new
IlvGeneralPath by copying an existing one. |
IlvGeneralPath(IlvInputStream stream)
Reads the object from an
IlvInputStream. |
IlvGeneralPath(Shape shape)
Creates a new
IlvGeneralPath. |
| Modifier and Type | Method and Description |
|---|---|
protected Paint |
adaptPaint(Shape shape,
Paint paint)
Returns a
new
Paint object that will fit the shape parameter
according to the initial paint parameter. |
boolean |
allowsPointInsertion()
Returns
true if isPointEditionAllowed
returns true and
false otherwise. |
boolean |
allowsPointMove(int index)
Returns
true ifisPointEditionAllowed
returns true and
false otherwise. |
boolean |
allowsPointRemoval()
Returns
true if isPointEditionAllowed
returns true and
false otherwise. |
void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.
|
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.
|
protected IlvRect |
calcBoundingBox(IlvTransformer t)
Calculates the bounding rectangle of the object.
|
boolean |
contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the shape.
|
IlvGraphic |
copy()
Copies the objects.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the object.
|
float |
getAlpha()
Returns the alpha value of this graphic object.
|
IlvTransformer |
getApplyTransformer()
Returns the internal transformer that represents the sum of all
calls of
applyTransform(ilog.views.IlvTransformer) since the shape of the general path
was set. |
Shape |
getClip()
Returns the shape that will clip the object.
|
Paint |
getFillPaint()
Returns the paint object set to fill the shape.
|
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.
|
double |
getMaximumStrokeWidth()
Returns the maximum stroke width used if a
BasicStroke
is set. |
Shape |
getOriginalShape()
Returns the original shape that was set via
setShape(java.awt.Shape). |
IlvPoint |
getPointAt(int index,
IlvTransformer t)
Returns the point at the specified index.
|
int |
getPointsCardinal()
Returns the number of points defining the
IlvGeneralPath. |
Shape |
getShape()
Returns the shape of the object.
|
IlvRect |
getShapeBounds(IlvTransformer t)
Returns the bounding rectangle of the
Shape
of the object. |
Stroke |
getStroke()
Returns the stroke object used to stroke
the shape.
|
Paint |
getStrokePaint()
Returns the paint object set to
stroke the path.
|
IlvTransformer |
getTransformer()
Returns the additional transformer that is
applied to the
Graphics2D before displaying the
IlvGeneralPath. |
void |
insertPoint(int index,
double x,
double y,
IlvTransformer t)
Inserts a new point in the
IlvGeneralPath if
allowsPointInsertion returns true. |
boolean |
isContainsWhenNotFilled()
Returns
true when the
method contains will return true for a
point inside the shape even if the object
is not filled. |
boolean |
isFillOn()
Returns
true if the inside of the
object will be filled. |
boolean |
isPaintAbsolute()
Returns
false if the TexturePaint or
GradientPaint will be adapted to the bounding rectangle of the
object. |
boolean |
isPaintZoomed()
Returns
true if the texture or
gradient will be zoomed according to the shape
when the object is zoomed. |
boolean |
isPointEditionAllowed()
Returns
true if it is allowed to move, insert, or remove a
point of the IlvGeneralPath. |
boolean |
isStrokeOn()
Returns
true if the shape of the
object is stroked. |
boolean |
isTransformedShapeMode()
Returns
true if the object is in transformed shape mode. |
IlvSelection |
makeSelection()
Creates the selection object for this
IlvGeneralPath
instance. |
void |
movePoint(int index,
double x,
double y,
IlvTransformer t)
Changes the position of a point if
isPointEditionAllowed
returns true. |
void |
moveResize(IlvRect rect)
Resizes the object.
|
boolean |
pointsInBBox()
Returns
false since all points are
not contained inside
the bounding rectangle of the object. |
void |
removePoint(int index,
IlvTransformer t)
Removes a point from the
IlvGeneralPath if
allowsPointRemoval returns true. |
void |
resize(double neww,
double newh)
Resizes the object.
|
void |
setAlpha(float alpha)
Changes the alpha value of this graphic object.
|
void |
setBackground(Color c)
Changes the background color of the object.
|
void |
setClip(Shape clip)
Changes the shape that will clip the object.
|
void |
setContainsWhenNotFilled(boolean set)
When set to
true, specifies that the
method contains will return true for a
point inside the shape even if the object
is not filled. |
void |
setFillOn(boolean set)
If
true, specifies that the inside of the
object will be filled. |
void |
setFillPaint(Paint paint)
Changes the paint object used to fill
the shape.
|
void |
setForeground(Color c)
Changes the foreground color of the object.
|
protected void |
setInternalShape(Shape shape)
Sets the internal shape.
|
void |
setMaximumStrokeWidth(double value)
Allows you to set the maximum stroke width if a
BasicStroke
is used. |
void |
setPaintAbsolute(boolean set)
When set to
false, specifies that the
TexturePaint or GradientPaint will be adapted
to the bounding rectangle of the object. |
void |
setPaintZoomed(boolean set)
When set to
true, specifies that the texture or
gradient will be zoomed according to the shape
when the object is zoomed. |
void |
setPointEditionAllowed(boolean set)
Allows you to change the value returned by the method
isPointEditionAllowed(). |
void |
setShape(Shape shape)
Changes the shape of the object.
|
void |
setShapeBounds(IlvRect rect)
Resizes the bounding rectangle of the
Shape
of the object. |
void |
setStroke(Stroke stroke)
Changes the stroke object used to stroke
the shape.
|
void |
setStrokeOn(boolean set)
When set to
true, specifies that the shape of the
object is stroked. |
void |
setStrokePaint(Paint paint)
Changes the paint object used
when stroking the path.
|
void |
setTransformedShapeMode(boolean transformedShapeMode)
Sets the transformed shape mode.
|
void |
setTransformer(IlvTransformer t)
Sets the additional transformer that is
applied to the
Graphics2D before
displaying the IlvGeneralPath. |
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, move, move, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, rotate, scale, setBaseTextDirection, setBaseTextDirectionDuringConstruction, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomablepublic IlvGeneralPath()
IlvGeneralPath instance with a Rectangle as shape.public IlvGeneralPath(Shape shape)
IlvGeneralPath.shape - The initial shape of the general path.public IlvGeneralPath(IlvGeneralPath source)
IlvGeneralPath by copying an existing one.source - The origin object for the copy.public IlvGeneralPath(IlvInputStream stream) throws IlvReadFileException
IlvInputStream.stream - The input stream.IlvReadFileException - if the format is not correct.public Shape getShape()
IlvGeneralPath.
If you need to change the shape of the object, use the
setShape method.setShape(java.awt.Shape),
getOriginalShape()public void setShape(Shape shape)
Note that the semantics of this method depends on the transformed shape mode,
see setTransformedShapeMode(boolean).
Note also that changing the shape of the object may
change its bounding rectangle. For this reason,
if the object is contained inside a manager
you should modify the shape using the applyToObject
method of the manager.
protected void setInternalShape(Shape shape)
public final IlvTransformer getTransformer()
Graphics2D before displaying the
IlvGeneralPath.setTransformer(ilog.views.IlvTransformer)public final void setTransformer(IlvTransformer t)
Graphics2D before
displaying the IlvGeneralPath. This allows you
to transform the drawing without modifying the real shape of the object.applyTransform(ilog.views.IlvTransformer)public boolean isFillOn()
true if the inside of the
object will be filled.setFillPaint(java.awt.Paint),
setFillOn(boolean)public void setFillOn(boolean set)
true, specifies that the inside of the
object will be filled.setFillOn in class IlvGraphicset - Set to true to enable the fill style for this
graphic object.isFillOn(),
setFillPaint(java.awt.Paint)public boolean isStrokeOn()
true if the shape of the
object is stroked.public void setStrokeOn(boolean set)
true, specifies that the shape of the
object is stroked. Note that this may
change its bounding rectangle. For this reason,
if the object is contained inside a manager,
you should modify the shape using the applyToObject
method of the manager.setStrokeOn in class IlvGraphicset - Set to true to enable the stroke in your
customized graphic object.setStroke(java.awt.Stroke),
setStrokePaint(java.awt.Paint),
isStrokeOn()public void setStroke(Stroke stroke)
null to remove the
stroke. Note that changing the stroke may modify the
bounding rectangle of the object. For this reason,
if the object is contained inside a manager,
you should modify the shape using the applyToObject
method of the manager.getStrokePaint(),
getStroke(),
isStrokeOn()public Stroke getStroke()
null if there is
no stroke specified.getStrokePaint(),
setStroke(java.awt.Stroke),
isStrokeOn()public void setMaximumStrokeWidth(double value)
BasicStroke
is used.
If the maximum stroke width is specified and not
equal to zero, then the width of the basic stroke will
stop zooming when the maximum stroke width is reached.
A value of zero means that there is no limit.
The default value is zero.getMaximumStrokeWidth(),
getStroke()public double getMaximumStrokeWidth()
BasicStroke
is set.
If the maximum stroke width is specified and not
equal to zero, then the width of the basic stroke will
stop zooming when the maximum stroke width is reached.
A value of zero means that there is no limit.
The default value is zero.setMaximumStrokeWidth(double),
getStroke()public void setFillPaint(Paint paint)
IlvBlinkingPaint.paint - The new filling object.getFillPaint(),
isFillOn()public Paint getFillPaint()
setFillPaint(java.awt.Paint)public void setStrokePaint(Paint paint)
IlvBlinkingPaint.getStrokePaint(),
isStrokeOn(),
setStroke(java.awt.Stroke)public Paint getStrokePaint()
public boolean isPaintZoomed()
true if the texture or
gradient will be zoomed according to the shape
when the object is zoomed. The default value is
true.public void setPaintZoomed(boolean set)
true, specifies that the texture or
gradient will be zoomed according to the shape
when the object is zoomed.public boolean isPaintAbsolute()
false if the TexturePaint or
GradientPaint will be adapted to the bounding rectangle of the
object. The default value is false. This value does not
affect automatically adjusted Paint such as
ilog.views.java2d.IlvLinearGradientPaint.public void setPaintAbsolute(boolean set)
false, specifies that the
TexturePaint or GradientPaint will be adapted
to the bounding rectangle of the object.
The default value is false. This value does not affect
automatically adjusted Paint such as
ilog.views.java2d.IlvLinearGradientPaint.public boolean isContainsWhenNotFilled()
true when the
method contains will return true for a
point inside the shape even if the object
is not filled.public void setContainsWhenNotFilled(boolean set)
true, specifies that the
method contains will return true for a
point inside the shape even if the object
is not filled.isFillOn(),
isContainsWhenNotFilled()public void setForeground(Color c)
setStrokePaint on the object.
This method is here for compatibility reasons for the non Java 2
IlvGraphic.setForeground in class IlvGraphicc - The new color.setStrokePaint(java.awt.Paint)public void setBackground(Color c)
setFillPaint on the object.
This method is here for compatibility reasons for the non Java 2
IlvGraphic.setBackground in class IlvGraphicc - The new color.setFillPaint(java.awt.Paint)public void setClip(Shape clip)
null if no clip is applied.
Note that the semantics of this method depends on the transformed shape
mode, see setTransformedShapeMode(boolean).
The clipping shape will follow the transformation applied to the object.
clip - The new clip.applyTransform(ilog.views.IlvTransformer)public Shape getClip()
null if no clip is applied. The shape of the clip is modified
when a transformation is applied to the object.setClip(java.awt.Shape)public void setAlpha(float alpha)
If the containers of the graphic object (manager layer, graphic set) have their own alpha value, the object draws with a composed alpha value.
The default value is 1.
alpha - The new transparency level in the range [0.0, 1.0].getAlpha(),
IlvManagerLayer.setAlpha(float)public float getAlpha()
setAlpha(float),
IlvManagerLayer.getAlpha()public void draw(Graphics dst, IlvTransformer t)
draw in class IlvGraphicdst - The destination Graphics instance.t - The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicprotected Paint adaptPaint(Shape shape, Paint paint)
Paint object that will fit the shape parameter
according to the initial paint parameter.
This method is called only if isPaintAbsolute() returns
false.
By default, it deals with GradientPaint and
TexturePaint instances to adapt them correctly because they
do not automatically fit the shape of the object on which they are drawn.
You can override this method to manage your own Paint
subclasses if they do not take the shape of the object into account. You
will generally call the superclass method for GradientPaint
and TexturePaint instances.
Other Paint objects deriving from
IlvMultipleGradientPaint automatically take into
account the shape of the object if their
IlvMultipleGradientPaint.isAdapting() method
returns true and thus are not modified by this method.shape - The shape parameter that the returned Paint
should fit.paint - The initial Paint object.isPaintAbsolute()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.isContainsWhenNotFilled()public IlvRect boundingBox(IlvTransformer t)
calcBoundingBox(ilog.views.IlvTransformer)
to recalculate the bounding box.boundingBox in interface IlvPolyPointsInterfaceboundingBox in class IlvGraphict - The transformer used to draw the object.getShapeBounds(IlvTransformer)protected IlvRect calcBoundingBox(IlvTransformer t)
boundingBox(ilog.views.IlvTransformer) if the current bounding
box is not cached.t - The transformer used to draw the object.getShapeBounds(IlvTransformer)public IlvRect getShapeBounds(IlvTransformer t)
Shape
of the object.t - The transformer used to draw the object.boundingBox(IlvTransformer)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 works precise if the stroke is off or if the stroke is a basic stroke with small stroke size. If the stroke is not a basic stroke, the stroke width cannot be determined and a stroke width 0 is assumed.
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 moveResize(IlvRect rect)
IlvRect parameter.
This method calls the applyTransform(ilog.views.IlvTransformer) method.moveResize in class IlvGraphicrect - The new bounding rectangle of the object.setShapeBounds(ilog.views.IlvRect)public void resize(double neww,
double newh)
neww, newh).
This method calls the applyTransform method.resize in class IlvGraphicneww - The new horizontal width.newh - The new horizontal height.IlvGraphic,
IlvGraphic.applyTransform(IlvTransformer)public void setShapeBounds(IlvRect rect)
Shape
of the object.
The method sets the bounding rectangle of the shape
to the IlvRect parameter.
This method calls the applyTransform(ilog.views.IlvTransformer) method.rect - The new bounding rectangle of the shape of the object.moveResize(ilog.views.IlvRect)public void applyTransform(IlvTransformer t)
applyTransform in class IlvGraphict - The transformer to be applied.setClip(java.awt.Shape)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 IlvPersistentObjectwrite in class IlvGraphicstream - The output stream.IOException - thrown when an exception occurs during
the write operation for this object.public IlvGraphic copy()
copy in class IlvGraphicIlvGeneralPath.IlvGraphicpublic boolean isPointEditionAllowed()
true if it is allowed to move, insert, or remove a
point of the IlvGeneralPath.
The default value is true except for an
IlvGeneralPath created
with java.awt.geom.RectangularShape.
This value can be changed with setPointEditionAllowed.setPointEditionAllowed(boolean),
allowsPointInsertion(),
allowsPointRemoval(),
allowsPointMove(int)public void setPointEditionAllowed(boolean set)
isPointEditionAllowed().isPointEditionAllowed()public IlvSelection makeSelection()
IlvGeneralPath
instance.
The default implementation creates an instance of
IlvPolyPointsSelection
if the object is in allow move point mode.
In other cases it returns an instance of
IlvReshapeSelection.makeSelection in class IlvGraphicisPointEditionAllowed(),
IlvPolyPointsSelectionpublic boolean allowsPointInsertion()
true if isPointEditionAllowed
returns true and
false otherwise.allowsPointInsertion in interface IlvPolyPointsInterfaceisPointEditionAllowed(),
insertPoint(int, double, double, ilog.views.IlvTransformer)public boolean allowsPointRemoval()
true if isPointEditionAllowed
returns true and
false otherwise.allowsPointRemoval in interface IlvPolyPointsInterfaceisPointEditionAllowed(),
removePoint(int, ilog.views.IlvTransformer)public boolean allowsPointMove(int index)
true ifisPointEditionAllowed
returns true and
false otherwise.allowsPointMove in interface IlvPolyPointsInterfaceindex - The index of the point.isPointEditionAllowed(),
movePoint(int, double, double, ilog.views.IlvTransformer)public IlvPoint getPointAt(int index, IlvTransformer t)
getPointAt in interface IlvPolyPointsInterfaceindex - The index.t - The transformer used to draw the object.public int getPointsCardinal()
IlvGeneralPath.getPointsCardinal in interface IlvPolyPointsInterfacepublic void insertPoint(int index,
double x,
double y,
IlvTransformer t)
IlvGeneralPath if
allowsPointInsertion returns true.insertPoint in interface IlvPolyPointsInterfaceindex - The index where to insert the point.x - The x location.y - The y location.t - The transformer used to draw the object.
Note that the x, y coordinates are not transformed by the transformer.allowsPointInsertion()public void movePoint(int index,
double x,
double y,
IlvTransformer t)
isPointEditionAllowed
returns true.movePoint in interface IlvPolyPointsInterfaceindex - The index of the point to be moved.x - The new x location.y - The new y location.t - The transformer used to draw the object.
Note that the x, y coordinates are not transformed by the transformer.isPointEditionAllowed()public boolean pointsInBBox()
false since all points are
not contained inside
the bounding rectangle of the object.pointsInBBox in interface IlvPolyPointsInterfacepublic void removePoint(int index,
IlvTransformer t)
IlvGeneralPath if
allowsPointRemoval returns true.removePoint in interface IlvPolyPointsInterfaceindex - The index of the point to be removed.t - The transformer used to draw the object.isPointEditionAllowed()public void setTransformedShapeMode(boolean transformedShapeMode)
setShape(java.awt.Shape)
receives a shape in a coordinate system independent from the current
position.
That is, the shape is automatically transformed according to the
current position of the object.
If the transformed shape mode is disabled, the method setShape(java.awt.Shape)
receives a shape in a coordinate system dependent from the current
position.
The difference is visible if you set a shape after moving the node:
IlvGeneralPath gp = new IlvGeneralPath(shape); gp.move(100,100); gp.setShape(shape);In transformed shape mode, resetting the original shape does not move the node back to the original position. In untransformed mode, it moves the node back to the original position.
Note that the method getShape() always returns the transformed
shape in the coordinate system dependent from the current position.
That is, the following statement affects the shape in transformed
shape mode, while it has no effect in untransformed shape mode:
gp.setShape(gp.getShape());The same observation about the shape holds also for the clip (see
setClip(java.awt.Shape)).
If IlvGeneralPath is specified by CSS, it is recommended
to use the transformed shape mode.
transformedShapeMode - If true, the transformer shape
mode is enabled.isTransformedShapeMode()public boolean isTransformedShapeMode()
true if the object is in transformed shape mode.setTransformedShapeMode(boolean)public IlvTransformer getApplyTransformer()
applyTransform(ilog.views.IlvTransformer) since the shape of the general path
was set. It can return null to represent the identity
transform.getOriginalShape()public Shape getOriginalShape()
setShape(java.awt.Shape).
The relationship between the original shape and the current shape
can as approximation be described by the following formula
(which is not legal Java code, but just a sketch):
getShape() == getApplyTransformer().apply(getOriginalShape());You should not modify the shape of the object directly. If you need to change the shape of the object, use the
setShape method.setShape(java.awt.Shape)© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.