Search this API

y.view
Class Graph2DView

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

public class Graph2DView
extends javax.swing.JComponent
implements View, ViewContainer, javax.swing.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

The default Graph2DRenderer used on the views canvas is a DefaultGraph2DRenderer which can be queried using method getGraph2DRenderer() and can be used to determine the rendering order of e.g. nodes and edges.

See Also:
Serialized Form
 

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static byte BG_LAYER
          Background layer constant.
static int CONTENT_POLICY_BACKGROUND_DRAWABLES
          Content policy constant that includes the current background drawables (i.e. all Drawable instances registered via the addBackgroundDrawable(Drawable) method) in the calculation of the content bounding box.
static int CONTENT_POLICY_FOREGROUND_DRAWABLES
          Content policy constant that includes the current foreground drawables (i.e. all Drawable instances registered via the addDrawable(Drawable) method) in the calculation of the content bounding box.
static int CONTENT_POLICY_GRAPH
          Content policy constant that includes the current graph in the calculation of the content bounding box.
static int CONTENT_POLICY_GRAPH_DRAWABLES
          Content policy constant that includes the current graph drawables (i.e. all Drawable instances registered via the Graph2D.addDrawable(Drawable) method) in the calculation of the content bounding box.
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 view control.
 
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 applyLayout(Layouter layouter)
          Convenience method that uses Graph2DLayoutExecutor in Graph2DLayoutExecutor.BUFFERED mode to calculate a layout for the currently given graph using the provided layouter instance.
 void applyLayoutAnimated(Layouter layouter)
          Convenience method that uses Graph2DLayoutExecutor in Graph2DLayoutExecutor.ANIMATED mode to calculate a layout for the currently given graph using the provided layouter instance and applying the new layout in an animated fashion.
 java.awt.Rectangle calculateContentBounds()
          Calculates the bounding box of this view's current content.
 void closeLabelEditor(boolean adoptValue)
          Closes a label editor that was opened for this view.
protected  javax.swing.JPanel createGlassPane()
          Creates a glass pane for the view.
protected  GraphicsContext createGraphicsContext()
          Factory method that creates the GraphicsContext for the subsequent rendering.
 javax.swing.JToolTip createToolTip()
           
 void fitContent()
          Fits the contents inside this view.
 void fitContent(boolean animated)
          Fits the contents inside this view.
 void fitRectangle(java.awt.Rectangle r)
          Fits the given rectangle inside this view.
 void fitWorldRect()
          Sets the size and offset of the displayed document's world rectangle to the size and offset of this view.
 void focusView(double newZoom, java.awt.geom.Point2D newCenter, boolean animated)
          Sets this view's zoom level and center to the specified values.
 java.util.Collection getBackgroundDrawables()
          Returns a collection of background Drawables associated with this view.
 BackgroundRenderer getBackgroundRenderer()
          Returns the current BackgroundRenderer of this view.
 javax.swing.JComponent getCanvasComponent()
          Returns the component that displays the contents of this view.
 java.awt.Dimension getCanvasSize()
          Returns the size of the canvas part of this component.
 java.awt.geom.Point2D getCenter()
          Returns the world coordinate that is displayed in the center of this view.
 java.awt.Component getComponent()
          Returns this.
 int getContentPolicy()
          Returns the policy used in the calculation of the content bounding box.
 View getCurrentView()
          Returns this View.
 java.util.Collection getDrawables()
          Returns a collection of Drawables currently associated with this view
 boolean getFitContentOnResize()
          Whether or not the fitContentOnResize feature is enabled.
 java.awt.Frame getFrame()
          Returns the frame this components belongs to.
 javax.swing.JPanel getGlassPane()
          Returns the glass pane of this view or null if there is no glass pane.
 Graph2D getGraph2D()
          Returns the graph that this view displays.
 Graph2DRenderer getGraph2DRenderer()
          Returns the renderer used to render the bound Graph2D.
 java.awt.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.
 HitInfoFactory getHitInfoFactory()
          Returns the hit info factory for this view.
 int getHorizontalScrollBarPolicy()
          Returns the scroll bar policy for the horizontal scroll bar.
 java.awt.Image getImage()
          Deprecated. Use 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
 java.awt.RenderingHints getRenderingHints()
          Returns the default rendering hints to be used when rendering the graph.
 int getVerticalScrollBarPolicy()
          Returns the scroll bar policy for the vertical scroll bar.
 ViewControl getViewControl()
          Returns the view control of this view.
 java.awt.Cursor getViewCursor()
          Returns the cursor that is displayed when the mouse is over this view.
 java.util.Iterator getViewModes()
          Returns an iterator over an unmodifiable Collection of the currently installed ViewModes.
 java.awt.Point getViewPoint()
          Returns the world coordinate this view displays at its the upper left corner.
 java.awt.geom.Point2D getViewPoint2D()
          Returns the world coordinate this view displays at its the upper left corner.
 java.awt.Dimension getViewSize()
          Returns the size of the drawing canvas.
 java.awt.Rectangle getVisibleRect()
          Returns the visible part of the world rectangle.
 java.awt.geom.Rectangle2D getVisibleRect2D()
          Returns the visible part of the world rectangle in double precision.
 java.awt.Rectangle getWorldRect()
          Returns the world rectangle defined for this view.
 java.awt.geom.Rectangle2D getWorldRect2D()
          Returns the world rectangle defined for this view in double precision.
 double getZoom()
          Returns the current zoom level of this view.
 boolean isAntialiasedPainting()
          Determines whether or not anti-aliasing is used when displaying graphs.
 boolean isFocusTraversable()
           
 boolean isGridVisible()
          Asks if grid is visible in the view.
 boolean isInputSuppressed()
          Determines whether input is currently suppressed by this instance.
 boolean isOptimizedDrawingEnabled()
           
 boolean isValidateRoot()
          Returns false.
 void openLabelEditor(YLabel label, double x, double y)
          Same as openLabelEditor(YLabel,double,double,PropertyChangeListener).
 void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener)
          Same as openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean) but uses multi-line mode by default.
 void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode)
          Opens a label editor for the given label at world coordinate (x,y).
 void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode, boolean commitValue)
          Opens a label editor for the given label at world coordinate (x,y).
 void openLabelEditorCentered(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode)
          Opens a label editor for the given label.
 void openLabelEditorCentered(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode, boolean commitValue)
          Opens a label editor for the given label.
