|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent y.view.Graph2DView
public class Graph2DView
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.
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.
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 |
---|
public static final int NORMAL_MODE
public static final int MOVE_SELECTION_MODE
public static final int SELECTION_BOX_MODE
public static final int LAYER_MODE
public static final int UNBUFFERED_MODE
public static final byte FG_LAYER
public static final byte BG_LAYER
public static final int CONTENT_POLICY_GRAPH
getContentPolicy()
,
setContentPolicy(int)
,
calculateContentBounds()
,
Constant Field Valuespublic static final int CONTENT_POLICY_GRAPH_DRAWABLES
Drawable
instances registered via the
Graph2D.addDrawable(Drawable)
method) in the calculation of
the content bounding box.
getContentPolicy()
,
setContentPolicy(int)
,
calculateContentBounds()
,
Constant Field Valuespublic static final int CONTENT_POLICY_FOREGROUND_DRAWABLES
Drawable
instances registered via the
addDrawable(Drawable)
method) in the calculation of the content
bounding box.
getContentPolicy()
,
setContentPolicy(int)
,
calculateContentBounds()
,
Constant Field Valuespublic static final int CONTENT_POLICY_BACKGROUND_DRAWABLES
Drawable
instances registered via the
addBackgroundDrawable(Drawable)
method) in the calculation of the
content bounding box.
getContentPolicy()
,
setContentPolicy(int)
,
calculateContentBounds()
,
Constant Field ValuesConstructor Detail |
---|
public Graph2DView()
public Graph2DView(Graph2D graph)
graph
- The graph which should be displayedpublic Graph2DView(Graph2D graph, ViewControl vc)
graph
- The graph which should be displayedvc
- The view control for this ViewMethod Detail |
---|
public boolean isOptimizedDrawingEnabled()
isOptimizedDrawingEnabled
in class javax.swing.JComponent
protected void registerDefaultViewActions()
Graph2DViewActions
if they are not already registered in the view's ActionMap. No input
bindings are registered.
protected javax.swing.JPanel createGlassPane()
Note: This factory method is called from the class constructors.
public javax.swing.JPanel getGlassPane()
null
if there is no
glass pane.
null
if there is no
glass pane.public void fitWorldRect()
public void setFitContentOnResize(boolean b)
public boolean getFitContentOnResize()
fitContentOnResize
feature
is enabled.
setFitContentOnResize(boolean b)
public void setBounds(int x, int y, int w, int h)
setBounds
in class java.awt.Component
public void setViewControl(ViewControl vc)
public ViewControl getViewControl()
getViewControl
in interface ViewContainer
public int getHorizontalScrollBarPolicy()
setHorizontalScrollBarPolicy(int)
public int getVerticalScrollBarPolicy()
setVerticalScrollBarPolicy(int)
public void setHorizontalScrollBarPolicy(int policy)
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.
policy
- one of
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
, orScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
public void setVerticalScrollBarPolicy(int policy)
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.
policy
- one of
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
,ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
, orScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
public void setScrollBarPolicy(int vsbp, int hsbp)
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.
vsbp
- policy for the vertical scroll bar, one of
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
,ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
, orScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
hsbp
- policy for the horizontal scroll bar, one of
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
, orScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
setHorizontalScrollBarPolicy(int)
,
setVerticalScrollBarPolicy(int)
public boolean adjustScrollBarVisibility()
public boolean isValidateRoot()
false
.
isValidateRoot
in class javax.swing.JComponent
protected GraphicsContext createGraphicsContext()
GraphicsContext
for the subsequent rendering.
The instance returned will be registered with the Graphics2D
object
using the YRenderingHints.GRAPHICS_CONTEXT_KEY
.
GraphicsContext.getGraph2DView()
property
already set to this instance.public void addViewMode(ViewMode vm)
vm
- A ViewModepublic void removeViewMode(ViewMode vm)
vm
- A ViewMode which has been added to this view.public java.util.Iterator getViewModes()
public boolean isInputSuppressed()
false
.
setInputSuppressed(boolean)
public void setInputSuppressed(boolean inputSuppressed)
core component
)
will fire MouseListener
, MouseMotionListener
,
MouseWheelListener
, KeyListener
, and
processes key bindings
.
inputSuppressed
- While true
the above events will not be fired and the respective code will
not be invoked. By default input is not suppressed.isInputSuppressed()
public void setGridMode(boolean b)
public void setGridVisible(boolean b)
public boolean getGridMode()
public boolean isGridVisible()
public void setGridResolution(double res)
res
- A positive numberpublic double getGridResolution()
public void setGridType(int type)
View2DConstants
.
type
- Type of the gridpublic int getGridType()
View2DConstants
public void setGridColor(java.awt.Color color)
color
- the color of the gridpublic java.awt.Color getGridColor()
setGridColor(Color)
public void setWorldRect(int x, int y, int w, int h)
setWorldRect2D(double, double, double, double)
public java.awt.Rectangle getWorldRect()
getWorldRect2D()
public void setWorldRect2D(double x, double y, double w, double h)
x
- x-coordinate of the upper left cornery
- y-coordinate of the upper left cornerw
- width of the rectangleh
- height of the rectanglepublic java.awt.geom.Rectangle2D getWorldRect2D()
public javax.swing.JComponent getCanvasComponent()
public java.awt.Image getImage()
paintVisibleContent(Graphics2D)
with a
graphics context of an appropriate image type instead.
public void fitContent()
public void fitContent(boolean animated)
animated
- determines whether this operation shall be animatedpublic int getContentPolicy()
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
.
calculateContentBounds()
public void setContentPolicy(int policy)
Defaults to CONTENT_POLICY_GRAPH
.
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
).calculateContentBounds()
public java.awt.Rectangle calculateContentBounds()
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.
getContentPolicy()
,
setContentPolicy(int)
public void fitRectangle(java.awt.Rectangle r)
public java.awt.Dimension getCanvasSize()
public void paintVisibleContent(java.awt.Graphics2D gfx)
public void setCenter(double x, double y)
public java.awt.geom.Point2D getCenter()
public java.awt.Dimension getViewSize()
public void updateView()
repaint
on this component
does not necessarily display the current contents.
updateView
in interface View
public void updateView(java.awt.geom.Rectangle2D bounds)
updateView(double, double, double, double)
.
Note that invoking repaint
on this component
does not necessarily display the current contents.
bounds
- the bounds of the rectangle in world coordinates that need to be updatedupdateView(double, double, double, double)
public void updateView(double x, double y, double w, double h)
repaint
on this component
does not necessarily display the current contents.
updateView
in interface View
x
- the upper left corner of the rectangular area to be updated in world coordinatesy
- the upper left corner of the rectangular area to be updated in world coordinatesw
- the width of the rectangular area to be updated in world coordinatesh
- the height of the rectangular area to be updated in world coordinatesView.updateView(double, double, double, double)
protected void paintSelectionBox(java.awt.Graphics2D gfx, java.awt.geom.Rectangle2D box)
Client Property | Value Type | Description |
---|---|---|
selectionbox.rectangularshape | java.awt.geom.RectangularShape | shape representation of the selection box |
selectionbox.fillcolor | java.awt.Color | (transparent) color used to fill the selection box |
selectionbox.linecolor | java.awt.Color | color used to draw the border of the selection box |
selectionbox.stroke | java.awt.Stroke | stroke used to draw the border of the selection box |
protected void setRenderingHints(java.awt.Graphics2D gfx)
default rendering hints
and handles
default anti-aliasing
.
gfx
- the graphics context to configure.YRenderingHints.KEY_ANTIALIASING_HANDLER
,
YRenderingHints.AntiAliasingHandler
public void updateWorldRect()
public double getZoom()
public void setZoom(double zoom)
1.0
getViewPoint()
,
getCenter()
public void zoomToArea(double x, double y, double width, double height)
public void setViewCursor(java.awt.Cursor c)
public java.awt.Cursor getViewCursor()
public Graph2D getGraph2D()
getGraph2D
in interface View
public void setGraph2D(Graph2D graph)
public HitInfoFactory getHitInfoFactory()
HitInfoFactories.DefaultHitInfoFactory
is used.
setHitInfoFactory(HitInfoFactory)
public void setHitInfoFactory(HitInfoFactory hitInfoFactory)
HitInfoFactories.DefaultHitInfoFactory
is used.
hitInfoFactory
- the hit info factory for this viewgetHitInfoFactory()
public void setDrawingMode(int mode)
NORMAL_MODE
is active.
NORMAL_MODE
,
MOVE_SELECTION_MODE
,
SELECTION_BOX_MODE
,
LAYER_MODE
,
UNBUFFERED_MODE
public void setSelectionBoxBounds(java.awt.Rectangle r)
SELECTION_BOX_MODE
.
The given rectangle is interpreted in world coordinates.
public void setSelectionBoxBounds2D(java.awt.geom.Rectangle2D r)
SELECTION_BOX_MODE
.
The given rectangle is interpreted in world coordinates.
public void showPopup(javax.swing.JPopupMenu popup, double x, double y)
(x,y)
.
public java.awt.Frame getFrame()
null
is returned.
getFrame
in interface View
public void closeLabelEditor(boolean adoptValue)
adoptValue
- whether or not the label should
adopt the text value inside the label editor.public void openLabelEditor(YLabel label, double x, double y)
openLabelEditor(YLabel,double,double,PropertyChangeListener)
.
Uses no PropertyChangeListener by default.
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
,
openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
public void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener)
openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean)
but uses multi-line mode by default.
openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
,
openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
public void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode)
(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.
openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
,
YLabel.getTextLocation()
public void openLabelEditor(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode, boolean commitValue)
(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.
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.openLabelEditorCentered(YLabel, double, double, java.beans.PropertyChangeListener, boolean, boolean)
,
YLabel.getTextLocation()
public void openLabelEditorCentered(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode)
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.
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.openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean)
public void openLabelEditorCentered(YLabel label, double x, double y, java.beans.PropertyChangeListener listener, boolean useSingleLineMode, boolean commitValue)
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.
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.openLabelEditor(YLabel, double, double, java.beans.PropertyChangeListener, boolean, boolean)
public java.awt.Component getComponent()
getComponent
in interface View
public java.awt.Rectangle getVisibleRect()
getVisibleRect
in class javax.swing.JComponent
getVisibleRect2D()
public java.awt.geom.Rectangle2D getVisibleRect2D()
public void print(java.awt.Graphics g)
print
in class javax.swing.JComponent
public void setViewPoint(int x, int y)
public void setViewPoint2D(double x, double y)
public java.awt.Point getViewPoint()
getViewPoint2D()
public java.awt.geom.Point2D getViewPoint2D()
public View getCurrentView()
getCurrentView
in interface ViewContainer
public void addViewChangeListener(ViewChangeListener l)
addViewChangeListener
in interface ViewContainer
public void addDrawable(Drawable d)
d
- A drawablepublic java.util.Collection getDrawables()
Drawable
spublic void removeDrawable(Drawable d)
d
- A drawablepublic void addBackgroundDrawable(Drawable d)
d
- A drawablepublic java.util.Collection getBackgroundDrawables()
Drawable
spublic void removeBackgroundDrawable(Drawable d)
d
- A drawablepublic Graph2DRenderer getGraph2DRenderer()
DefaultGraph2DRenderer
is used as Renderer of this view.
public void setGraph2DRenderer(Graph2DRenderer renderer)
public void setPaintDetailThreshold(double thresh)
public double getPaintDetailThreshold()
setPaintDetailThreshold(double)
public int toViewCoordX(double x)
public int toViewCoordY(double y)
public double toWorldCoordX(int x)
public double toWorldCoordY(int y)
public void setBackgroundRenderer(BackgroundRenderer renderer)
public BackgroundRenderer getBackgroundRenderer()
public void animationPerformed(AnimationEvent e)
animationPerformed
in interface AnimationListener
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
public void setToolTipText(java.lang.String text)
setToolTipText
in class javax.swing.JComponent
public javax.swing.JToolTip createToolTip()
createToolTip
in class javax.swing.JComponent
public void focusView(double newZoom, java.awt.geom.Point2D newCenter, boolean animated)
newZoom
- the new zoom level.newCenter
- the new center world coordinate.animated
- if true zoom and center will be changed in an
animated fashion.
public boolean isAntialiasedPainting()
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
.
true
if anti-aliasing is used when displaying graphs;
false
otherwise.setAntialiasedPainting(boolean)
,
setRenderingHints(java.awt.Graphics2D)
,
setRenderingHints(java.awt.RenderingHints)
,
getRenderingHints()
public void setAntialiasedPainting(boolean enabled)
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
.
enabled
- true
if anti-aliasing has to be used when
displaying graphs; false
otherwise.isAntialiasedPainting()
,
setRenderingHints(java.awt.Graphics2D)
,
setRenderingHints(java.awt.RenderingHints)
,
getRenderingHints()
public void registerKeyboardAction(java.awt.event.ActionListener anAction, java.lang.String aCommand, javax.swing.KeyStroke aKeyStroke, int aCondition)
registerKeyboardAction
in class javax.swing.JComponent
public void registerKeyboardAction(java.awt.event.ActionListener anAction, javax.swing.KeyStroke aKeyStroke, int aCondition)
registerKeyboardAction
in class javax.swing.JComponent
public void unregisterKeyboardAction(javax.swing.KeyStroke aKeyStroke)
unregisterKeyboardAction
in class javax.swing.JComponent
public void requestFocus()
requestFocus
in class javax.swing.JComponent
public void setRenderingHints(java.awt.RenderingHints renderingHints)
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.
YLabel.setFractionMetricsForSizeCalculationEnabled(boolean)
.
RenderingHints.KEY_INTERPOLATION
: on many platforms the choice of
interpolation type has a huge effect on scaled image rendering quality.
public java.awt.RenderingHints getRenderingHints()
RenderingHints.KEY_STROKE_CONTROL
= RenderingHints.VALUE_STROKE_NORMALIZE
.
for more details about RenderingHints.
public void applyLayout(Layouter layouter)
Graph2DLayoutExecutor
in
Graph2DLayoutExecutor.BUFFERED
mode to calculate a layout for the currently given
graph using the provided layouter instance.
layouter
- The layout algorithm to apply to the graph
.Graph2DLayoutExecutor
,
applyLayoutAnimated(y.layout.Layouter)
public void applyLayoutAnimated(Layouter layouter)
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.
layouter
- The layout algorithm to apply to the graph
.Graph2DLayoutExecutor
,
applyLayout(y.layout.Layouter)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |