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:
ImageObserver, MenuContainer, Serializable, ScrollPaneConstants, AnimationListener, 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
 
Your browser does not support SVG content.

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static 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 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.
 Rectangle calculateContentBounds()
          Calculates the bounding box of this view's current content.
protected  GraphicsContext createGraphicsContext()
          Factory method that creates the GraphicsContext for the subsequent rendering.
 void fitContent()
          Fits the contents inside this view.
 void fitContent(boolean animated)
          Fits the contents inside this view.
 void fitRectangle(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, Point2D newCenter, boolean animated)
           
 Collection getBackgroundDrawables()
          Returns a collection of background Drawables associated with this view.
 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.
 int getContentPolicy()
          Returns the policy used in the calculation of the content bounding box.
 View getCurrentView()
          Returns this View.
 Collection getDrawables()
          Returns a collection of Drawables currently associated with this view
 boolean getFitContentOnResize()
          Whether or not the fitContentOnResize feature is enabled.
 Frame getFrame()
          Returns the frame this components belongs to.
 JPanel getGlassPane()
          Returns a glass pane of this view.
 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 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.
 ViewControl getViewControl()
          Returns the view control of this view.
 Cursor getViewCursor()
          Returns the cursor that is displayed when the mouse is over this view.
 Iterator getViewModes()
          Returns an iterator over an unmodifiable Collection of the currently installed ViewModes.
 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 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, PropertyChangeListener listener)
          Same as 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).
protected  void paintSelectionBox(Graphics2D gfx, Rectangle2D box)
          Paints a selection box on the given graphics context.
 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 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(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 grid cursor.
 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 being displayed while in SELECTION_BOX_MODE.
 void setSelectionBoxBounds2D(Rectangle2D r)
          Sets the bounds of the selection box being 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 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(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 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(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(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, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, 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,