protected  void paintSelectionBox(java.awt.Graphics2D gfx, java.awt.geom.Rectangle2D box)
          Paints a selection box on the given graphics context.
 void paintVisibleContent(java.awt.Graphics2D gfx)
          Paints the visible part of this view's content on the given graphics context.
 void print(java.awt.Graphics g)
          Prints the currently displayed contents of this view to the given graphics context.
protected  void registerDefaultViewActions()
          Register predefined actions into the view's ActionMap.
 void registerKeyboardAction(java.awt.event.ActionListener anAction, javax.swing.KeyStroke aKeyStroke, int aCondition)
          Registers a keyboard action for this view.
 void registerKeyboardAction(java.awt.event.ActionListener anAction, java.lang.String aCommand, javax.swing.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 enabled)
          Specifies whether or not anti-aliasing is used when displaying graphs.
 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 setContentPolicy(int policy)
          Specifies the policy for the calculation of the content bounding box.
 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(java.awt.Color color)
          Sets the color of the grid By default the grid is painted in gray.
 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 setHitInfoFactory(HitInfoFactory hitInfoFactory)
          Sets the hit info factory for this view.
 void setHorizontalScrollBarPolicy(int policy)
          Sets the scroll bar policy for the horizontal scroll bar.
 void setInputSuppressed(boolean inputSuppressed)
          Determines whether this component (or rather the core component) will fire MouseListener, MouseMotionListener, MouseWheelListener, KeyListener, and processes key bindings.
 void setPaintDetailThreshold(double thresh)
          Sets the scale threshold after that less detailed versions of the graphs are displayed.
