ilog.views.swing
Class IlvJComponentGraphic

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.swing.IlvJComponentGraphic
All Implemented Interfaces:
IlvPersistentObject, Transferable, Serializable

public class IlvJComponentGraphic
extends IlvGraphic

IlvJComponentGraphic is used to add Swing JComponent objects to an IlvManager instance.

Overview

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.

Example

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:

Limitations

The following limitations apply with this class:

About Graphic Objects

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.

Since:
JViews 5.0
See Also:
IlvManager, IlvManagerView, Serialized Form

Nested Class Summary
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.
 
Field Summary
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 Summary
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.
 
Method Summary
 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.
 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.
 int getResizeComponentMode()
          Returns the component-resizing mode of 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.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, contains, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, isVisible, makeSelection, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setForeground, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, write, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESIZE_COMPONENT_NEVER

public static final 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. When the IlvJComponentGraphic object is subsequently resized or shown in a magnifying view, it will be rendered through proportional zoom.

Since:
JViews 8.1
See Also:
setResizeComponentMode(int), Constant Field Values

RESIZE_COMPONENT_ON_RESHAPE

public static final 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. Still, when the IlvJComponentGraphic object is subsequently shown in a magnifying view, it will be rendered through proportional zoom.

Since:
JViews 8.1
See Also:
setResizeComponentMode(int), Constant Field Values

RESIZE_COMPONENT_ON_ZOOM

public static final 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. In this mode, proportional zoom is not normally used for rendering the component (except during printing).

Since:
JViews 8.1
See Also:
setResizeComponentMode(int), Constant Field Values
Constructor Detail

IlvJComponentGraphic

public 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.

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.


IlvJComponentGraphic

public IlvJComponentGraphic(IlvJComponentGraphic source)
The copy constructor.

Method Detail

getComponent

public final JComponent getComponent()
Returns the JComponent that is displayed by the IlvJComponentGraphic.


setComponent

public void setComponent(JComponent component)
Replaces the JComponent that is displayed by this IlvJComponentGraphic.

Since:
JViews 8.1

getAdditionalOptions

public IlvJComponentGraphic.AdditionalOptions getAdditionalOptions()
Returns the additional options to configure the component. Returns null if there are no additional options.

Since:
JViews 8.0

setAdditionalOptions

public void setAdditionalOptions(IlvJComponentGraphic.AdditionalOptions options)
Sets the additional options to configure the component.

Since:
JViews 8.0

getComboBoxOptions

public IlvJComponentGraphic.ComboBoxOptions getComboBoxOptions()
Returns the additional options to configure the combo box component. This assumes that the Swing component handled by this graphic object is a JComboBox. Returns null if the Swing component is not a combo box.

Since:
JViews 8.0

setZoomLimit

public void setZoomLimit(double limit)
Specifies the zoom factor limit. When the zoom factor applied to the initial JComponent is less than this value, the IlvJComponentGraphic is displayed as a filled rectangle. The default value is 0.1.


getZoomLimit

public final double getZoomLimit()
Returns the zoom factor limit.

See Also:
setZoomLimit(double)

setResizeComponentMode

public void setResizeComponentMode(int resizeComponentMode)
Determines when the encapsulated 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.

Parameters:
resizeComponentMode - One of RESIZE_COMPONENT_NEVER, RESIZE_COMPONENT_ON_RESHAPE, RESIZE_COMPONENT_ON_ZOOM.
Since:
JViews 8.1

getResizeComponentMode

public final int getResizeComponentMode()
Returns the component-resizing mode of this graphic object.

Since:
JViews 8.1
See Also:
setResizeComponentMode(int)

setActive

public void setActive(boolean active)
Sets whether the 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.

Since:
JViews 8.0
See Also:
isActive()

isActive

public final boolean isActive()
Returns true if the JComponent is active. In this case, the component receives events and can react on interaction.

Since:
JViews 8.0
See Also:
setActive(boolean)

setGraphicBag

public void setGraphicBag(IlvGraphicBag newbag)
Sets the 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.

Overrides:
setGraphicBag in class IlvGraphic
Parameters:
newbag - The graphic bag to contain this graphic object.
See Also:
IlvGraphic.setGraphicBag(ilog.views.IlvGraphicBag)

ensureJComponentsPrintable

public 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.

Note: The JComponentss are not necessarily immediately printable; they are made printable through an invokeLater that is posted to the AWT/Swing thread.

Since:
JViews 8.1

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the JComponent on a Graphics for a given IlvTransformer.

Specified by:
draw in class IlvGraphic
Parameters:
dst - The destination Graphics.
t - The transformation used to draw the object.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)

copy

public IlvGraphic copy()
Returns a copy of the IlvJComponentGraphic.

Specified by:
copy in class IlvGraphic
Returns:
A copy of this IlvGraphic instance.
See Also:
IlvGraphic.copy()

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Computes the boundingBox of the IlvJComponentGraphic.

Specified by:
boundingBox in class IlvGraphic
Parameters:
t - The transformer used to draw the object. If the transformer is null, the bounding box for the identity transformer is returned.
See Also:
IlvGraphic.boundingBox(IlvTransformer)

applyTransform

public void applyTransform(IlvTransformer t)
Applies an IlvTransformer to the IlvJComponentGraphic.

Specified by:
applyTransform in class IlvGraphic
Parameters:
t - The transformation to be applied.
See Also:
IlvGraphic.applyTransform(ilog.views.IlvTransformer)

isPersistent

public boolean isPersistent()
If this method returns true the IlvGraphic instance will be saved in IVL files.

This method always returns false for IlvJComponentGraphic.

Overrides:
isPersistent in class IlvGraphic
Returns:
Whether the IlvGraphic is persistent or not.
Since:
JViews 6.0


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.