y.view
Class Graph2DView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--y.view.Graph2DView
All Implemented Interfaces:
AnimationListener, ImageObserver, MenuContainer, ScrollPaneConstants, Serializable, View, View2DConstants, ViewContainer
Direct Known Subclasses:
Overview

public class Graph2DView
extends JComponent
implements View, ViewContainer, ScrollPaneConstants, View2DConstants, AnimationListener

This is a powerful component to view graphs in 2-dimensional space. It displays a Graph2D object. The same Graph2D object can be displayed at different zoom levels in different views.

Features of this component include

See Also:
Serialized Form

Field Summary
static byte BG_LAYER
          Background layer constant.
static byte FG_LAYER
          Foreground layer constant.
static int LAYER_MODE
          Drawing mode constant.
static int MOVE_SELECTION_MODE
          Drawing mode constant.
static int NORMAL_MODE
          Drawing mode constant.
static int SELECTION_BOX_MODE
          Drawing mode constant.
static int UNBUFFERED_MODE
          Drawing mode constant.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface y.view.View2DConstants
GRID_CROSS, GRID_LINES, GRID_NONE, GRID_POINTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Graph2DView()
          Creates a new Graph2DView containing an empty graph.
Graph2DView(Graph2D graph)
          Creates a new Graph2DView for a given graph.
Graph2DView(Graph2D graph, ViewControl vc)
          Creates a new Graph2DView for a given graph and viewcontrol.
 
