|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.graphstream.ui.swingViewer.View
org.graphstream.ui.swingViewer.DefaultView
public class DefaultView
Base for constructing views.
This base view is an abstract class that provides mechanism that are necessary in any view :
This view also handle a current selection of nodes and sprites.
This mechanism pushes a repaint query each time the viewer asks us to
repaint. Two flags are provided to know what to repaint :
graphChanged
allows to know when the graph needs to be rendered anew
because its structure changed and canvasChanged
allows to know one
must repaint because the rendering canvas was resized, shown, etc.
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.
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.
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.BaselineResizeBehavior |
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 |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
DefaultView(Viewer viewer,
String identifier,
GraphRenderer renderer)
|
Method Summary | |
---|---|
ArrayList<GraphicElement> |
allNodesOrSpritesIn(double x1,
double y1,
double x2,
double y2)
Search for all the nodes and sprites contained inside the rectangle (x1,y1)-(x2,y2). |
void |
beginSelectionAt(double x1,
double y1)
Called by the mouse manager to specify where a node and sprite selection started. |
void |
close(GraphicGraph graph)
Close definitively this view. |
void |
componentHidden(ComponentEvent e)
|
void |
componentMoved(ComponentEvent e)
|
void |
componentResized(ComponentEvent e)
|
void |
componentShown(ComponentEvent e)
|
void |
display(GraphicGraph graph,
boolean graphChanged)
Redisplay or update the view contents. |
void |
endSelectionAt(double x2,
double y2)
Called by the mouse manager to specify where a node and spite selection stopped. |
GraphicElement |
findNodeOrSpriteAt(double x,
double y)
Search for the first node or sprite (in that order) that contains the point at coordinates (x, y). |
Camera |
getCamera()
Get a camera object to provide control commands on the view. |
void |
moveElementAtPx(GraphicElement element,
double x,
double y)
Force an element to move at the given location in pixels. |
void |
openInAFrame(boolean on)
Open this view JPanel in a frame. |
void |
paint(Graphics g)
|
void |
render(Graphics2D g)
|
void |
resizeFrame(int width,
int height)
Set the size of the view frame, if any. |
void |
selectionGrowsAt(double x,
double y)
The selection already started grows toward position (x, y). |
void |
setBackLayerRenderer(LayerRenderer renderer)
Set a layer renderer that will be called each time the graph needs to be redrawn before the graph is rendered. |
void |
setForeLayoutRenderer(LayerRenderer renderer)
Set a layer renderer that will be called each time the graph needs to be redrawn after the graph is rendered. |
void |
windowActivated(WindowEvent e)
|
void |
windowClosed(WindowEvent e)
|
void |
windowClosing(WindowEvent e)
|
void |
windowDeactivated(WindowEvent e)
|
void |
windowDeiconified(WindowEvent e)
|
void |
windowIconified(WindowEvent e)
|
void |
windowOpened(WindowEvent e)
|
Methods inherited from class org.graphstream.ui.swingViewer.View |
---|
getId |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DefaultView(Viewer viewer, String identifier, GraphRenderer renderer)
Method Detail |
---|
public Camera getCamera()
View
getCamera
in class View
public void display(GraphicGraph graph, boolean graphChanged)
View
display
in class View
graph
- The graphic graph to represent.graphChanged
- True if the graph changed since the last call to this method.public void paint(Graphics g)
paint
in class JComponent
public void close(GraphicGraph graph)
View
close
in class View
graph
- The graphic graph.public void resizeFrame(int width, int height)
View
resizeFrame
in class View
width
- The new width.height
- The new height.public void openInAFrame(boolean on)
View
openInAFrame
in class View
on
- Add the panel in its own frame or remove it if it already was
in its own frame.public void render(Graphics2D g)
public void beginSelectionAt(double x1, double y1)
View
beginSelectionAt
in class View
x1
- The selection start abscissa.y1
- The selection start ordinate.public void selectionGrowsAt(double x, double y)
View
selectionGrowsAt
in class View
x
- The new end selection abscissa.y
- The new end selection ordinate.public void endSelectionAt(double x2, double y2)
View
endSelectionAt
in class View
x2
- The selection stop abscissa.y2
- The selection stop ordinate.public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void windowActivated(WindowEvent e)
windowActivated
in interface WindowListener
public void windowClosed(WindowEvent e)
windowClosed
in interface WindowListener
public void windowClosing(WindowEvent e)
windowClosing
in interface WindowListener
public void windowDeactivated(WindowEvent e)
windowDeactivated
in interface WindowListener
public void windowDeiconified(WindowEvent e)
windowDeiconified
in interface WindowListener
public void windowIconified(WindowEvent e)
windowIconified
in interface WindowListener
public void windowOpened(WindowEvent e)
windowOpened
in interface WindowListener
public ArrayList<GraphicElement> allNodesOrSpritesIn(double x1, double y1, double x2, double y2)
View
allNodesOrSpritesIn
in class View
x1
- The rectangle lowest point abscissa.y1
- The rectangle lowest point ordinate.x2
- The rectangle highest point abscissa.y2
- The rectangle highest point ordinate.
public GraphicElement findNodeOrSpriteAt(double x, double y)
View
findNodeOrSpriteAt
in class View
x
- The point abscissa.y
- The point ordinate.
public void moveElementAtPx(GraphicElement element, double x, double y)
View
moveElementAtPx
in class View
element
- The element.x
- The requested position abscissa in pixels.y
- The requested position ordinate in pixels.public void setBackLayerRenderer(LayerRenderer renderer)
View
setBackLayerRenderer
in class View
renderer
- The renderer (or null to remove it).public void setForeLayoutRenderer(LayerRenderer renderer)
View
setForeLayoutRenderer
in class View
renderer
- The renderer (or null to remove it).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |