public class IlvRectangle extends IlvGraphic
IlvRectangle
represents a rectangle with customizable fill
and stroke. You can set the corners to be rounded or square.
The default values for an IlvRectangle
instance are as
follows:
Color.black
Color.black
false
true
IlvRect(0, 0, 100, 100)
IlvRectangle.ALL_CORNERS
The following code example shows how to use an IlvRectangle
in a
simple Java application:
IlvManager manager = new IlvManager(); IlvRectangle myDefaultRect = new IlvRectangle(); IlvRectangle myCustomRect = new IlvRectangle(new IlvRect(120,100,80,20), true, true); myCustomRect.setForeground(Color.black); myCustomRect.setBackground(Color.green); int topCorners = IlvRectangle.TOP_LEFT|IlvRectangle.TOP_RIGHT; myCustomRect.setCorners(topCorners); manager.addObject( myDefaultRect, true); manager.addObject( myCustomRect, true);
The following image shows the graphic objects created in the code example:
IlvRectangle
is a custom graphic object, that is, a subclass of
IlvGraphic
. Graphic objects are controlled using an
IlvManager
instance and displayed using one or more
IlvManagerView
instances in a Java Swing application.
For information about generic features for graphic objects, see
IlvGraphic.
IlvPoint
,
IlvManager
,
IlvManagerView
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
BOTTOM_LEFT
Defines the bottom left corner.
|
static int |
BOTTOM_RIGHT
Defines the bottom right corner.
|
protected IlvRect |
drawrect
The definition rectangle of the object.
|
static int |
TOP_LEFT
Defines the top left corner.
|
static int |
TOP_RIGHT
Defines the top right corner.
|
Constructor and Description |
---|
IlvRectangle()
Creates a new
IlvRectangle with a definition rectangle of
(0, 0, 100, 100) |
IlvRectangle(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvRectangle(IlvRect rect)
Creates a new
IlvRectangle . |
IlvRectangle(IlvRectangle source)
Creates a new
IlvRectangle by copying an existing one. |
IlvRectangle(IlvRect rect,
boolean outlined,
boolean filled)
Creates a new
IlvRectangle . |
IlvRectangle(IlvRect rect,
boolean outlined,
boolean filled,
int radius)
Creates a new
IlvRectangle with rounded corners. |
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 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
IlvRectangle . |
int |
getCorners()
Returns which corners of the rectangle are rounded if
getRadius()
is not 0 . |
IlvRect |
getDefinitionRect()
Returns a copy of the definition rectangle.
|
Color |
getForeground()
Returns the foreground color of the
IlvRectangle . |
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 |
getRadius()
Returns the radius.
|
boolean |
isCornersZoomable()
Returns
true if the radius of the rounded corners follows
the zoom level. |
boolean |
isFillOn()
Returns
true if the inside of the
rectangle will be filled. |
boolean |
isStrokeOn()
Returns
true if the
rectangle is stroked. |
void |
moveResize(IlvRect size)
Resizes the object.
|
void |
resize(double neww,
double newh)
Resizes the object.
|
void |
setBackground(Color color)
Changes the background color of the
IlvRectangle . |
void |
setCorners(int corners)
Sets which corners of the rectangle are rounded if
getRadius()
is not 0 . |
void |
setCornersZoomable(boolean set)
When set to
true , specifies that the radius of the rounded
corners follows the zoom level. |
void |
setDefinitionRect(IlvRect rect)
Sets the definition rectangle.
|
void |
setFillOn(boolean set)
If
true , specifies that the inside of the
rectangle will be filled. |
void |
setForeground(Color color)
Changes the foreground color of the
IlvRectangle . |
void |
setRadius(int radius)
Changes the radius.
|
void |
setStrokeOn(boolean set)
When set to
true , specifies that the
rectangle is stroked. |
void |
translate(double dx,
double dy)
Translates the object.
|
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, 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, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, zoomable
public static final int TOP_LEFT
setCorners(int)
,
Constant Field Valuespublic static final int BOTTOM_LEFT
setCorners(int)
,
Constant Field Valuespublic static final int TOP_RIGHT
setCorners(int)
,
Constant Field Valuespublic static final int BOTTOM_RIGHT
setCorners(int)
,
Constant Field Valuesprotected final IlvRect drawrect
public IlvRectangle()
IlvRectangle
with a definition rectangle of
(0, 0, 100, 100)
IlvRectangle(IlvRect)
public IlvRectangle(IlvRect rect)
IlvRectangle
. The IlvRectangle
is outlined but not filled.rect
- The definition rectangle of the object.public IlvRectangle(IlvRect rect, boolean outlined, boolean filled)
IlvRectangle
.rect
- The definition rectangle of the object.outlined
- true
if the rectangle has to be stroked.filled
- true
if the rectangle has to be filled.setStrokeOn(boolean)
,
setFillOn(boolean)
public IlvRectangle(IlvRect rect, boolean outlined, boolean filled, int radius)
IlvRectangle
with rounded corners.rect
- The definition rectangle of the object.outlined
- true
if the rectangle has to be stroked.filled
- true
if the rectangle has to be filled.radius
- The radius of the rectangle corners.setStrokeOn(boolean)
,
setFillOn(boolean)
,
setRadius(int)
public IlvRectangle(IlvRectangle source)
IlvRectangle
by copying an existing one.source
- The origin object for the copy.public IlvRectangle(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- The input stream.IlvReadFileException
- if the format is not correct.IlvReadFileException
public IlvGraphic copy()
copy
in class IlvGraphic
IlvGraphic
public final IlvRect getDefinitionRect()
public void setDefinitionRect(IlvRect rect)
moveResize(ilog.views.IlvRect)
.
This method is here to follow the Beaninfo naming standard.public void moveResize(IlvRect size)
IlvRect
parameter.
This method calls the setDefinitionRect
method.moveResize
in class IlvGraphic
size
- The new bounding rectangle of the object.IlvGraphic
,
IlvGraphic.applyTransform(IlvTransformer)
public void resize(double neww, double newh)
(neww, newh)
.resize
in class IlvGraphic
neww
- The new horizontal width.newh
- The new horizontal height.IlvGraphic
,
applyTransform(IlvTransformer)
public void translate(double dx, double dy)
translate
in class IlvGraphic
dx
- The horizontal translation factor.dy
- The vertical translation factor.IlvGraphic
,
IlvGraphic.applyTransform(IlvTransformer)
public void draw(Graphics dst, IlvTransformer t)
draw
in class IlvGraphic
dst
- The destination Graphics.t
- The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer)
,
IlvGraphic.boundingBox(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 IlvRect boundingBox(IlvTransformer t)
boundingBox
in class IlvGraphic
t
- The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
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 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 IlvGraphic
innerPoint
- 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.IlvClippingLinkConnector
public void setForeground(Color color)
IlvRectangle
. It is the
color used to draw the outline of the rectangle.
This property supports
IlvBlinkingColor
.setForeground
in class IlvGraphic
color
- The new foreground color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setBackground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getForeground()
IlvRectangle
.
It is the color used to draw the outline of the rectangle.public void setBackground(Color color)
IlvRectangle
. It is the
color used to fill the rectangle.
This property supports
IlvBlinkingColor
.setBackground
in class IlvGraphic
color
- The new background color.IlvGraphic.draw(Graphics, IlvTransformer)
,
IlvGraphic.setForeground(Color)
,
IlvGraphic.setFillOn(boolean)
,
IlvGraphic.setStrokeOn(boolean)
,
IlvGraphic
public Color getBackground()
IlvRectangle
. It is the
color used to fill the rectangle.public void setRadius(int radius)
radius
- The new radius.getRadius()
,
getCorners()
,
setCornersZoomable(boolean)
public int getRadius()
setRadius(int)
public boolean isFillOn()
true
if the inside of the
rectangle will be filled.setFillOn(boolean)
public void setFillOn(boolean set)
true
, specifies that the inside of the
rectangle will be filled.setFillOn
in class IlvGraphic
set
- Set to true
to enable the fill style for this
graphic object.isFillOn()
public boolean isStrokeOn()
true
if the
rectangle is stroked.setStrokeOn(boolean)
public void setStrokeOn(boolean set)
true
, specifies that the
rectangle is stroked.setStrokeOn
in class IlvGraphic
set
- Set to true
to enable the stroke in your
customized graphic object.isStrokeOn()
public int getCorners()
getRadius()
is not 0
. The default value is all the corners, that is, a combination
of all the possible values described below.TOP_LEFT
: top left corner.
TOP_RIGHT
: top right corner.
BOTTOM_RIGHT
: bottom right corner.
BOTTOM_LEFT
: bottom left corner.
setCorners(int)
public void setCorners(int corners)
getRadius()
is not 0
. The default value is all the corners, that is, a combination
of all the possible values described below.corners
- A combination of the following values:
TOP_LEFT
: top left corner.
TOP_RIGHT
: top right corner.
BOTTOM_RIGHT
: bottom right corner.
BOTTOM_LEFT
: bottom left corner.
getCorners()
,
setCornersZoomable(boolean)
,
setRadius(int)
public boolean isCornersZoomable()
true
if the radius of the rounded corners follows
the zoom level.setCornersZoomable(boolean)
public void setCornersZoomable(boolean set)
true
, specifies that the radius of the rounded
corners follows the zoom level.
The option has only an effect if a non-zero radius is
specified and some or all corners are rounded.
By default, the radius of the corners does not follow the zoom level.isCornersZoomable()
,
setCorners(int)
,
setRadius(int)
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.