Method Summary
 void addBackgroundDrawable(Drawable d)
          Adds a background drawable to this view.
 void addDrawable(Drawable d)
          Adds a drawable to this view.
 void addViewChangeListener(ViewChangeListener l)
          View can not change, so this method does nothing
 void addViewMode(ViewMode vm)
          Adds a view mode to this Graph2DView.
 boolean adjustScrollBarVisibility()
          Updates scrollbar visibility and adjustment for this view .
 void animationPerformed(AnimationEvent e)
          AnimationListener implementation.
 void fitContent()
          Fits the contents inside this view.
 void fitRectangle(Rectangle r)
          Fits the given rectangle inside this view.
 void fitWorldRect()
          Set the size and offset of the displayed document's world rectangle to the size and offset of this view.
 void focusView(double newZoom, Point2D newCenter, boolean animated)
           
 BackgroundRenderer getBackgroundRenderer()
          Returns the current BackgroundRenderer of this view.
 JComponent getCanvasComponent()
          Returns the component that displays the contents of this view.
 Dimension getCanvasSize()
          Returns the size of the canvas part of this component.
 Point2D getCenter()
          Returns the world coordinate that is displayed in the center of this view.
 Component getComponent()
          Returns this.
 View getCurrentView()
          Returns this View.
 boolean getFitContentOnResize()
          Whether or not the fitContentOnResize feature is enabled.
 Frame getFrame()
          Returns the frame this components belongs to.
 Graph2D getGraph2D()
          Returns the graph that this view displays.
 Graph2DRenderer getGraph2DRenderer()
          Returns the renderer used to render the bound Graph2D.
 Color getGridColor()
          Returns the currently set grid color
 boolean getGridMode()
          Asks if grid is on or off on the view.
 double getGridResolution()
          Get resolution of grid.
 int getGridType()
          Get type of grid.
 int getHorizontalScrollBarPolicy()
          Returns the scroll bar policy for the horizontal scroll bar.
 Image getImage()
          Deprecated. use Graph2DView.paintVisibleContent(Graphics2D) with a graphics context of an appropriate image type instead.
 double getPaintDetailThreshold()
          Returns the scale threshold after that less detailed versions of the graph are displayed
 int getVerticalScrollBarPolicy()
          Returns the scroll bar policy for the vertical scroll bar.
 void getVerticalScrollBarPolicy(int policy)
          Sets the scroll bar policy for the vertical scroll bar.
 ViewControl getViewControl()
          Returns the view control of this view.
 Cursor getViewCursor()
          Returns the cursor that is displayed when the mouse is over this view.
 Point getViewPoint()
          Returns the world coordinate this view displays at its the upper left corner.
 Point2D getViewPoint2D()
          Returns the world coordinate this view displays at its the upper left corner.
 Dimension getViewSize()
          Returns the size of the drawing canvas.
 Rectangle getVisibleRect()
          Returns the visible part of the world rectangle.
 Rectangle getWorldRect()
          Returns the world rectangle defined for this view.
 double getZoom()
          Returns the current zoom level of this view.
 void gridCursorActive(boolean active)
          Activates/Deactivates the grid cursor.
 boolean isAntialiasedPainting()
          Getter for property antialiasedPainting.
 boolean isFocusTraversable()
           
 boolean isGridVisible()
          Asks if grid is visible in the view.
 boolean isValidateRoot()
          Returns true.
 void openLabelEditor(YLabel label, double x, double y)
          Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener).
 void openLabelEditor(YLabel label, double x, double y, PropertyChangeListener listener)
          Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean) but uses single-line mode by default.
 void openLabelEditor(YLabel label, double x, double y, PropertyChangeListener listener, boolean useSingleLineMode)
          Opens a label editor for the given label at world coordinate (x,y).
 void paintVisibleContent(Graphics2D gfx)
          Paints the visible part of this view's content on the given graphics context.
 void print(Graphics g)
          Prints the currently displayed contents of this view to the given graphics context.
 void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)
          Registers a keyboard action for this view.
 void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition)
          Registers a keyboard action for this view.
 void removeBackgroundDrawable(Drawable d)
          Removes a background drawable from this view.
 void removeDrawable(Drawable d)
          Removes a drawable from this view.
 void removeViewMode(ViewMode vm)
          Remove a view mode from this Graph2DView.
 void requestFocus()
           
 void setAntialiasedPainting(boolean antialiasedPainting)
          Setter for property antialiasedPainting.
 void setBackgroundRenderer(BackgroundRenderer renderer)
          Sets the BackgroundRenderer of this view.
 void setBounds(int x, int y, int w, int h)
          Sets the bounds of this component.
 void setCenter(double x, double y)
          Sets the world coordinate that should be displayed in the center of this view.
 void setDrawingMode(int mode)
          Sets the drawing mode for this view.
 void setFitContentOnResize(boolean b)
          Specifies whether or not to fit the content inside the view automatically whenever this component changes it's size.
 void setGraph2D(Graph2D graph)
          Sets the graph that this view displays.
 void setGraph2DRenderer(Graph2DRenderer renderer)
          Sets the renderer used to render the bound Graph2D.
 void setGridColor(Color color)
          Sets the color of the grid By default the grid is painted in gray.
 void setGridCursorPosition(double x, double y)
          Sets the position of the gridcursor.
 void setGridMode(boolean b)
          Turns grid on or off on the view.
 void setGridResolution(double res)
          Sets resolution of the grid.
 void setGridType(int type)
          Sets type of the grid.
 void setGridVisible(boolean b)
          Turns grid's visibility on or off on the view.
 void setHorizontalScrollBarPolicy(int policy)
          Sets the scroll bar policy for the horizontal scroll bar.
 void setPaintDetailThreshold(double thresh)
          Sets the scale threshold after that less detailed versions of the graphs are displayed.
 void setScrollBarPolicy(int vsbp, int hsbp)
          Sets the scroll bar policy for the scroll bars.
 void setSecureDrawingMode(boolean b)
          If set to true, all drawing optimizations will be disabled.
 void setSelectionBoxBounds(Rectangle r)
          Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE.
 void setSelectionBoxBounds2D(Rectangle2D r)
          Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE.
 void setToolTipText(String text)
          Sets the tool tip text. this method can be used in a view mode to show tip texts to show context sensitive tips over nodes, etc.
 void setViewControl(ViewControl vc)
          Sets the view control for this view.
 void setViewCursor(Cursor c)
          Sets the cursor that is displayed when the mouse is over this view.
 void setViewPoint(int x, int y)
          Sets the world coordinate that is being displayed at the upper left corner of this view.
 void setViewPoint2D(double x, double y)
          Sets the world coordinate that is being displayed at the upper left corner of this view.
 void setWorldRect(int x, int y, int w, int h)
          Sets the bounds of the world rectangle.
 void setZoom(double zoom)
          Sets the current zoom level that will be used to display the contents.
 void showPopup(JPopupMenu popup, double x, double y)
          Displays the given popup menu at world coordinate (x,y).
 int toViewCoordX(double x)
          Transforms a x world-coordinate to a y view-coordinate.
 int toViewCoordY(double y)
          Transforms a y world-coordinate to a y view-coordinate.
 double toWorldCoordX(int x)
          Transforms a x view-coordinate to a y world-coordinate.
 double toWorldCoordY(int y)
          Transforms a y view-coordinate to a y world-coordinate.
 void unregisterKeyboardAction(KeyStroke aKeyStroke)
          Unregisters a keyboard action for this view.
 void updateView()
          Forces this view to repaint its contents.
 void updateWorldRect()
          Updates the current world rectangle.
 void zoomToArea(double x, double y, double width, double height)
          Adjusts the zoom level and view point of this view such that the given bounds are visible in this view.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL_MODE

