Class DefaultView
- All Implemented Interfaces:
ComponentListener,WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,org.graphstream.ui.view.View
This base view is an abstract class that provides mechanism that are necessary in any view :
- the painting and repainting mechanism.
- the optional frame handling.
- the frame closing protocol.
This view also handle a current selection of nodes and sprites.
The painting mechanism
The main method to implement is render(Graphics2D). This method is
called each time the graph needs to be rendered anew in the canvas.
The render(Graphics2D) is called only when a repainting is really
needed.
All the painting, by default, is deferred to a GraphRenderer
instance. This mechanism allows developers that do not want to mess with the
viewer/view mechanisms to render a graph in any Swing surface.
The optional frame handling
This abstract view is able to create a frame that is added around this panel (each view is a JPanel instance). The frame can be removed at any time.
The frame closing protocol
This abstract view handles the closing protocol. This means that it will close the view if needed, or only hide it to allow reopening it later. Furthermore it adds the "ui.viewClosed" attribute to the graph when the view is closed or hidden, and removes it when the view is shown. The value of this graph attribute is the identifier of the view.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JFrameThe (optional) frame.protected org.graphstream.ui.graphicGraph.GraphicGraphThe graph to render, shortcut to the viewers reference.protected org.graphstream.ui.view.util.MouseManagerManager for events with the mouse.protected org.graphstream.ui.view.GraphRendererThe graph renderer.protected org.graphstream.ui.view.util.ShortcutManagerManager for events with the keyboard.protected org.graphstream.ui.view.ViewerParent viewer.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionDefaultView(org.graphstream.ui.view.Viewer viewer, String identifier, org.graphstream.ui.view.GraphRenderer renderer) -
Method Summary
Modifier and TypeMethodDescription<T,U> void addListener(T descriptor, U listener) Collection<org.graphstream.ui.graphicGraph.GraphicElement>allGraphicElementsIn(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2) voidbeginSelectionAt(double x1, double y1) protected voidvoidclose(org.graphstream.ui.graphicGraph.GraphicGraph graph) voidvoidvoidvoidvoiddisplay(org.graphstream.ui.graphicGraph.GraphicGraph graph, boolean graphChanged) voidThis is a shortcut to a call setMouseManager with a MouseOverMouseManager instance and with (InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE).voidendSelectionAt(double x2, double y2) org.graphstream.ui.graphicGraph.GraphicElementfindGraphicElementAt(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y) voidfreezeElement(org.graphstream.ui.graphicGraph.GraphicElement element, boolean frozen) org.graphstream.ui.view.camera.CameravoidmoveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y) voidopenInAFrame(boolean on) void<T,U> void removeListener(T descriptor, U listener) voidrender(Graphics2D g) voidresizeFrame(int width, int height) Set the size of the view frame, if any.voidselectionGrowsAt(double x, double y) voidsetBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<Graphics2D> renderer) voidsetForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<Graphics2D> renderer) voidsetMouseManager(org.graphstream.ui.view.util.MouseManager manager) voidsetShortcutManager(org.graphstream.ui.view.util.ShortcutManager manager) voidvoidvoidvoidvoidvoidvoidMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
viewer
protected org.graphstream.ui.view.Viewer viewerParent viewer. -
graph
protected org.graphstream.ui.graphicGraph.GraphicGraph graphThe graph to render, shortcut to the viewers reference. -
frame
The (optional) frame. -
shortcuts
protected org.graphstream.ui.view.util.ShortcutManager shortcutsManager for events with the keyboard. -
mouseClicks
protected org.graphstream.ui.view.util.MouseManager mouseClicksManager for events with the mouse. -
renderer
protected org.graphstream.ui.view.GraphRenderer rendererThe graph renderer.
-
-
Constructor Details
-
DefaultView
public DefaultView(org.graphstream.ui.view.Viewer viewer, String identifier, org.graphstream.ui.view.GraphRenderer renderer)
-
-
Method Details
-
getCamera
public org.graphstream.ui.view.camera.Camera getCamera()- Specified by:
getCamerain interfaceorg.graphstream.ui.view.View
-
display
public void display(org.graphstream.ui.graphicGraph.GraphicGraph graph, boolean graphChanged) - Specified by:
displayin interfaceorg.graphstream.ui.view.View
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
checkTitle
protected void checkTitle() -
close
public void close(org.graphstream.ui.graphicGraph.GraphicGraph graph) - Specified by:
closein interfaceorg.graphstream.ui.view.View
-
resizeFrame
public void resizeFrame(int width, int height) Description copied from class:ViewPanelSet the size of the view frame, if any. If this view has been open in a frame, this changes the size of the frame containing it.- Specified by:
resizeFramein classViewPanel- Parameters:
width- The new width.height- The new height.
-
openInAFrame
public void openInAFrame(boolean on) - Specified by:
openInAFramein interfaceorg.graphstream.ui.view.View
-
render
-
beginSelectionAt
public void beginSelectionAt(double x1, double y1) - Specified by:
beginSelectionAtin interfaceorg.graphstream.ui.view.View
-
selectionGrowsAt
public void selectionGrowsAt(double x, double y) - Specified by:
selectionGrowsAtin interfaceorg.graphstream.ui.view.View
-
endSelectionAt
public void endSelectionAt(double x2, double y2) - Specified by:
endSelectionAtin interfaceorg.graphstream.ui.view.View
-
windowActivated
- Specified by:
windowActivatedin interfaceWindowListener
-
windowClosed
- Specified by:
windowClosedin interfaceWindowListener
-
windowClosing
- Specified by:
windowClosingin interfaceWindowListener
-
windowDeactivated
- Specified by:
windowDeactivatedin interfaceWindowListener
-
windowDeiconified
- Specified by:
windowDeiconifiedin interfaceWindowListener
-
windowIconified
- Specified by:
windowIconifiedin interfaceWindowListener
-
windowOpened
- Specified by:
windowOpenedin interfaceWindowListener
-
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener
-
componentMoved
- Specified by:
componentMovedin interfaceComponentListener
-
componentResized
- Specified by:
componentResizedin interfaceComponentListener
-
componentShown
- Specified by:
componentShownin interfaceComponentListener
-
allGraphicElementsIn
public Collection<org.graphstream.ui.graphicGraph.GraphicElement> allGraphicElementsIn(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2) - Specified by:
allGraphicElementsInin interfaceorg.graphstream.ui.view.View
-
findGraphicElementAt
public org.graphstream.ui.graphicGraph.GraphicElement findGraphicElementAt(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y) - Specified by:
findGraphicElementAtin interfaceorg.graphstream.ui.view.View
-
moveElementAtPx
public void moveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y) - Specified by:
moveElementAtPxin interfaceorg.graphstream.ui.view.View
-
freezeElement
public void freezeElement(org.graphstream.ui.graphicGraph.GraphicElement element, boolean frozen) - Specified by:
freezeElementin interfaceorg.graphstream.ui.view.View
-
setBackLayerRenderer
-
setForeLayoutRenderer
-
setMouseManager
public void setMouseManager(org.graphstream.ui.view.util.MouseManager manager) - Specified by:
setMouseManagerin interfaceorg.graphstream.ui.view.View
-
enableMouseOptions
public void enableMouseOptions()This is a shortcut to a call setMouseManager with a MouseOverMouseManager instance and with (InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE).- Specified by:
enableMouseOptionsin interfaceorg.graphstream.ui.view.View- Specified by:
enableMouseOptionsin classViewPanel
-
setShortcutManager
public void setShortcutManager(org.graphstream.ui.view.util.ShortcutManager manager) - Specified by:
setShortcutManagerin interfaceorg.graphstream.ui.view.View
-
requireFocus
- Specified by:
requireFocusin interfaceorg.graphstream.ui.view.View
-
addListener
public <T,U> void addListener(T descriptor, U listener) - Specified by:
addListenerin interfaceorg.graphstream.ui.view.View
-
removeListener
public <T,U> void removeListener(T descriptor, U listener) - Specified by:
removeListenerin interfaceorg.graphstream.ui.view.View
-