public class IlvComponentGraphic extends IlvGraphic
IlvComponentGraphic
is used to mix graphic objects and
lightweight Java Component
s. A lightweight component is a
component that is written entirely in Java, that is, it is not associated
with a native peer.
Notes
IlvJComponentGraphic
and not IlvComponentGraphic
to add Java Swing components to
your custom application.Component
does
not support IlvBlinkingColor
or IlvBlinkingPaint
when
it is encapsulated in a IlvComponentGraphic
.
The following code example shows how to use an
IlvComponentGraphic
to include a lightweight component in a
simple Java application:
public class RoundButton extends Component { public RoundButton() { this.setSize(new Dimension(50,50)); } public void paint(Graphics g) { int s = Math.min(getSize().width - 1, getSize().height - 1); g.setColor(getBackground()); g.fillArc(0, 0, s, s, 0, 360); // draw the perimeter of the button g.setColor(getBackground().darker().darker().darker()); g.drawArc(0, 0, s, s, 0, 360); } } public class myCustomApp { ... public static void main(String[] args) { IlvManager manager = new IlvManager(); IlvManagerView view = new IlvManagerView(manager); view.setBackground(Color.WHITE); // Creates the component graphic RoundButton myButton = new RoundButton(); IlvComponentGraphic compGraphic = new IlvComponentGraphic(new IlvRect(5,5,100,100), myButton, view); ... } }
The following image shows the graphic objects created in the code example:
IlvComponentGraphic
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.
IlvJComponentGraphic
,
IlvManager
,
IlvManagerView
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected IlvRect |
drawrect
The bounding rectangle of the object.
|
Constructor and Description |
---|
IlvComponentGraphic(IlvRect rect,
Component component,
IlvManagerView v)
Creates a new component graphic for a specified component.
|
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.
|
IlvGraphic |
copy()
Copies the object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the object by calling the
paint method
of the component. |
Component |
getComponent()
Returns the component.
|
boolean |
isPersistent()
If this method returns
true , the IlvGraphic
instance will be saved in IVL files. |
void |
setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object.
|
void |
setView(IlvManagerView v)
Adds the component to a manager view.
|
addActionListener, addNamedPropertyListener, allViewsRemoved, baseTextDirectionChanged, blinkingStateOn, boundingBox, callDraw, componentOrientationChanged, contains, 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, isSelectable, isVisible, localeChanged, makeSelection, 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, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved, write, zoomable
protected final IlvRect drawrect
public IlvComponentGraphic(IlvRect rect, Component component, IlvManagerView v)
rect
- The rectangle defining the size of the component.component
- The component.v
- The manager view where the component will be added.
It can be null
: the component must then be added
later to a manager view with the setView
method.public void setView(IlvManagerView v)
v
- The manager view where the component will be added.
It can be null
to remove the component from its view.public void setGraphicBag(IlvGraphicBag bag)
setGraphicBag
in class IlvGraphic
bag
- The graphic bag.IlvGraphic
public Component getComponent()
public IlvGraphic copy()
copy
in class IlvGraphic
null
; this object cannot be copied.IlvGraphic
public void draw(Graphics dst, IlvTransformer t)
paint
method
of the component.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 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)
applyTransform
in class IlvGraphic
t
- The transformer to be applied.IlvGraphic
public boolean isPersistent()
true
, the IlvGraphic
instance will be saved in IVL files.
This method always returns false
for IlvComponentGraphic
.isPersistent
in class IlvGraphic
IlvGraphic
is persistent or not.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.