public static final int NORMAL_MODE
Drawing mode constant. This mode indicates the absence of a specialized drawing modes.

See Also:
Constant Field Values

MOVE_SELECTION_MODE

public static final int MOVE_SELECTION_MODE
Drawing mode constant. By activating this mode, the view uses optimized drawing routines for moving the selected parts of the displayed document.

See Also:
Constant Field Values

SELECTION_BOX_MODE

public static final int SELECTION_BOX_MODE
Drawing mode constant. By activating this mode, the view uses optimized drawing routines for drawing an active selection box.

See Also:
Constant Field Values

LAYER_MODE

public static final int LAYER_MODE
Drawing mode constant. By activating this mode, the view uses optimized drawing routines for graph objects that reside in different drawing layers. Graph Objects that are in layer BG_LAYER are drawn in a passive background layer and graph objects in layer FG_LAYER are drawn in an active foreground layer. This mode is useful if only some parts of the displayed document will be moved around while other parts remain static. Note that while being in this mode no visible changes on BG_LAYER objects should be performed.

See Also:
Constant Field Values

UNBUFFERED_MODE

public static final int UNBUFFERED_MODE
Drawing mode constant. This mode causes the view to draw in unbuffered mode. Usually this causes flickering repaints.

See Also:
Constant Field Values

FG_LAYER

public static final byte FG_LAYER
Foreground layer constant. Displayed Objects that reside in this layer will be drawn on top of all background layer objects and changed performed on them will be displayed even when drawing in LAYER_MODE.

See Also:
Constant Field Values

BG_LAYER

public static final byte BG_LAYER
Background layer constant. Displayed Objects that reside in this layer will be drawn underneath all foreground layer objects. While drawing in LAYER_MODE no visible changes should be performed on objects residing in this layer.

See Also:
Constant Field Values
Constructor Detail

Graph2DView

public Graph2DView()
Creates a new Graph2DView containing an empty graph.


Graph2DView

public Graph2DView(Graph2D graph)
Creates a new Graph2DView for a given graph.

Parameters:
graph - The graph which should be displayed

Graph2DView

public Graph2DView(Graph2D graph,
                   ViewControl vc)
Creates a new Graph2DView for a given graph and viewcontrol.

Parameters:
graph - The graph which should be displayed
vc - The viewcontrol for this View
Method Detail

fitWorldRect

public void fitWorldRect()
Set the size and offset of the displayed document's world rectangle to the size and offset of this view. The effect of this method is that there will be no need for scrollbars anymore since the area outsize of the viewport area is not port of the displayed document anymore.


setFitContentOnResize

public void setFitContentOnResize(boolean b)
Specifies whether or not to fit the content inside the view automatically whenever this component changes it's size. By default this feature is disabled.


getFitContentOnResize

public boolean getFitContentOnResize()
Whether or not the fitContentOnResize feature is enabled.

See Also:
Graph2DView.setFitContentOnResize(boolean b)

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Sets the bounds of this component. This method should not be called directly.

Overrides:
setBounds in class Component

setViewControl

public void setViewControl(ViewControl vc)
Sets the view control for this view.


getViewControl

public ViewControl getViewControl()
Returns the view control of this view.

Specified by:
getViewControl in interface ViewContainer

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Returns the scroll bar policy for the horizontal scroll bar.


getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()
Returns the scroll bar policy for the vertical scroll bar.


setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int policy)
Sets the scroll bar policy for the horizontal scroll bar.


getVerticalScrollBarPolicy

public void getVerticalScrollBarPolicy(int policy)
Sets the scroll bar policy for the vertical scroll bar.


setScrollBarPolicy

public void setScrollBarPolicy(int vsbp,
                               int hsbp)
Sets the scroll bar policy for the scroll bars.

Parameters:
vsbp - policy for the vertical scroll bar
hsbp - policy for the horizontal scroll bar Policy constants as defined in javax.swing.JScrollPaneConstants may be used.

adjustScrollBarVisibility

public boolean adjustScrollBarVisibility()
Updates scrollbar visibility and adjustment for this view . A call to this method may be necessary if the complete contents of this view lies outside the canvas area reachable by scrolling the viewport.


isValidateRoot

public boolean isValidateRoot()
Returns true.

Overrides:
isValidateRoot in class JComponent

addViewMode

public void addViewMode(ViewMode vm)
Adds a view mode to this Graph2DView.

Parameters:
vm - A ViewMode

removeViewMode

public void removeViewMode(ViewMode vm)
Remove a view mode from this Graph2DView.

Parameters:
vm - A ViewMode which hab been added to this view.

setGridMode

public void setGridMode(boolean b)
Turns grid on or off on the view.


setGridVisible

public void setGridVisible(boolean b)
Turns grid's visibility on or off on the view.


getGridMode

public boolean getGridMode()
Asks if grid is on or off on the view.


isGridVisible

public boolean isGridVisible()
Asks if grid is visible in the view.


setGridResolution

public void setGridResolution(double res)
Sets resolution of the grid.

Parameters:
res - A positive number

getGridResolution

public double getGridResolution()
Get resolution of grid.

Returns:
A positive number

setGridType

public void setGridType(int type)
Sets type of the grid. Possible types are listed in View2DConstants.

Parameters:
type - Type of the grid

getGridType

public int getGridType()
Get type of grid. Possible types are listed in View2DConstants

Returns:
Type of the grid

setGridColor

public void setGridColor(Color color)
Sets the color of the grid By default the grid is painted in gray.

Parameters:
color - the color of the grid

getGridColor

public Color getGridColor()
Returns the currently set grid color

Returns:
the color of the grid
See Also:
Graph2DView.setGridColor(Color)

setGridCursorPosition

public void setGridCursorPosition(double x,
                                  double y)
Sets the position of the gridcursor. Position is in world coordinates.


gridCursorActive

public void gridCursorActive(boolean active)
Activates/Deactivates the grid cursor.


setWorldRect

public void setWorldRect(int x,
                         int y,
                         int w,
                         int h)
Sets the bounds of the world rectangle. The world rectangle defines size and location of the contents that are displayed.


getWorldRect

public Rectangle getWorldRect()
Returns the world rectangle defined for this view.


getCanvasComponent

public JComponent getCanvasComponent()
Returns the component that displays the contents of this view.


getImage

public Image getImage()
Deprecated. use Graph2DView.paintVisibleContent(Graphics2D) with a graphics context of an appropriate image type instead.

Returns an image of the currently displayed contents of this view.


fitContent

public void fitContent()
Fits the contents inside this view. Fitting the contents is done by adjusting the zoom level and view point.


fitRectangle

public void fitRectangle(Rectangle r)
Fits the given rectangle inside this view. The coordinates of the given rectangle are interpreted as world coordinates.

By calling this method the view port is adjusted in such a way that the given rectangular area is visible.


getCanvasSize

public Dimension getCanvasSize()
Returns the size of the canvas part of this component.


paintVisibleContent

public void paintVisibleContent(Graphics2D gfx)
Paints the visible part of this view's content on the given graphics context.


setCenter

public void setCenter(double x,
                      double y)
Sets the world coordinate that should be displayed in the center of this view.


getCenter

public Point2D getCenter()
Returns the world coordinate that is displayed in the center of this view.


getViewSize

public Dimension getViewSize()
Returns the size of the drawing canvas.


updateView

public void updateView()
Forces this view to repaint its contents.

