public class IlvDiamond extends IlvGraphic
IlvDiamond
represents a
diamond shape. This class is designed to be used with an
IlvCompositeGraphic
instance.
The default values for an IlvDiamond
instance are as
follows:
Color.black
Color.black
BasicStroke(1)
false
50
50
The following code example shows how to use IlvDiamond
in a
simple Java application:
// Creates the grapher to hold the composite graphic IlvGrapher grapher = new IlvGrapher(); // Creates the composite graphic with an IlvAttachmentLayout layout IlvCompositeGraphic composite = new IlvCompositeGraphic(); IlvAttachmentLayout attLayout = new IlvAttachmentLayout(); composite.setLayout(attLayout); IlvDiamond diamond = new IlvDiamond(new IlvRect(5,5,80,130)); diamond.setFillOn(true); diamond.setBackground(Color.red); diamond.setForeground(Color.blue); diamond.setStroke(new BasicStroke(4)); composite.setChildren(0,diamond); IlvText text = new IlvText(new IlvPoint(10,10),"IlvDiamond"); composite.setChildren(1,text); //Attach the top center point of the text object to the bottom center //point of the diamond. composite.setConstraints(1, new IlvAttachmentConstraint(IlvAttachmentLocation.TopCenter, IlvAttachmentLocation.BottomCenter)); grapher.addNode(composite,true);
The following image shows the graphic objects created in the code example:
>
IlvDiamond
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 |
---|
IlvDiamond()
Default bean constructor.
|
IlvDiamond(IlvDiamond source)
Creates a new
IlvDiamond by copying an existing one. |
IlvDiamond(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvDiamond(IlvRect definitionRect)
Creates an
IlvDiamond with its size defined by the supplied rectangle. |
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 box of this
IlvDiamond |
boolean |
contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the shape.
|
IlvGraphic |
copy()
Copies this object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws this object.
|
Color |
getBackground()
Returns the background color of this object.
|
IlvRect |
getDefinitionRect()
Returns the rectangle that provides the bounds of the diamond.
|
Color |
getForeground()
Returns the foreground color of this object.
|
double |
getHeight()
Returns the height of this diamond.
|
Stroke |
getStroke()
Returns the stroke object used to stroke
the shape.
|
double |
getWidth()
Returns the width of this diamond.
|
boolean |
isFillOn()
Returns
true if the inside of the
ellipse will be filled. |
void |
setBackground(Color c)
Changes the background color of this object.
|
void |
setFillOn(boolean set)
If
true , specifies that the inside of the
ellipse will be filled. |
void |
setForeground(Color c)
Changes the foreground color of this object.
|
void |
setHeight(double h)
Sets the height of this diamond
|
void |
setStroke(Stroke stroke)
Changes the stroke object used to stroke
the shape.
|
void |
setWidth(double w)
Sets the width of this diamond.
|
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, getIntersectionWithOutline, 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, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomable
public IlvDiamond()
IlvDiamond
with the default values.public IlvDiamond(IlvRect definitionRect)
IlvDiamond
with its size defined by the supplied rectangle.public IlvDiamond(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- The input stream.IlvReadFileException
- if the format is not correct.public IlvDiamond(IlvDiamond source)
IlvDiamond
by copying an existing one.public void applyTransform(IlvTransformer t)
Note that the method must never be called with a null
argument.
applyTransform
in class IlvGraphic
t
- The transformer to be applied.IlvGraphic
public IlvRect boundingBox(IlvTransformer t)
IlvDiamond
boundingBox
in class IlvGraphic
t
- The transformer used to draw the object. The value
null
can be used for the identity transformer.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
contains
in class IlvGraphic
p
- 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 IlvGraphic copy()
copy
in class IlvGraphic
IlvGraphic
public void draw(Graphics dst, IlvTransformer t)
draw
in class IlvGraphic
dst
- The destination Graphics
instance.t
- The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer)
,
IlvGraphic.boundingBox(IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public void setForeground(Color c)
IlvBlinkingColor
.setForeground
in class IlvGraphic
c
- The new color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setBackground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getForeground()
public void setBackground(Color c)
IlvBlinkingColor
.setBackground
in class IlvGraphic
c
- The new color.setFillOn(boolean)
,
isFillOn()
public Color getBackground()
setFillOn(boolean)
,
isFillOn()
public boolean isFillOn()
true
if the inside of the
ellipse will be filled.setFillOn(boolean)
public void setFillOn(boolean set)
true
, specifies that the inside of the
ellipse will be filled.setFillOn
in class IlvGraphic
set
- Set to true
to enable the fill style for this
graphic object.isFillOn()
public IlvRect getDefinitionRect()
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.getStroke()
public Stroke getStroke()
null
if there is
no stroke specified.setStroke(java.awt.Stroke)
public void setWidth(double w)
public double getWidth()
public void setHeight(double h)
public double getHeight()
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.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.