public class IlvJComponentGraphic extends IlvGraphic
IlvJComponentGraphic is used to add Swing
JComponent objects to an IlvManager instance.
Instances of JComponent and its subcomponents are modified to
remove their Swing double-buffering when the
IlvJComponentGraphic holding them is added to an
IlvManager. Each JComponent in an
IlvJComponentGraphic is displayed in all
IlvManagerView instances associated with its manager.
The current transformation is correctly applied to all objects.
Note: use
IlvComponentGraphic
and not IlvJComponentGraphic to add AWT components to your
custom application.
The following code example shows how to use an
IlvJComponentGraphic to include a Swing component in a simple
Java application:
IlvManager manager = new IlvManager();
JTextArea text =
new JTextArea("you can type a message here");
JScrollPane sPane = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
IlvManagerView view = new IlvManagerView(manager);
IlvJComponentGraphic wrapper = new IlvJComponentGraphic(
new IlvRect(20, 20, 200, 100), sPane);
wrapper.resize(150, 70);
manager.addObject(wrapper, true);
The following image shows the graphic object created in the code example:
The following limitations apply with this class:
IlvJComponentGraphic graphic object cannot be saved to an IVL
file. This is because it references an external JComponent.IlvJComponentGraphic instance can only be used in a
graphic bag instances that implement
GraphicBagHierarchyEventReceiver. For example it
cannot be used in an IlvGraphicHandle.
JComponent can be embedded into
several instances of IlvJComponentGraphic but cannot be added
to both an IlvJComponentGraphic and a regular Swing container
such as JFrame.JComboBox can be embedded into only
one instance of IlvJComponentGraphic.
IlvJComponentGraphic is not recommended, since the
interactions may not work.
JComponent
objects can be fully functional only in the first manager view attached
to the manager if the views do not share the same top level window of frame.
This is a limitation of the Microsoft user interface; other user interfaces
do not have this limitation.
IlvJComponentGraphic
embedded complex Swing components can affect performances.
IlvBlinkingColor
or IlvBlinkingPaint when
it is encapsulated in a IlvJComponentGraphic.
IlvJComponentGraphic 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.
IlvManager,
IlvManagerView,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
IlvJComponentGraphic.AdditionalOptions
Base class for additional options for specific components.
|
static class |
IlvJComponentGraphic.ComboBoxOptions
Additional options if the Swing component is a combo box.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
RESIZE_COMPONENT_NEVER
The component-resizing mode that specifies that the encapsulated
JComponent is not resized, except during this class
constructor and during the setComponent(javax.swing.JComponent) method. |
static int |
RESIZE_COMPONENT_ON_RESHAPE
The component-resizing mode that specifies that the encapsulated
JComponent is resized every time this graphic object is
reshaped or resized. |
static int |
RESIZE_COMPONENT_ON_ZOOM
The component-resizing mode that specifies that the encapsulated
JComponent is resized during the drawing, according to
the zoom level. |
| Constructor and Description |
|---|
IlvJComponentGraphic(IlvJComponentGraphic source)
The copy constructor.
|
IlvJComponentGraphic(IlvRect rect,
JComponent component)
Constructs and initializes an
IlvJComponentGraphic
instance that allows to display in an IlvManagerView
a Swing JComponent handled by an IlvManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyTransform(IlvTransformer t)
Applies an
IlvTransformer to the
IlvJComponentGraphic. |
IlvRect |
boundingBox(IlvTransformer t)
Computes the boundingBox of the
IlvJComponentGraphic. |
IlvGraphic |
copy()
Returns a copy of the
IlvJComponentGraphic. |
void |
draw(Graphics dst,
IlvTransformer t)
Draws the
JComponent on a Graphics for a given
IlvTransformer. |
static void |
ensureJComponentsPrintable(IlvManagerView view)
Ensures that all the
JComponents belonging to
IlvJComponentGraphic instances in the given manager view
have AWT peers and are therefore printable. |
protected void |
finalize()
Does the necessary operation when the
object is garbage collected.
|
IlvJComponentGraphic.AdditionalOptions |
getAdditionalOptions()
Returns the additional options to configure the component.
|
IlvJComponentGraphic.ComboBoxOptions |
getComboBoxOptions()
Returns the additional options to configure the combo box component.
|
JComponent |
getComponent()
Returns the
JComponent that is displayed by the
IlvJComponentGraphic. |
static IlvManagerView |
getContainingView(Component comp)
Returns the
IlvManagerView in which a given
JComponent is visible through an intermediate
IlvJComponentGraphic, or null if there is none. |
int |
getResizeComponentMode()
Returns the component-resizing mode of this graphic object.
|
String |
getToolTipText()
Returns the tooltip set for this graphic object.
|
double |
getZoomLimit()
Returns the zoom factor limit.
|
boolean |
isActive()
Returns
true if the JComponent is active. |
boolean |
isPersistent()
If this method returns
true the IlvGraphic
instance will be saved in IVL files. |
void |
setActive(boolean active)
Sets whether the
JComponent is active. |
void |
setAdditionalOptions(IlvJComponentGraphic.AdditionalOptions options)
Sets the additional options to configure the component.
|
void |
setComponent(JComponent component)
Replaces the
JComponent that is displayed by this
IlvJComponentGraphic. |
void |
setGraphicBag(IlvGraphicBag newbag)
Sets the
IlvGraphicBag. |
void |
setResizeComponentMode(int resizeComponentMode)
Determines when the encapsulated
JComponent is resized. |
void |
setZoomLimit(double limit)
Specifies the zoom factor limit.
|
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, 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, zoomablepublic static final int RESIZE_COMPONENT_NEVER
JComponent is not resized, except during this class
constructor and during the setComponent(javax.swing.JComponent) method. When
the IlvJComponentGraphic object is subsequently
resized or shown in a magnifying view, it will be rendered
through proportional zoom.setResizeComponentMode(int),
Constant Field Valuespublic static final int RESIZE_COMPONENT_ON_RESHAPE
JComponent is resized every time this graphic object is
reshaped or resized. Still, when the IlvJComponentGraphic
object is subsequently shown in a magnifying view, it will be rendered
through proportional zoom.setResizeComponentMode(int),
Constant Field Valuespublic static final int RESIZE_COMPONENT_ON_ZOOM
JComponent is resized during the drawing, according to
the zoom level. In this mode, proportional zoom is not normally used for
rendering the component (except during printing).setResizeComponentMode(int),
Constant Field Valuespublic IlvJComponentGraphic(IlvRect rect, JComponent component)
IlvJComponentGraphic
instance that allows to display in an IlvManagerView
a Swing JComponent handled by an IlvManager.
This component will follow the transformations of the views.
If rect is null, the
IlvJComponentGraphic will have the preferred size
of the JComponent and will be placed at (0,0).
For information about the limitations of IlvJComponentGraphic,
refer to the documentation of this class.
public IlvJComponentGraphic(IlvJComponentGraphic source)
public final JComponent getComponent()
JComponent that is displayed by the
IlvJComponentGraphic.public void setComponent(JComponent component)
JComponent that is displayed by this
IlvJComponentGraphic.public String getToolTipText()
getToolTipText in class IlvGraphicnull if the tooltip has not been set.IlvGraphic.setToolTipText(String),
IlvGraphic.getToolTipText(IlvPoint, IlvTransformer),
IlvGraphicpublic IlvJComponentGraphic.AdditionalOptions getAdditionalOptions()
null if there are no additional options.public void setAdditionalOptions(IlvJComponentGraphic.AdditionalOptions options)
public IlvJComponentGraphic.ComboBoxOptions getComboBoxOptions()
JComboBox.
Returns null if the Swing component is not a combo box.public void setZoomLimit(double limit)
JComponent is less
than this value,
the IlvJComponentGraphic is displayed as a filled rectangle.
The default value is 0.1.public final double getZoomLimit()
setZoomLimit(double)public void setResizeComponentMode(int resizeComponentMode)
JComponent is resized.
If resizeComponentMode is
RESIZE_COMPONENT_NEVER, a proportional zoom will be used for
drawing the component in all cases.
If resizeComponentMode is
RESIZE_COMPONENT_ON_RESHAPE, proportional zoom will be used
only on behalf of a magnifying view or for printing.
If resizeComponentMode is
RESIZE_COMPONENT_ON_ZOOM, proportional zoom will normally not
be used.resizeComponentMode - One of RESIZE_COMPONENT_NEVER,
RESIZE_COMPONENT_ON_RESHAPE,
RESIZE_COMPONENT_ON_ZOOM.public final int getResizeComponentMode()
setResizeComponentMode(int)public void setActive(boolean active)
JComponent is active.
An active component receives events and can react on interaction.
An inactive component does not receive any events, regardless whether
it is enabled or not. It is only displayed.
For some Swing components, it is useful to make them inactive while they are moved by the select interactor.
By default, the component is active.
isActive()public final boolean isActive()
true if the JComponent is active.
In this case, the component receives events and can react on interaction.setActive(boolean)public void setGraphicBag(IlvGraphicBag newbag)
IlvGraphicBag. An IlvJComponentGraphic
can be added only to a top-level IlvManager.
You should not call this method directly unless you are creating a new type of bag.
setGraphicBag in class IlvGraphicnewbag - The graphic bag to contain this graphic object.IlvGraphic.setGraphicBag(ilog.views.IlvGraphicBag)public static IlvManagerView getContainingView(Component comp)
IlvManagerView in which a given
JComponent is visible through an intermediate
IlvJComponentGraphic, or null if there is none.public static void ensureJComponentsPrintable(IlvManagerView view)
JComponents belonging to
IlvJComponentGraphic instances in the given manager view
have AWT peers and are therefore printable.
Note: The JComponentss are not necessarily immediately
printable; they are made printable through an invokeLater
that is posted to the AWT/Swing thread.
public void draw(Graphics dst, IlvTransformer t)
JComponent on a Graphics for a given
IlvTransformer.draw in class IlvGraphicdst - The destination Graphics instance.t - The transformation used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)public IlvGraphic copy()
IlvJComponentGraphic.copy in class IlvGraphicIlvGraphic instance.IlvGraphic.copy()public IlvRect boundingBox(IlvTransformer t)
IlvJComponentGraphic.boundingBox in class IlvGraphict - The transformer used to draw the object. If the
transformer is null, the bounding box for the
identity transformer is returned.IlvGraphic.boundingBox(IlvTransformer)public void applyTransform(IlvTransformer t)
IlvTransformer to the
IlvJComponentGraphic.applyTransform in class IlvGraphict - The transformation to be applied.IlvGraphic.applyTransform(ilog.views.IlvTransformer)public boolean isPersistent()
true the IlvGraphic
instance will be saved in IVL files.
This method always returns false for
IlvJComponentGraphic.
isPersistent in class IlvGraphicIlvGraphic is persistent or not.© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.