Note that invoking repainton this component does not necessarily display the current contents.

Specified by:
updateView in interface View

updateWorldRect

public void updateWorldRect()
Updates the current world rectangle. Adjusts the world rectangle that the contents of this view lie completely inside the world rectangle.


getZoom

public double getZoom()
Returns the current zoom level of this view.


setZoom

public void setZoom(double zoom)
Sets the current zoom level that will be used to display the contents.

By default the zoom level is 1.0


zoomToArea

public void zoomToArea(double x,
                       double y,
                       double width,
                       double height)
Adjusts the zoom level and view point of this view such that the given bounds are visible in this view. The bounds are interpretes as world coordinates.


setViewCursor

public void setViewCursor(Cursor c)
Sets the cursor that is displayed when the mouse is over this view.


getViewCursor

public Cursor getViewCursor()
Returns the cursor that is displayed when the mouse is over this view.


getGraph2D

public Graph2D getGraph2D()
Returns the graph that this view displays.

Specified by:
getGraph2D in interface View

setGraph2D

public void setGraph2D(Graph2D graph)
Sets the graph that this view displays.


setDrawingMode

public void setDrawingMode(int mode)
Sets the drawing mode for this view.

By default NORMAL_MODE is active.

See Also:
Graph2DView.NORMAL_MODE, Graph2DView.MOVE_SELECTION_MODE, Graph2DView.SELECTION_BOX_MODE, Graph2DView.LAYER_MODE, Graph2DView.UNBUFFERED_MODE

setSelectionBoxBounds

public void setSelectionBoxBounds(Rectangle r)
Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE. The given rectangle is interpreted in world coordinates.


setSelectionBoxBounds2D

public void setSelectionBoxBounds2D(Rectangle2D r)
Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE. The given rectangle is interpreted in world coordinates.


showPopup

public void showPopup(JPopupMenu popup,
                      double x,
                      double y)
Displays the given popup menu at world coordinate (x,y).


getFrame

public Frame getFrame()
Returns the frame this components belongs to. If there is no such frame, null is returned.

Specified by:
getFrame in interface View

openLabelEditor

public void openLabelEditor(YLabel label,
                            double x,
                            double y)
Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener). Uses no PropertyChangeListener by default.


openLabelEditor

public void openLabelEditor(YLabel label,
                            double x,
                            double y,
                            PropertyChangeListener listener)
Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean) but uses single-line mode by default.


openLabelEditor

public void openLabelEditor(YLabel label,
                            double x,
                            double y,
                            PropertyChangeListener listener,
                            boolean useSingleLineMode)
Opens a label editor for the given label at world coordinate (x,y). To open the label editor at the location were the given label currently resides use (label.getBox.getX(), label.getBox().getY()) as coordinates.

Additionally a PropertyChangeListener can be provided that gets informed after the label text has been changed. To use no PCL one should pass null as an argument.

The last argument specifies whether the the label editor should work in single-line or in multi-line mode. In single-line mode pressing the "Enter" key terminates the input and "Ctrl-Enter" adds a newline to the label. In multi-line mode the behaviour is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.


getComponent

public Component getComponent()
Returns this.

Specified by:
getComponent in interface View

getVisibleRect

public Rectangle getVisibleRect()
Returns the visible part of the world rectangle.

Overrides:
getVisibleRect in class JComponent

print

public void print(Graphics g)
Prints the currently displayed contents of this view to the given graphics context.

Overrides:
print in class JComponent

setViewPoint

public void setViewPoint(int x,
                         int y)
Sets the world coordinate that is being displayed at the upper left corner of this view.


setViewPoint2D

public void setViewPoint2D(double x,
                           double y)
Sets the world coordinate that is being displayed at the upper left corner of this view.


getViewPoint

public Point getViewPoint()
Returns the world coordinate this view displays at its the upper left corner.


getViewPoint2D

public Point2D getViewPoint2D()
Returns the world coordinate this view displays at its the upper left corner.


setSecureDrawingMode

public void setSecureDrawingMode(boolean b)
If set to true, all drawing optimizations will be disabled.


getCurrentView

public View getCurrentView()
Returns this View.

Specified by:
getCurrentView in interface ViewContainer

