Class DefaultView
- All Implemented Interfaces:
java.awt.event.ComponentListener
,java.awt.event.WindowListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,org.graphstream.ui.view.View
public class DefaultView extends ViewPanel implements java.awt.event.WindowListener, java.awt.event.ComponentListener
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:
- Serialized Form
-
Nested Class Summary
-
Field Summary
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Constructor Summary
Constructors Constructor Description DefaultView(org.graphstream.ui.view.Viewer viewer, java.lang.String identifier, org.graphstream.ui.view.GraphRenderer renderer)
-
Method Summary
Modifier and Type Method Description <T, U> void
addListener(T descriptor, U listener)
java.util.Collection<org.graphstream.ui.graphicGraph.GraphicElement>
allGraphicElementsIn(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2)
void
beginSelectionAt(double x1, double y1)
void
close(org.graphstream.ui.graphicGraph.GraphicGraph graph)
void
componentHidden(java.awt.event.ComponentEvent e)
void
componentMoved(java.awt.event.ComponentEvent e)
void
componentResized(java.awt.event.ComponentEvent e)
void
componentShown(java.awt.event.ComponentEvent e)
void
display(org.graphstream.ui.graphicGraph.GraphicGraph graph, boolean graphChanged)
void
enableMouseOptions()
This is a shortcut to a call setMouseManager with a MouseOverMouseManager instance and with (InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE).void
endSelectionAt(double x2, double y2)
org.graphstream.ui.graphicGraph.GraphicElement
findGraphicElementAt(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y)
void
freezeElement(org.graphstream.ui.graphicGraph.GraphicElement element, boolean frozen)
org.graphstream.ui.view.camera.Camera
getCamera()
void
moveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y)
void
openInAFrame(boolean on)
void
paintComponent(java.awt.Graphics g)
<T, U> void
removeListener(T descriptor, U listener)
void
render(java.awt.Graphics2D g)
java.lang.Object
requireFocus()
void
resizeFrame(int width, int height)
Set the size of the view frame, if any.void
selectionGrowsAt(double x, double y)
void
setBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)
void
setForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)
void
setMouseManager(org.graphstream.ui.view.util.MouseManager manager)
void
setShortcutManager(org.graphstream.ui.view.util.ShortcutManager manager)
void
windowActivated(java.awt.event.WindowEvent e)
void
windowClosed(java.awt.event.WindowEvent e)
void
windowClosing(java.awt.event.WindowEvent e)
void
windowDeactivated(java.awt.event.WindowEvent e)
void
windowDeiconified(java.awt.event.WindowEvent e)
void
windowIconified(java.awt.event.WindowEvent e)
void
windowOpened(java.awt.event.WindowEvent e)
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, 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
-
Constructor Details
-
DefaultView
public DefaultView(org.graphstream.ui.view.Viewer viewer, java.lang.String identifier, org.graphstream.ui.view.GraphRenderer renderer)
-
-
Method Details
-
getCamera
public org.graphstream.ui.view.camera.Camera getCamera()- Specified by:
getCamera
in interfaceorg.graphstream.ui.view.View
-
display
public void display(org.graphstream.ui.graphicGraph.GraphicGraph graph, boolean graphChanged)- Specified by:
display
in interfaceorg.graphstream.ui.view.View
-
paintComponent
public void paintComponent(java.awt.Graphics g) -
close
public void close(org.graphstream.ui.graphicGraph.GraphicGraph graph)- Specified by:
close
in interfaceorg.graphstream.ui.view.View
-
resizeFrame
public void resizeFrame(int width, int height)Description copied from class:ViewPanel
Set 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:
resizeFrame
in classViewPanel
- Parameters:
width
- The new width.height
- The new height.
-
openInAFrame
public void openInAFrame(boolean on)- Specified by:
openInAFrame
in interfaceorg.graphstream.ui.view.View
-
render
public void render(java.awt.Graphics2D g) -
beginSelectionAt
public void beginSelectionAt(double x1, double y1)- Specified by:
beginSelectionAt
in interfaceorg.graphstream.ui.view.View
-
selectionGrowsAt
public void selectionGrowsAt(double x, double y)- Specified by:
selectionGrowsAt
in interfaceorg.graphstream.ui.view.View
-
endSelectionAt
public void endSelectionAt(double x2, double y2)- Specified by:
endSelectionAt
in interfaceorg.graphstream.ui.view.View
-
windowActivated
public void windowActivated(java.awt.event.WindowEvent e)- Specified by:
windowActivated
in interfacejava.awt.event.WindowListener
-
windowClosed
public void windowClosed(java.awt.event.WindowEvent e)- Specified by:
windowClosed
in interfacejava.awt.event.WindowListener
-
windowClosing
public void windowClosing(java.awt.event.WindowEvent e)- Specified by:
windowClosing
in interfacejava.awt.event.WindowListener
-
windowDeactivated
public void windowDeactivated(java.awt.event.WindowEvent e)- Specified by:
windowDeactivated
in interfacejava.awt.event.WindowListener
-
windowDeiconified
public void windowDeiconified(java.awt.event.WindowEvent e)- Specified by:
windowDeiconified
in interfacejava.awt.event.WindowListener
-
windowIconified
public void windowIconified(java.awt.event.WindowEvent e)- Specified by:
windowIconified
in interfacejava.awt.event.WindowListener
-
windowOpened
public void windowOpened(java.awt.event.WindowEvent e)- Specified by:
windowOpened
in interfacejava.awt.event.WindowListener
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)- Specified by:
componentHidden
in interfacejava.awt.event.ComponentListener
-
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)- Specified by:
componentMoved
in interfacejava.awt.event.ComponentListener
-
componentResized
public void componentResized(java.awt.event.ComponentEvent e)- Specified by:
componentResized
in interfacejava.awt.event.ComponentListener
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)- Specified by:
componentShown
in interfacejava.awt.event.ComponentListener
-
allGraphicElementsIn
public java.util.Collection<org.graphstream.ui.graphicGraph.GraphicElement> allGraphicElementsIn(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2)- Specified by:
allGraphicElementsIn
in interfaceorg.graphstream.ui.view.View
-
findGraphicElementAt
public org.graphstream.ui.graphicGraph.GraphicElement findGraphicElementAt(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y)- Specified by:
findGraphicElementAt
in interfaceorg.graphstream.ui.view.View
-
moveElementAtPx
public void moveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y)- Specified by:
moveElementAtPx
in interfaceorg.graphstream.ui.view.View
-
freezeElement
public void freezeElement(org.graphstream.ui.graphicGraph.GraphicElement element, boolean frozen)- Specified by:
freezeElement
in interfaceorg.graphstream.ui.view.View
-
setBackLayerRenderer
public void setBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer) -
setForeLayoutRenderer
public void setForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer) -
setMouseManager
public void setMouseManager(org.graphstream.ui.view.util.MouseManager manager)- Specified by:
setMouseManager
in 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:
enableMouseOptions
in interfaceorg.graphstream.ui.view.View
- Specified by:
enableMouseOptions
in classViewPanel
-
setShortcutManager
public void setShortcutManager(org.graphstream.ui.view.util.ShortcutManager manager)- Specified by:
setShortcutManager
in interfaceorg.graphstream.ui.view.View
-
requireFocus
public java.lang.Object requireFocus()- Specified by:
requireFocus
in interfaceorg.graphstream.ui.view.View
-
addListener
public <T, U> void addListener(T descriptor, U listener)- Specified by:
addListener
in interfaceorg.graphstream.ui.view.View
-
removeListener
public <T, U> void removeListener(T descriptor, U listener)- Specified by:
removeListener
in interfaceorg.graphstream.ui.view.View
-