protected  void setRenderingHints(java.awt.Graphics2D gfx)
          Configures the specified graphics context for painting this view's content.
 void setRenderingHints(java.awt.RenderingHints renderingHints)
          Sets the default rendering hints to be used when rendering the graph.
 void setScrollBarPolicy(int vsbp, int hsbp)
          Sets the scroll bar policy for the scroll bars.
 void setSelectionBoxBounds(java.awt.Rectangle r)
          Sets the bounds of the selection box being displayed while in SELECTION_BOX_MODE.
 void setSelectionBoxBounds2D(java.awt.geom.Rectangle2D r)
          Sets the bounds of the selection box being displayed while in SELECTION_BOX_MODE.
 void setToolTipText(java.lang.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 setVerticalScrollBarPolicy(int policy)
          Sets the scroll bar policy for the vertical scroll bar.
 void setViewControl(ViewControl vc)
          Sets the view control for this view.
 void setViewCursor(java.awt.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 setWorldRect2D(double x, double y, double w, double 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(javax.swing.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 x 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 x world-coordinate.
 double toWorldCoordY(int y)
          Transforms a y view-coordinate to a y world-coordinate.
 void unregisterKeyboardAction(javax.swing.KeyStroke aKeyStroke)
          Unregisters a keyboard action for this view.
 void updateView()
          Forces this view to repaint its contents.
 void updateView(double x, double y, double w, double h)
          Forces this view to repaint its contents for the given world coordinate rectangle.
 void updateView(java.awt.geom.Rectangle2D bounds)
          Forces this view to repaint its contents for the given world coordinate rectangle.
 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, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

CONTENT_POLICY_GRAPH

public static final int CONTENT_POLICY_GRAPH
Content policy constant that includes the current graph in the calculation of the content bounding box.

See Also:
getContentPolicy(), setContentPolicy(int), calculateContentBounds(), Constant Field Values

CONTENT_POLICY_GRAPH_DRAWABLES

public static final int CONTENT_POLICY_GRAPH_DRAWABLES
Content policy constant that includes the current graph drawables (i.e. all Drawable instances registered via the Graph2D.addDrawable(Drawable) method) in the calculation of the content bounding box.

See Also:
getContentPolicy(), setContentPolicy(int), calculateContentBounds(), Constant Field Values

CONTENT_POLICY_FOREGROUND_DRAWABLES

public static final int CONTENT_POLICY_FOREGROUND_DRAWABLES
Content policy constant that includes the current foreground drawables (i.e. all Drawable instances registered via the addDrawable(Drawable) method) in the calculation of the content bounding box.

See Also:
getContentPolicy(), setContentPolicy(int), calculateContentBounds(), Constant Field Values

CONTENT_POLICY_BACKGROUND_DRAWABLES

public static final int CONTENT_POLICY_BACKGROUND_DRAWABLES
Content policy constant that includes the current background drawables (i.e. all Drawable instances registered via the addBackgroundDrawable(Drawable) method) in the calculation of the content bounding box.

See Also:
getContentPolicy(), setContentPolicy(int), calculateContentBounds(), 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 view control.

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

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
Overrides:
isOptimizedDrawingEnabled in class javax.swing.JComponent

registerDefaultViewActions

protected void registerDefaultViewActions()
Register predefined actions into the view's ActionMap. This implementation registers all predefined Actions from Graph2DViewActions if they are not already registered in the view's ActionMap. No input bindings are registered.


createGlassPane

protected javax.swing.JPanel createGlassPane()
Creates a glass pane for the view.

Note: This factory method is called from the class constructors.

Returns:
a glass pane for the view.

getGlassPane

public javax.swing.JPanel getGlassPane()
Returns the glass pane of this view or null if there is no glass pane.

Returns:
the glass pane of this view or null if there is no glass pane.

fitWorldRect

public void fitWorldRect()
Sets 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 outside of the viewport area is not part 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:
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 java.awt.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.

See Also:
setHorizontalScrollBarPolicy(int)

getVerticalScrollBarPolicy

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

See Also:
setVerticalScrollBarPolicy(int)

setHorizontalScrollBarPolicy

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

Note that some view mode classes (most notably EditMode and its subclasses) may reset the scroll bar policy to ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED when activated.
In order to prevent this, disable scroll bar adjusting for these instances using the EditMode.setAdjustScrollBarPolicy(boolean) setter method, for example.

Parameters:
policy - one of
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, or
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS

setVerticalScrollBarPolicy

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

Note that some view mode classes (most notably EditMode and its subclasses) may reset the scroll bar policy to ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED when activated.
In order to prevent this, disable scroll bar adjusting for these instances using the EditMode.setAdjustScrollBarPolicy(boolean) setter method, for example.

Parameters:
policy - one of
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, or
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS

setScrollBarPolicy

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

Note that some view mode classes (most notably EditMode and its subclasses) may reset the scroll bar policy to ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED/ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED when activated.
In order to prevent this, disable scroll bar adjusting for these instances using the EditMode.setAdjustScrollBarPolicy(boolean) setter method, for example.

Parameters:
vsbp - policy for the vertical scroll bar, one of
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, or
  • ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
hsbp - policy for the horizontal scroll bar, one of
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, or
  • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
See Also:
setHorizontalScrollBarPolicy(int), setVerticalScrollBarPolicy(int)

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

Overrides:
isValidateRoot in class javax.swing.JComponent

createGraphicsContext

protected GraphicsContext createGraphicsContext()
Factory method that creates the GraphicsContext for the subsequent rendering. The instance returned will be registered with the Graphics2D object using the YRenderingHints.GRAPHICS_CONTEXT_KEY.

Returns:
a newly created context that has the GraphicsContext.getGraph2DView() property already set to this instance.

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 has been added to this view.

getViewModes

public java.util.Iterator getViewModes()
Returns an iterator over an unmodifiable Collection of the currently installed ViewModes.


isInputSuppressed

public boolean isInputSuppressed()
Determines whether input is currently suppressed by this instance. By default this is set to false.

See Also:
setInputSuppressed(boolean)

setInputSuppressed

public void setInputSuppressed(boolean inputSuppressed)
Determines whether this component (or rather the core component) will fire MouseListener, MouseMotionListener, MouseWheelListener, KeyListener, and processes key bindings.

Parameters:
inputSuppressed - While true the above events will not be fired and the respective code will not be invoked. By default input is not suppressed.
See Also:
isInputSuppressed()

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(java.awt.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 java.awt.Color getGridColor()
Returns the currently set grid color

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

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.

See Also:
setWorldRect2D(double, double, double, double)

getWorldRect

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

See Also:
getWorldRect2D()

setWorldRect2D

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

Parameters:
x - x-coordinate of the upper left corner
y - y-coordinate of the upper left corner
w - width of the rectangle
h - height of the rectangle

getWorldRect2D

public java.awt.geom.Rectangle2D getWorldRect2D()
Returns the world rectangle defined for this view in double precision.


getCanvasComponent

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


getImage

public java.awt.Image getImage()
Deprecated. Use 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.


fitContent

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

Parameters:
animated - determines whether this operation shall be animated

getContentPolicy

public int getContentPolicy()
Returns the policy used in the calculation of the content bounding box. The policy can be CONTENT_POLICY_GRAPH or a bitwise union of CONTENT_POLICY_GRAPH_DRAWABLES, CONTENT_POLICY_FOREGROUND_DRAWABLES, and/or CONTENT_POLICY_BACKGROUND_DRAWABLES.

Defaults to CONTENT_POLICY_GRAPH.

Returns:
the policy used in the calculation of the content bounding box.
See Also:
calculateContentBounds()

setContentPolicy

public void setContentPolicy(int policy)
Specifies the policy for the calculation of the content bounding box. This policy determines whether graph drawables, foreground drawables, and/or background drawables are included in said calculation. (This view's associated graph is always included in the bounds calculation).

Defaults to CONTENT_POLICY_GRAPH.

Parameters:
policy - the policy constant for the fitContent calculation. The policy argument is an integer bit mask that may be CONTENT_POLICY_GRAPH, or a bitwise union of CONTENT_POLICY_GRAPH_DRAWABLES, CONTENT_POLICY_FOREGROUND_DRAWABLES, and/or CONTENT_POLICY_BACKGROUND_DRAWABLES (for example, CONTENT_POLICY_GRAPH_DRAWABLES or CONTENT_POLICY_FOREGROUND_DRAWABLES|CONTENT_POLICY_BACKGROUND_DRAWABLES).
See Also:
calculateContentBounds()

calculateContentBounds

public java.awt.Rectangle calculateContentBounds()
Calculates the bounding box of this view's current content.

The content bounds are used to determine the area of interest for methods fitContent() and updateWorldRect().

Property contentPolicy determines whether graph drawables, foreground drawables, and/or background drawables are taken into account when calculating content bounds. The nodes and edges of this view's associated graph are always taken into account.

See Also:
getContentPolicy(), setContentPolicy(int)

fitRectangle

public void fitRectangle(java.awt.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 java.awt.Dimension getCanvasSize()
Returns the size of the canvas part of this component.


paintVisibleContent

public void paintVisibleContent(java.awt.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 java.awt.geom.Point2D getCenter()
Returns the world coordinate that is displayed in the center of this view.


getViewSize

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

updateView

public void updateView(java.awt.geom.Rectangle2D bounds)
Forces this view to repaint its contents for the given world coordinate rectangle. This method simple delegates to updateView(double, double, double, double).

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

Parameters:
bounds - the bounds of the rectangle in world coordinates that need to be updated
See Also:
updateView(double, double, double, double)

updateView

public void updateView(double x,
                       double y,
                       double w,
                       double h)
Forces this view to repaint its contents for the given world coordinate rectangle.

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

Specified by:
updateView in interface View
Parameters:
x - the upper left corner of the rectangular area to be updated in world coordinates
y - the upper left corner of the rectangular area to be updated in world coordinates
w - the width of the rectangular area to be updated in world coordinates
h - the height of the rectangular area to be updated in world coordinates
See Also:
View.updateView(double, double, double, double)

paintSelectionBox

protected void paintSelectionBox(java.awt.Graphics2D gfx,
                                 java.awt.geom.Rectangle2D box)
Paints a selection box on the given graphics context. The bounds of the box are given in view coordinates. The graphics context is configured with the corresponding transform. This class has some client properties defined that influence the default implementation of this method. All currently supported client properties are listed below:
Client PropertyValue TypeDescription
selectionbox.rectangularshapejava.awt.geom.RectangularShape shape representation of the selection box
selectionbox.fillcolorjava.awt.Color (transparent) color used to fill the selection box
selectionbox.linecolorjava.awt.Color color used to draw the border of the selection box
selectionbox.strokejava.awt.Stroke stroke used to draw the border of the selection box


setRenderingHints

protected void setRenderingHints(java.awt.Graphics2D gfx)
Configures the specified graphics context for painting this view's content. The default implementation sets the default rendering hints and handles default anti-aliasing.

Parameters:
gfx - the graphics context to configure.
See Also:
YRenderingHints.KEY_ANTIALIASING_HANDLER, YRenderingHints.AntiAliasingHandler

updateWorldRect

public void updateWorldRect()
Updates the current world rectangle. Adjusts the world rectangle so 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. When changing the zoom level, the world coordinate displayed in the center of the view will be fixed but the world coordinate displayed at the upper-left corner (viewPoint) of the view will change.

By default the zoom level is 1.0

See Also:
getViewPoint(), getCenter()

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 interpreted in world coordinates.


setViewCursor

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


getViewCursor

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


getHitInfoFactory

public HitInfoFactory getHitInfoFactory()
Returns the hit info factory for this view. This is used by the view modes for obtaining hit information. By default a HitInfoFactories.DefaultHitInfoFactory is used.

Returns:
the hit info factory for this view
See Also:
setHitInfoFactory(HitInfoFactory)

setHitInfoFactory

public void setHitInfoFactory(HitInfoFactory hitInfoFactory)
Sets the hit info factory for this view. This is used by the view modes for obtaining hit information. By default a HitInfoFactories.DefaultHitInfoFactory is used.

Parameters:
hitInfoFactory - the hit info factory for this view
See Also:
getHitInfoFactory()

setDrawingMode

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

By default NORMAL_MODE is active.

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

setSelectionBoxBounds

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


setSelectionBoxBounds2D

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


showPopup

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


getFrame

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

Specified by:
getFrame in interface View

closeLabelEditor

public void closeLabelEditor(boolean adoptValue)
Closes a label editor that was opened for this view.

Parameters:
adoptValue - whether or not the label should adopt the text value inside the label editor.

openLabelEditor

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

See Also:
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean), openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean)

openLabelEditor

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

See Also:
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean), openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean)

openLabelEditor

public void openLabelEditor(YLabel label,
                            double x,
                            double y,
                            java.beans.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 text of the given label currently resides use (label.getTextLocation().getX(), label.getTextLocation().getY()) as coordinates.

Additionally a PropertyChangeListener can be provided that gets informed after the label text has been changed. To use no PropertyChangeListener 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" or "Shift-Enter" adds a newline to the label. In multi-line mode the behavior is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.

The label editor can also be terminated by clicking somewhere into the view. In this case the current text is applied to the label.

Before applying the new text from the editor to the label, it is checked whether the text of the label changed since opening the editor. In this case the editor text is not applied to the label.

See Also:
openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean), YLabel.getTextLocation()

openLabelEditor

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

The editor supports two editing modes: single line and multiple line editing. In single line mode pressing the "Enter" key terminates the input and "Ctrl-Enter" or "Shift-Enter" adds a newline to the label. In multiple line mode the behavior is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.

Parameters:
label - the label to be edited.
x - x-coordinate of the editor's upper left corner.
y - y-coordinate of the editor's upper left corner.
listener - the listener to be notified after changing the label text. May be null if no notification is necessary.
useSingleLineMode - if true the editor works in single line mode, i.e. pressing the "Enter" key will terminate editing and "Ctrl-Enter" or "Shift-Enter" will add a new line; if false the editor works in multiple lines mode, i.e. pressing "Enter" will add a new line and "Ctrl-Enter" or "Shift-Enter" will terminate editing.
commitValue - if true the editor will set the label's text content and fire a corresponding PropertyChangeEvent (if the specified listener is not null) when editing is stopped; otherwise the editor will only fire the event without actually changing the label's text.
See Also:
openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean, boolean), YLabel.getTextLocation()

openLabelEditorCentered

public void openLabelEditorCentered(YLabel label,
                                    double x,
                                    double y,
                                    java.beans.PropertyChangeListener listener,
                                    boolean useSingleLineMode)
Opens a label editor for the given label. The editor will be centered on the specified coordinates.

The editor supports two editing modes: single line and multiple line editing. In single line mode pressing the "Enter" key terminates the input and "Ctrl-Enter" or "Shift-Enter" adds a newline to the label. In multiple line mode the behavior is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.

The label editor can also be terminated by clicking somewhere into the view. In this case the current text is applied to the label.

Before applying the new text from the editor to the label, it is checked whether the text of the label changed since opening the editor. In this case the editor text is not applied to the label.

Parameters:
label - the label to be edited.
x - x-coordinate of the editor's center.
y - y-coordinate of the editor's center.
listener - the listener to be notified after changing the label text. May be null if no notification is necessary.
useSingleLineMode - if true the editor works in single line mode, i.e. pressing the "Enter" key will terminate editing and "Ctrl-Enter" or "Shift-Enter" will add a new line; if false the editor works in multiple lines mode, i.e. pressing "Enter" will add a new line and "Ctrl-Enter" or "Shift-Enter" will terminate editing.
See Also:
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean)

openLabelEditorCentered

public void openLabelEditorCentered(YLabel label,
                                    double x,
                                    double y,
                                    java.beans.PropertyChangeListener listener,
                                    boolean useSingleLineMode,
                                    boolean commitValue)
Opens a label editor for the given label. The editor will be centered on the specified coordinates.

The editor supports two editing modes: single line and multiple line editing. In single line mode pressing the "Enter" key terminates the input and "Ctrl-Enter" or "Shift-Enter" adds a newline to the label. In multiple line mode the behavior is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.

Parameters:
label - the label to be edited.
x - x-coordinate of the editor's center.
y - y-coordinate of the editor's center.
listener - the listener to be notified after changing the label text. May be null if no notification is necessary.
useSingleLineMode - if true the editor works in single line mode, i.e. pressing the "Enter" key will terminate editing and "Ctrl-Enter" or "Shift-Enter" will add a new line; if false the editor works in multiple lines mode, i.e. pressing "Enter" will add a new line and "Ctrl-Enter" or "Shift-Enter" will terminate editing.
commitValue - if true the editor will set the label's text content and fire a corresponding PropertyChangeEvent (if the specified listener is not null) when editing is stopped; otherwise the editor will only fire the event without actually changing the label's text.
See Also:
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean, boolean)

getComponent

public java.awt.Component getComponent()
Returns this.

Specified by:
getComponent in interface View

getVisibleRect

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

Overrides:
getVisibleRect in class javax.swing.JComponent
See Also:
getVisibleRect2D()

getVisibleRect2D

public java.awt.geom.Rectangle2D getVisibleRect2D()
Returns the visible part of the world rectangle in double precision.


print

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

Overrides:
print in class javax.swing.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 java.awt.Point getViewPoint()
Returns the world coordinate this view displays at its the upper left corner.

See Also:
getViewPoint2D()

getViewPoint2D

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


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

getDrawables

public java.util.Collection getDrawables()
Returns a collection of Drawables currently associated with this view

Returns:
a Collection of Drawables

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

getBackgroundDrawables

public java.util.Collection getBackgroundDrawables()
Returns a collection of background Drawables associated with this view.

Returns:
a Collection of Drawables

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:
setPaintDetailThreshold(double)

toViewCoordX

public int toViewCoordX(double x)
Transforms a x world-coordinate to a x 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 x 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 java.awt.Component

setToolTipText

public void setToolTipText(java.lang.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 javax.swing.JComponent

createToolTip

public javax.swing.JToolTip createToolTip()
Overrides:
createToolTip in class javax.swing.JComponent

focusView

public void focusView(double newZoom,
                      java.awt.geom.Point2D newCenter,
                      boolean animated)
Sets this view's zoom level and center to the specified values.

Parameters:
newZoom - the new zoom level.
newCenter - the new center world coordinate.
animated - if true zoom and center will be changed in an animated fashion.

isAntialiasedPainting

public boolean isAntialiasedPainting()
Determines whether or not anti-aliasing is used when displaying graphs.

Defaults to true.

A more powerful way to control anti-aliasing preferences is by specifying adequate rendering hints. When specifying anti-aliasing preferences through explicit rendering hints, this property needs to be set to false.

Returns:
true if anti-aliasing is used when displaying graphs; false otherwise.
See Also:
setAntialiasedPainting(boolean), setRenderingHints(java.awt.Graphics2D), setRenderingHints(java.awt.RenderingHints), getRenderingHints()

setAntialiasedPainting

public void setAntialiasedPainting(boolean enabled)
Specifies whether or not anti-aliasing is used when displaying graphs.

Defaults to true.

A more powerful way to control anti-aliasing preferences is by specifying adequate rendering hints. When specifying anti-aliasing preferences through explicit rendering hints, this property needs to be set to false.

Parameters:
enabled - true if anti-aliasing has to be used when displaying graphs; false otherwise.
See Also:
isAntialiasedPainting(), setRenderingHints(java.awt.Graphics2D), setRenderingHints(java.awt.RenderingHints), getRenderingHints()

registerKeyboardAction

public void registerKeyboardAction(java.awt.event.ActionListener anAction,
                                   java.lang.String aCommand,
                                   javax.swing.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 javax.swing.JComponent

registerKeyboardAction

public void registerKeyboardAction(java.awt.event.ActionListener anAction,
                                   javax.swing.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 javax.swing.JComponent

unregisterKeyboardAction

public void unregisterKeyboardAction(javax.swing.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 javax.swing.JComponent

requestFocus

public void requestFocus()
Overrides:
requestFocus in class javax.swing.JComponent

setRenderingHints

public void setRenderingHints(java.awt.RenderingHints renderingHints)
Sets the default rendering hints to be used when rendering the graph. By default, the following rendering hints are set: RenderingHints.KEY_STROKE_CONTROL = RenderingHints.VALUE_STROKE_NORMALIZE.

Some non-default RenderingHints to set are, for example:

  • RenderingHints.KEY_FRACTIONALMETRICS: without using fractional font metrics text bounds will change with varying zoom level. Using fractional font metrics will remedy this problem.
    The down-side of this setting is that text does not have consistent spacing between adjacent glyphs. This variation in spacing creates visual noise which is disruptive to the reading process.
    For consistent results, the value for this rendering hint should be kept in sync with the YLabel.setFractionMetricsForSizeCalculationEnabled(boolean).
  • RenderingHints.KEY_INTERPOLATION: on many platforms the choice of interpolation type has a huge effect on scaled image rendering quality.


getRenderingHints

public java.awt.RenderingHints getRenderingHints()
Returns the default rendering hints to be used when rendering the graph. By default, the following rendering hints are set: RenderingHints.KEY_STROKE_CONTROL = RenderingHints.VALUE_STROKE_NORMALIZE.

See Also:
for more details about RenderingHints.

applyLayout

public void applyLayout(Layouter layouter)
Convenience method that uses Graph2DLayoutExecutor in Graph2DLayoutExecutor.BUFFERED mode to calculate a layout for the currently given graph using the provided layouter instance.

Parameters:
layouter - The layout algorithm to apply to the graph.
See Also:
Graph2DLayoutExecutor, applyLayoutAnimated(y.layout.Layouter)

applyLayoutAnimated

public void applyLayoutAnimated(Layouter layouter)
Convenience method that uses Graph2DLayoutExecutor in Graph2DLayoutExecutor.ANIMATED mode to calculate a layout for the currently given graph using the provided layouter instance and applying the new layout in an animated fashion.

Parameters:
layouter - The layout algorithm to apply to the graph.
See Also:
Graph2DLayoutExecutor, applyLayout(y.layout.Layouter)

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