addViewChangeListener

public void addViewChangeListener(ViewChangeListener l)
View can not change, so this method does nothing

Specified by:
addViewChangeListener in interface ViewContainer

addDrawable

public void addDrawable(Drawable d)
Adds a drawable to this view. Added drawables are rendered on top of the associated Graph2D.

Parameters:
d - A drawable

removeDrawable

public void removeDrawable(Drawable d)
Removes a drawable from this view.

Parameters:
d - A drawable

addBackgroundDrawable

public void addBackgroundDrawable(Drawable d)
Adds a background drawable to this view. Background drawables are rendered behind the associated Graph2D

Parameters:
d - A drawable

removeBackgroundDrawable

public void removeBackgroundDrawable(Drawable d)
Removes a background drawable from this view.

Parameters:
d - A drawable

getGraph2DRenderer

public Graph2DRenderer getGraph2DRenderer()
Returns the renderer used to render the bound Graph2D. By default an instance of DefaultGraph2DRenderer is used as Renderer of this view.


setGraph2DRenderer

public void setGraph2DRenderer(Graph2DRenderer renderer)
Sets the renderer used to render the bound Graph2D.


setPaintDetailThreshold

public void setPaintDetailThreshold(double thresh)
Sets the scale threshold after that less detailed versions of the graphs are displayed.

The default value is 0.3


getPaintDetailThreshold

public double getPaintDetailThreshold()
Returns the scale threshold after that less detailed versions of the graph are displayed

See Also:
Graph2DView.setPaintDetailThreshold(double)

toViewCoordX

public int toViewCoordX(double x)
Transforms a x world-coordinate to a y view-coordinate.


toViewCoordY

public int toViewCoordY(double y)
Transforms a y world-coordinate to a y view-coordinate.


toWorldCoordX

public double toWorldCoordX(int x)
Transforms a x view-coordinate to a y world-coordinate.


toWorldCoordY

public double toWorldCoordY(int y)
Transforms a y view-coordinate to a y world-coordinate.


setBackgroundRenderer

public void setBackgroundRenderer(BackgroundRenderer renderer)
Sets the BackgroundRenderer of this view.


getBackgroundRenderer

public BackgroundRenderer getBackgroundRenderer()
Returns the current BackgroundRenderer of this view.


animationPerformed

public void animationPerformed(AnimationEvent e)
AnimationListener implementation.

Specified by:
animationPerformed in interface AnimationListener

isFocusTraversable

public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class Component

setToolTipText

public void setToolTipText(String text)
Sets the tool tip text. this method can be used in a view mode to show tip texts to show context sensitive tips over nodes, etc.

Overrides:
setToolTipText in class JComponent

focusView

public void focusView(double newZoom,
                      Point2D newCenter,
                      boolean animated)

isAntialiasedPainting

public boolean isAntialiasedPainting()
Getter for property antialiasedPainting.

Returns:
Value of property antialiasedPainting.

setAntialiasedPainting

public void setAntialiasedPainting(boolean antialiasedPainting)
Setter for property antialiasedPainting.

Parameters:
antialiasedPainting - New value of property antialiasedPainting.

registerKeyboardAction

public void registerKeyboardAction(ActionListener anAction,
                                   String aCommand,
                                   KeyStroke aKeyStroke,
                                   int aCondition)
Registers a keyboard action for this view. ActionMaps or InputMaps for this view must be added to its canvas component. see #getCanvasComponent()

Overrides:
registerKeyboardAction in class JComponent

registerKeyboardAction

public void registerKeyboardAction(ActionListener anAction,
                                   KeyStroke aKeyStroke,
                                   int aCondition)
Registers a keyboard action for this view. ActionMaps or InputMaps for this view must be added to its canvas component. see #getCanvasComponent()

Overrides:
registerKeyboardAction in class JComponent

unregisterKeyboardAction

public void unregisterKeyboardAction(KeyStroke aKeyStroke)
Unregisters a keyboard action for this view. ActionMaps or InputMaps for this view must be added to its canvas component. see #getCanvasComponent()

Overrides:
unregisterKeyboardAction in class JComponent

requestFocus

public void requestFocus()
Overrides:
requestFocus in class JComponent

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003