|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
ilog.views.IlvManagerView
public class IlvManagerView
A manager view is a Java AWT component used to display the graphic objects contained in a manager.
A manager view is attached to a single manager at a time. However, each
manager can be connected to several views simultaneously. The manager to
which a view is attached is defined when you call the constructor; you
retrieve and change this manager by calling
setManager(IlvManager) and getManager().
Each manager view contains a geometric transformer which defines the
translation, the scaling and the rotation applied to the drawing of
the graphic objects in the manager attached to this view.
A transformer is defined by an IlvTransformer instance.
You modify the transformations associated with a view either by calling
setTransformer(IlvTransformer) or getTransformer()
to change the transformer, or by calling methods that change the transformer
for you. Examples of this are zoom(IlvPoint, double, double, boolean),
translate(float, float, boolean), fitTransformerToContent().
When KeepingAspectRatio is true, the view will
verify each modification of its transformer so that the zoom factor
remains the same along the x axis and the y axis.
The zoom level can be different on the x axis and on the y axis, for instance
in order to fit the content into a area of a given aspect ratio. If you need
to ensure the zoom level remains always the same along the two axis, use the
the method setKeepingAspectRatio(boolean).
The following code example shows how to use two manager view instances to display a manager in different ways.
IlvGraphic obj;
IlvManager manager = new IlvManager();
// Create new graphic objects and add them to the submanager.
// These graphic objects will be beneath the other objects.
obj = new IlvEllipse(new IlvRect(30, 10, 50, 50), true, false);
manager.addObject(obj, false);
// Add a new graphic object to layer 2 in the manager
obj = new IlvRectangle(new IlvRect(70,40,50,50), false, true);
manager.addObject(obj, 2, false);
// Add the manager to different views.
IlvManagerView viewOne = new IlvManagerView(manager);
IlvManagerView viewTwo = new IlvManagerView(manager);
viewOne.setBackground(Color.RED);
viewTwo.setBackground(Color.GREEN);
// Add a grid to viewOne
viewOne.setGrid(new IlvGrid());
// Zoom into viewTwo
viewTwo.zoom(new IlvPoint(50,70), 2, 2, true);
// Set all the graphic objects in layer 2 to be invisible
// for viewOne.
manager.setVisible(viewOne, 2, false, true);
JFrame frame = new JFrame("IlvManagerView");
frame.setLayout(new BorderLayout(2, 2));
JSplitPane splitPane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT, viewOne, viewTwo);
splitPane.setDividerLocation(140);
frame.getContentPane().add(splitPane);
frame.setSize(320, 200);
frame.setVisible(true);
The following image shows the two views created for a single manager in the code example:
Double buffering prevents the screen from flickering when many objects are
being manipulated. IlvManagerView is a lightweight Java
component and cannot manage double buffering on its own. To use double
buffering in a Swing application, just place your view in an
IlvJManagerViewPanel or
IlvJScrollManagerView.
Note that in a Swing application, it is not necessary to set
double buffering on (using setDoubleBuffering(boolean)), since
Swing already handles the double buffering of all components.
For AWT, non-Swing applications, place your view in an
IlvManagerViewPanel or
IlvScrollManagerView.
Using triple buffering, static background layers are drawn in an additional
off-screen image, and this image is used instead of redrawing the background
graphic objects to speed up your application. Triple buffering is activated
by calling setTripleBufferedLayerCount(int).
A view interactor processes AWT events and controls behavior that can be
applied to a view as a whole, that is, affecting all the objects contained
in the view. View interactors are subclasses of
IlvManagerViewInteractor
that are attached to the view. The following code example shows how to add a
zoom interactor:
IlvManager manager = new IlvManager();
IlvManagerView mgrview = new IlvManagerView(manager);
IlvZoomViewInteractor zoomInteractor;
zoomButton = new Button("Zoom In");
...
zoomButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (zoomInteractor == null)
zoomInteractor = new IlvZoomViewInteractor();
if (mgrview.getInteractor() != zoomInteractor)
mgrview.setInteractor(zoomInteractor);
}
});
Note: use setWheelZoomingEnabled(boolean)
to allow users to zoom in and out of a view using the mouse wheel. For
scrolling using the mouse wheel, encapsulate the manager view in a
IlvJScrollManagerView and
use its method
setWheelScrollingEnabled.
A manager view manages a stack of view interactors, only the
interactor on top of the interactor stack is active. Subclasses of
IlvManagerViewInteractor class allow you to perform different
tasks on the view. For example,
IlvZoomViewInteractor
allows the user to zoom to a rectangle dragged over the view using the mouse.
When the manager displayed by a view changes, the view fires a
ManagerChangedEvent. To handle
these events, a
ManagerChangedListener
implementation instance must be registered with this view by calling
addManagerChangedListener(ManagerChangedListener). To remove
this listener call
removeManagerChangedListener(ManagerChangedListener).
When the transformer of the view changes, the view fires a
TransformerChangedEvent
event. To handle these events a
TransformerListener
implementation instance must be registered with this view by calling
addTransformerListener(TransformerListener). To remove this
listener call removeTransformerListener(TransformerListener).
When the interactor of the view changes, the view fires a
InteractorChangedEvent
event. To handle these events a
InteractorListener
implementation instance must be registered with this view by calling
addInteractorListener(InteractorListener). To remove this
listener call removeInteractorListener(InteractorListener).
| Nested Class Summary | |
|---|---|
static interface |
IlvManagerView.FitAreaCalculator
This interface can be used to fit the transformer of the manager view so that a certain area of the manager is visible in the view. |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
DIRECT_REDRAW
Direct mode for redrawing of invalid regions. |
static int |
THREADED_REDRAW
Threaded mode for redrawing of invalid regions. |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
IlvManagerView()
Creates a new manager view. |
|
IlvManagerView(IlvManager manager)
Creates a new manager view to display the contents of the specified manager. |
|
IlvManagerView(IlvManager manager,
IlvTransformer t)
Creates a new manager view. |
|
| Method Summary | |
|---|---|
void |
addInteractorListener(InteractorListener l)
Adds the specified interactor listener to receive interactor changed events from the manager view when the interactor of the view is changed. |
void |
addManagerChangedListener(ManagerChangedListener listener)
Adds the specified listener to receive manager changed events from this manager view when the manager displayed by this view changes. |
void |
addNotify()
Notifies the manager view that it has been added to its parent. |
void |
addTransformer(IlvTransformer t)
Adds the transformer on the view (composes the existing transformer with the new one). |
void |
addTransformerListener(TransformerListener l)
Adds the specified transformer listener to receive transformer changed events when the transformer of this manager view changes. |
void |
addViewDecoration(IlvManagerViewDecoration decoration)
Adds a decoration to the view. |
IlvRect |
computeBBox()
Computes the rectangle that contains all the graphic objects of the manager of the view. |
IlvRect |
computeBBox(IlvTransformer t)
Computes the rectangle that contains all the graphic objects of the manager of the view, for a given transformer. |
void |
ensureVisible(IlvPoint point)
Modifies the transformer so that the specified point becomes visible. |
void |
ensureVisible(IlvRect r)
Modifies the transformer so that the specified rectangle becomes visible. |
void |
fitTransformerToArea(Insets insets,
IlvManagerView.FitAreaCalculator areaCalculator,
int maxNumberOfIterations)
Modifies the manager view transformer so that a specific area is visible in the view. |
void |
fitTransformerToContent()
Modifies the transformer of the manager view so that all objects are visible in the view. |
void |
fitTransformerToContent(Insets insets)
Modifies the manager view transformer so that all objects are visible in the view and specified margins are preserved. |
void |
fitTransformerToContent(Insets insets,
int maxNumberOfIterations)
Modifies the manager view transformer so that all objects are visible in the view, margins are preserved and a specified number of iterations is used for computing the optimal transformer. |
Image |
getBackgroundPattern()
Deprecated. use getBackgroundPatternLocation |
URL |
getBackgroundPatternLocation()
Returns the location of the background pattern of the view. |
Color |
getDefaultGhostColor()
Returns the default ghost color of the view. |
Color |
getDefaultXORColor()
Returns the default XOR color for the view. |
IlvGrid |
getGrid()
Returns the grid of the view. |
IlvManagerViewInteractor |
getInteractor()
Returns the interactor of the view, if any, or null otherwise. |
IlvManager |
getManager()
Returns the manager displayed by this view. |
Dimension |
getMaximumSize()
Returns the maximum size of the view. |
double |
getMaxZoomXFactor()
Returns the maximal zoom factor allowed for the view in the x direction. |
double |
getMaxZoomYFactor()
Returns the maximal zoom factor allowed for the view in the y direction. |
Dimension |
getMinimumSize()
Returns the minimum size of the view. |
double |
getMinZoomXFactor()
Returns the minimal zoom factor allowed for the view in the x direction. |
double |
getMinZoomYFactor()
Returns the minimal zoom factor allowed for the view in the y direction. |
protected JPopupMenu |
getPopupMenu(IlvGraphic obj,
IlvPoint p,
IlvPopupMenuManager popupManager)
Returns the Swing popup menu to be displayed when the popup is triggered at a specified location inside the manager view. |
JPopupMenu |
getPopupMenu(IlvPoint p,
IlvPopupMenuManager popupManager)
Returns the Swing popup menu to be displayed when the popup is triggered at a specified location inside the manager view. |
Dimension |
getPreferredSize()
Returns the preferred size of the view. |
int |
getRedrawMode()
Returns the way invalid regions of the view are redrawn. |
IlvRegion |
getRegion()
Returns the invalid region of the view. |
long |
getRepaintSkipThreshold()
Gets the minimum delay between repaint requests. |
IlvTransformer |
getTransformer()
Returns a copy of the transformer of the manager view. |
int |
getTripleBufferedLayerCount()
Returns the number of layers that are triple buffered. |
IlvManagerViewDecoration |
getViewDecoration(int index)
Returns the decoration installed on the view at the specified index. |
int |
getViewDecorationCount()
Returns the number of decorations added to the view. |
boolean |
imageUpdate(Image img,
int flags,
int x,
int y,
int w,
int h)
Repaints the component when the image has changed. |
static void |
initDisplayInfo()
Initializes the information about the display. |
protected void |
interactorChanged(IlvManagerViewInteractor current,
IlvManagerViewInteractor previous)
Called when the interactor of the view is changed, that is, each time an interactor is added or removed from the interactor stack. |
void |
invalidateRect(IlvRect rect)
Adds a rectangle to the invalid region of the view. |
void |
invalidateTripleBuffer(boolean repaint)
Invalidates the triple buffer. |
void |
invalidateTripleBuffer(IlvRect rect,
boolean repaint)
Invalidates partially the triple buffer. |
void |
invalidateView()
Invalidates the entire view. |
boolean |
isAntialiasing()
Returns true if the antialiasing mode
of the view is on. |
boolean |
isAtZoomXFactorLimit()
Returns true if the zoom factor of the view reached
the minimal or the maximal zoom factor limit in the x direction when
the transformer was changed. |
boolean |
isAtZoomYFactorLimit()
Returns true if the zoom factor of the view reached
the minimal or the maximal zoom factor limit in the y direction when
the transformer was changed. |
boolean |
isAutoFitToContents()
Returns true if the view is in autofit
mode. |
boolean |
isContributingToViewBBox(int layer)
Returns true if the specified layer is taken into account
when computing the bounding box of the view. |
boolean |
isDoubleBufferFrozen()
Returns true if the double buffer is frozen. |
boolean |
isDoubleBuffering()
Returns the double-buffering mode of the view. |
boolean |
isEventDispatching()
Returns true if AWT events
are dispatched to the listeners on the view and
to the subcomponents. |
boolean |
isInSwingParent()
Returns true if the IlvManagerView is used
in a Swing context (i.e its parent is a JComponent),
false otherwise. |
boolean |
isKeepingAspectRatio()
Returns true if the view keeps the aspect ratio;
otherwise it returns false. |
boolean |
isLayerCached(int layer)
Tells whether the specified layer is cached for this view. |
boolean |
isOptimizedTranslation()
Returns an indication of whether the translation of the manager view content is optimized or not. |
boolean |
isTransparent()
Returns true if the view is transparent. |
boolean |
isVisible(int layer)
Returns the visibility of the specified layer in the view. |
boolean |
isWheelZoomingEnabled()
Indicates whether or not zooming will take place in response to movement of the mouse wheel plus control key pressed. |
boolean |
isWheelZoomingInverted()
Returns true when mouse wheel zooming is inverted. |
protected void |
managerChanged(IlvManager oldManager,
IlvManager newManager)
This method is called by setManager as
notification that the manager displayed by this view has changed. |
void |
paint(Graphics g)
Paints the view. |
IlvManagerViewInteractor |
popInteractor()
Removes an interactor from the top of the interactor stack. |
protected void |
processEvent(AWTEvent evt)
Processes the events in the view. |
protected void |
processKeyEvent(KeyEvent event)
This method is overridden to forward key events that have not yet been consumed by the view interactor or registered KeyListeners to
this view's IlvJManagerViewPanel or IlvJScrollManagerView
parent. |
void |
pushInteractor(IlvManagerViewInteractor interactor)
Adds the specified interactor to the top of the interactor stack. |
void |
pushInteractor(IlvManagerViewInteractor interactor,
AWTEvent evt)
Adds the specified interactor to the top of the interactor stack. |
void |
reDrawViews()
Repaints the invalid region of the view. |
void |
removeAllInteractors()
Removes all the interactors from the view. |
void |
removeInteractorListener(InteractorListener l)
Removes the specified interactor listener so that it no longer receives interactor changed events from the manager view. |
void |
removeManagerChangedListener(ManagerChangedListener listener)
Removes the specified listener so that it no longer receives manager changed events from this view. |
void |
removeNotify()
Notifies the manager view that it has been removed from its parent. |
void |
removeTransformerListener(TransformerListener l)
Removes the specified transformer listener so that it no longer receives transformer changed events from this view. |
void |
removeViewDecoration(IlvManagerViewDecoration decoration)
Removes a decoration from the view. |
void |
repaint(IlvRect rect)
Repaints a region of the view. |
void |
repaint(long tm,
int x,
int y,
int width,
int height)
Repaints the specified rectangle of this component. |
void |
setAntialiasing(boolean set)
Changes the antialiasing mode of the view. |
void |
setAutoFitToContents(boolean set)
Changes the autofit mode of the view. |
void |
setBackground(Color color)
Changes the background of the view. |
void |
setBackgroundPattern(Image pattern)
Deprecated. use setBackgroundPatternLocation |
void |
setBackgroundPatternLocation(URL pattern)
Changes the background pattern of the view. |
void |
setBounds(int x,
int y,
int width,
int height)
Reshapes the view to the specified bounding box. |
void |
setContributingToViewBBox(int layer,
boolean value)
Allows to indicate whether the specified layer must be taken into account when computing the bounding box of the view. |
void |
setCursor(Cursor cursor)
Changes the cursor of the view. |
void |
setDefaultGhostColor(Color color)
Changes the default ghost color for the view. |
void |
setDefaultXORColor(Color color)
Changes the default XOR color for the view. |
void |
setDoubleBufferFrozen(boolean freeze)
Sets whether the double buffer is frozen. |
void |
setDoubleBuffering(boolean set)
Sets the manager view in double-buffering mode. |
void |
setEventDispatching(boolean value)
Changes the way AWT events are dispatched. |
void |
setGrid(IlvGrid grid)
Changes the grid of the view. |
void |
setInteractor(IlvManagerViewInteractor interactor)
Changes the interactor of the view. |
void |
setKeepingAspectRatio(boolean set)
Allows or inhibits the ability to have different zoom factors along the x and y axes. |
void |
setLayerCached(int layer,
boolean enabled)
Enables or disables the cache on a specified manager layer. |
void |
setManager(IlvManager manager)
Changes the manager displayed by this manager view. |
void |
setMaximumSize(Dimension maximumSize)
Sets the maximum size of the view to a constant value. |
void |
setMaxZoomXFactor(double zoomFactor)
Sets the maximal zoom factor allowed for the view in the x direction. |
void |
setMaxZoomYFactor(double zoomFactor)
Sets the maximal zoom factor allowed for the view in the y direction. |
void |
setMinimumSize(Dimension minimumSize)
Sets the minimum size of the view to a constant value. |
void |
setMinZoomXFactor(double zoomFactor)
Sets the minimal zoom factor allowed for the view in the x direction. |
void |
setMinZoomYFactor(double zoomFactor)
Sets the minimal zoom factor allowed for the view in the y direction. |
void |
setOptimizedTranslation(boolean set)
Changes the optimized translation mode. |
void |
setPreferredSize(Dimension preferredSize)
Sets the preferred size of the view to a constant value. |
void |
setRedrawMode(int mode)
Changes the way invalid regions of the view are redrawn. |
void |
setRepaintSkipThreshold(long delay)
Sets the minimum delay between repaint requests. |
void |
setTransformer(IlvTransformer t)
Changes the transformer of the view. |
void |
setTransparent(boolean transparent)
Changes the transparency of the view. |
void |
setTripleBufferedLayerCount(int n)
Sets the number of triple-buffered layers for this view. |
void |
setVisible(int layer,
boolean value)
Modifies the visibility of the specified layer in the view. |
void |
setWheelZoomingEnabled(boolean handleWheel)
Enables/disables zooming in response to movement of the mouse wheel plus control key pressed. |
void |
setWheelZoomingInverted(boolean inverted)
Sets whether the zooming facility of the mouse wheel is inverted. |
void |
setZoomFactorRange(double minZoomFactor,
double maxZoomFactor)
Sets the minimal and maximal zoom factor allowed for the view. |
void |
snapToGrid(IlvPoint point)
Changes the coordinates of the specified point to the closest point of the grid. |
protected void |
transformerChanged(IlvTransformer newTransformer,
IlvTransformer oldTransformer)
This method is called when the transformer changes. |
void |
translate(float deltax,
float deltay,
boolean redraw)
Translates the view. |
void |
update(Graphics g)
Updates the component. |
void |
verifyTransformer()
Checks a transformer before setting it to a view. |
Rectangle |
visibleRect()
Returns the visible rectangle of the view. |
void |
zoom(IlvPoint point,
double sx,
double sy,
boolean redraw)
Zooms the transformer of the view. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ilog.views.IlvObjectInteractorContext |
|---|
getCursor, getGraphics, isCursorSet |
| Field Detail |
|---|
public static final int THREADED_REDRAW
setRedrawMode(int),
Constant Field Valuespublic static final int DIRECT_REDRAW
setRedrawMode(int),
Constant Field Values| Constructor Detail |
|---|
public IlvManagerView(IlvManager manager,
IlvTransformer t)
manager - The manager to which the view is connected.t - The transformation used to draw the content of the manager.
A value of null is equivalent to an Identity transformer.public IlvManagerView(IlvManager manager)
manager - The manager to which the view is connected.public IlvManagerView()
| Method Detail |
|---|
public final IlvManager getManager()