V
- the type of vertex that should be used in the graph viewE
- the type of edge that should be used in the graph viewpublic class GraphView<V extends Vertex,E extends Edge> extends View implements Serializable
GraphView(String, Graph, GraphFactory, boolean, LanguageFile, String)
to specify a language file from which
labels, tooltips and messages are read by the given language id. The following language labels are available:
Resources.LANGUAGE_FILE
.
GraphView.VisualVertex
and each edge by a GraphView.VisualEdge
. Use this objects to change the color or line width
of the vertices/edges. To get access to the visual objects use one of the getVisualVertex(int)
/getVisualEdge(int)
methods.setFont(Font)
to set a specific font for the display of text, like vertex captions or edge labels.
CustomVisualObject
s. With addVisualObject(CustomVisualObject)
you add new
objects and with removeVisualObject(CustomVisualObject)
you can remove the added objects. there are default implementations
for CustomVisualText
setShowCursorToolAlways(boolean)
, setShowZoomToolsAlways(boolean)
and setHideGraphToolsAlways(boolean)
to enable specific tools even if the graph is (not)
editable.
loadAdvancedVertexProperties(PropertiesListModel, Vertex)
/loadAdvancedEdgeProperties(PropertiesListModel, Edge)
and
applyAdvancedVertexProperties(PropertiesListModel, Vertex)
/applyAdvancedEdgeProperties(PropertiesListModel, Edge)
to load and apply
vertex/edge data. The graph view only covers the default/general properties of Vertex
and Edge
by default.
GraphScene
s to visualize a sequence of visual effects on the graph that can be made undone.
ignoreKeyboardInput()
.
setVPASTolerance(int)
to set this tolerance yourself.
setDynamicEdgeLabeling(boolean)
.
VertexRenderer
and EdgeRenderer
. The default implementations are DefaultVertexRenderer
and DefaultEdgeRenderer
.
setZoom(int)
or zoomIn()
/zoomOut()
.
save(String)
to save a visual graph in the .vgf format and call load(String)
to load one. The .vgf format is
independent from the objects used in the graph view. That means you can load a visual graph that is generated by another graph view
with types of Vertex
and Edge
that differ from the ones in this graph view.saveAsPNG(String)
.
transferGraph(GraphTransferProtocol)
you can transfer a graph structure from another graph view into this one.
View.saveConfiguration(Configuration)
and View.loadConfiguration(Configuration)
.
It is saved or restored the visibility of the view, the toolbar orientation, the zoom value, the selection color and the edge tool color
of the graph view. This makes it possible that you can store the state of the view persistent.GraphScene
,
GraphLayout
,
GraphTransferProtocol
,
DefaultGraphView
,
DefaultNetworkView
,
Serialized FormModifier and Type | Class and Description |
---|---|
class |
GraphView.CircleGraphLayout
Graph layout algorithm that arranges the vertices of the graph in a circle.
|
protected class |
GraphView.EdgeOffset
A mapping object between an edge and its offset.
|
static class |
GraphView.SelectionType
The selection type.
|
class |
GraphView.VisualEdge
Represents the visual component of an
Edge . |
class |
GraphView.VisualVertex
Represents the visual component of a
Vertex . |
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
DEF_EDGECOLOR
the default color of an edge
|
static int |
DEF_EDGELINEWIDTH
the default line width of an edge
|
static java.awt.Color |
DEF_VERTEXBACKGROUND
the default background of a vertex
|
static int |
DEF_VERTEXEDGEWIDTH
the default line width of a the vertex edge
|
static java.awt.Color |
DEF_VERTEXFOREGROUND
the default foreground of a vertex
|
static java.lang.String |
VISUALGRAPHFILE_EXT
the extension of a visual graph file (.vgf)
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory)
Creates a new view of a graph.
|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory,
boolean closable)
Creates a new view of a graph.
|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory,
boolean closable,
LanguageFile langFile,
java.lang.String langID)
Creates a new view of a graph.
|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory,
GraphLayout graphLayout)
Creates a new view of a graph.
|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory,
GraphLayout graphLayout,
boolean closable)
Creates a new view of a graph.
|
GraphView(java.lang.String title,
Graph<V,E> graph,
GraphFactory<V,E> graphFactory,
GraphLayout graphLayout,
boolean closable,
LanguageFile langFile,
java.lang.String langID)
Creates a new view of a graph.
|
Modifier and Type | Method and Description |
---|---|
void |
addGraphViewListener(GraphViewListener<V,E> listener)
Adds a listener to listen to graph view events.
|
protected void |
addToolbarButton(javax.swing.JButton button)
Adds a new button to the toolbar.
|
void |
addVisualObject(CustomVisualObject cvo)
Adds a new custom visual object to the graph view.
|
protected void |
afterPaint(java.awt.Graphics2D g)
This method is invoked after the graphical representation of the graph view is painted.
|
protected void |
afterVisualEdgeCreated(GraphView.VisualEdge ve)
This method is invoked after a new visual edge is created using graphical input by the user.
|
protected void |
afterVisualVertexCreated(GraphView.VisualVertex vv)
This method is invoked after a new visual vertex is created using graphical input by the user.
|
protected void |
applyAdvancedEdgeProperties(PropertiesListModel plm,
E edge)
Applies the advanced properties of an edge to the given edge.
|
protected void |
applyAdvancedVertexProperties(PropertiesListModel plm,
V vertex)
Applies the advanced properties of a vertex to the given vertex.
|
protected void |
applyKeyboardInput(E edge,
java.lang.String input)
Applies the keyboard input the user has entered to an edge.
|
protected void |
applyKeyboardInput(V vertex,
java.lang.String input)
Applies the keyboard input the user has entered to a vertex.
|
protected void |
autoRepaint()
Repaints the view but only if auto repainting is allowed.
|
protected void |
beforePaint(java.awt.Graphics2D g)
This method is invoked before the graphical representation of the graph view is painted.
|
protected boolean |
beforeVisualEdgeCreated(GraphView.VisualVertex predecessor,
GraphView.VisualVertex successor,
boolean directed)
This method is invoked before a new visual edge is created using graphical input by the user.
|
protected boolean |
beforeVisualVertexCreated(int x,
int y)
This method is invoked before a new visual vertex is created using graphical input by the user.
|
GraphView.CircleGraphLayout |
createCircleGraphLayout()
Creates a new instance of a
GraphView.CircleGraphLayout . |
protected GraphView.VisualEdge |
createVisualEdge(GraphView.VisualVertex predecessor,
GraphView.VisualVertex successor)
Adds a new (undirected) visual edge to the graph between two specified vertices.
|
protected GraphView.VisualEdge |
createVisualEdge(GraphView.VisualVertex predecessor,
GraphView.VisualVertex successor,
boolean directed)
Adds a new visual edge to the graph between two specified vertices.
|
protected GraphView.VisualVertex |
createVisualVertex(int x,
int y)
Creates a new visual vertex at the specified position.
|
void |
deselectAll()
Deselects all selected vertices and edges, that means no object is selected anymore.
|
void |
deserialize(Serializer s)
Deserializes (loads) the object data from the given serializer.
|
boolean |
getAutoRepaint()
Indicates whether auto repaint is enabled in the view.
|
GraphView.VisualEdge |
getEdgeFromPosition(int x,
int y)
Gets an edge from the given position.
|
int |
getEdgeOffsetDistance()
Gets the offset distance of edges.
|
java.awt.Color |
getEdgeToolColor()
Gets the color of the edge tool (the path that is be drawn when user uses left and right mouse button
to connect vertices).
|
java.awt.Font |
getFont()
Gets the font of the graph view.
|
Graph<V,E> |
getGraph()
Gets the graph of the graph view.
|
GraphFactory<V,E> |
getGraphFactory()
Gets the graph factory which creates the vertices and edges in the graph view.
|
int |
getLastZoom()
Gets the last zoom value in percent (integral values).
|
int |
getScaledVertexRadius(GraphView.VisualVertex v)
Gets the scaled radius of the given vertex.
|
GraphView.VisualEdge |
getSelectedEdge(int index)
Gets the selected edge at the given index.
|
int |
getSelectedEdgeCount()
Gets the amount of edges which are currently selected.
|
GraphView.VisualVertex |
getSelectedVertex(int index)
Gets the selected vertex at the given index.
|
int |
getSelectedVertexCount()
Gets the amount of vertices which are currently selected.
|
java.awt.Color |
getSelectionColor()
Gets the color of selected vertices or edges.
|
GraphView.SelectionType |
getSelectionType()
Gets the selection type of the graph indicating which objects (vertices and edges) a user can select.
|
GraphView.VisualVertex |
getVertexFromPosition(int x,
int y)
Gets a vertex from the given position.
|
GraphView.VisualEdge |
getVisualEdge(Edge e)
Gets the visual edge of a given edge.
|
GraphView.VisualEdge |
getVisualEdge(int index)
Gets the visual edge at the given index.
|
GraphView.VisualEdge |
getVisualEdgeByID(int id)
Gets the visual edge of a given edge id.
|
int |
getVisualEdgeCount()
Gets the number of edges that are shown in the graph view.
|
CustomVisualObject |
getVisualObject(int index)
Gets the custom visual object at the given index.
|
int |
getVisualObjectCount()
Gets the number of custom visual objects.
|
GraphView.VisualVertex |
getVisualVertex(int index)
Gets the visual vertex at the given index.
|
GraphView.VisualVertex |
getVisualVertex(Vertex v)
Gets the visual vertex of a given vertex.
|
GraphView.VisualVertex |
getVisualVertexByCaption(java.lang.String caption)
Gets the visual vertex with the given caption.
|
GraphView.VisualVertex |
getVisualVertexByID(int id)
Gets the visual vertex of a given vertex id.
|
int |
getVisualVertexCount()
Gets the number of vertices that are shown in the graph view.
|
int |
getVPASTolerance()
Gets the tolerance value of the Vertex Position Adjustment System (VPAS).
|
int |
getZoom()
Gets the current zoom value in percent (integral values).
|
boolean |
hasDynamicEdgeLabeling()
Indicates wether the graph view supports dynamic edge labeling.
|
boolean |
hasRestorableEditMode()
Indicates whether the old edit state is restorable.
|
protected boolean |
ignoreKeyboardInput()
Indicates if the keyboard input should be ignored meaning that the weight of a selected edge or the
caption of a selected vertex cannot be modified by using the keyboard input any longer.
|
boolean |
isEditable()
Indicates whether the graph view is editable (that means the toolbar is visible and the user can modify the graph)
or not.
|
void |
layoutGraph(GraphLayout graphLayout)
Layouts the graph that means all vertices of the graph are automatically positioned by the
layout algorithm specified in the
GraphLayout . |
void |
load(java.io.File file)
Loads a visual graph from a file.
|
void |
load(java.lang.String filename)
Loads a visual graph from a file.
|
protected void |
loadAdvancedEdgeProperties(PropertiesListModel plm,
E edge)
Loads the advanced properties of an edge that aren't elements of the super class
Edge and adds them to
the properties list model. |
protected void |
loadAdvancedVertexProperties(PropertiesListModel plm,
V vertex)
Loads the advanced properties of a vertex that aren't elements of the super class
Vertex and adds them to
the properties list model. |
protected void |
readConfigurationData(Configuration cd)
Reads the configuration data of the view.
|
void |
removeAllEdges()
Removes all the edges from the visual graph and its graph data structure.
|
void |
removeAllVertices()
Removes all the vertices from the visual graph and its graph data structure.
|
void |
removeAllVisualObjects()
Removes all the visual objects from the graph view.
|
void |
removeGraphViewListener(GraphViewListener<V,E> listener)
Removes a listener from the graph view.
|
protected void |
removeVisualEdge(GraphView.VisualEdge e)
Removes a visual edge of the graph.
|
void |
removeVisualObject(CustomVisualObject cvo)
Removes a custom visal object from the graph view.
|
protected void |
removeVisualVertex(GraphView.VisualVertex v)
Removes a visual vertex of the graph and all its edges.
|
protected void |
repaintComponent()
Repaints the component.
|
protected java.util.List<GraphView.EdgeOffset> |
requestOffsetEdges(GraphView.VisualVertex v,
GraphView.VisualVertex u)
Requests the edges between two vertices its offset have to be updated.
|
void |
reset()
Resets the graph view meaning that all vertices, edges and custom visual objects are removed from the graph if procurable
(it could be that some vertices/edges are not removable).
|
void |
resetVisualAppearance()
Sets the default visual appearance for all vertices and edges.
|
void |
save(java.io.File file)
Saves the visual graph to a file.
|
void |
save(java.lang.String filename)
Saves the visual graph to a file.
|
void |
saveAsPNG(java.io.File file)
Saves the graph as an image in the PNG format.
|
void |
saveAsPNG(java.lang.String filename)
Saves the graph as an image in the PNG format.
|
void |
selectEdge(GraphView.VisualEdge e,
boolean multiSelect)
Selects a visual edge.
|
void |
selectEdges(java.util.List<GraphView.VisualEdge> edges)
Selects all visual edges in the list.
|
protected void |
selectTool(lavesdk.algorithm.plugin.views.GraphView.Tool tool)
Selects a tool of the toolbar.
|
void |
selectVertex(GraphView.VisualVertex v,
boolean multiSelect)
Selects a visual vertex.
|
void |
selectVertices(java.util.List<GraphView.VisualVertex> vertices)
Selects all visual vertices in the list.
|
void |
serialize(Serializer s)
Serializes (saves) the object data to the given serializer.
|
void |
setAutoRepaint(boolean autoRepaint)
Sets whether the view is allowed to be auto repainted.
|
void |
setDynamicEdgeLabeling(boolean enable)
Sets wether the graph view supports dynamic edge labeling.
|
void |
setEdgeOffsetDistance(int distance)
Sets the offset distance of edges that go in the same direction from the same vertex.
|
void |
setEdgeRenderer(EdgeRenderer<E> renderer)
Sets an individual renderer for the edges of the graph.
|
void |
setEdgeToolColor(java.awt.Color c)
Sets the color of the edge tool (the path that is be drawn when user uses left and right mouse button
to connect vertices).
|
void |
setEditable(boolean editable)
Sets the editable state of the graph view meaning whether the user can edit the graph that is displayed in the view
or not.
|
void |
setFont(java.awt.Font f)
Sets the font of the graph view.
|
void |
setGraph(Graph<V,E> graph)
Sets the graph of the graph view.
|
void |
setHideGraphToolsAlways(boolean hide)
Sets whether the graph tools (buttons for adding vertices, adding edges or removing objects) in the toolbar should always be hidden even if the graph view
is editable.
|
void |
setRestorableEditMode(boolean restorable)
Sets whether the old edit state is restorable.
|
void |
setSelectionColor(java.awt.Color c)
Sets the color of selected vertices or edges.
|
void |
setSelectionType(GraphView.SelectionType type)
Sets the selection type of the graph indicating which objects (vertices and edges) a user can select.
|
void |
setShowCursorToolAlways(boolean show)
Sets whether the cursor tool (cursor/mouse button) in the toolbar should always be shown even if the graph view
is not editable.
|
void |
setShowZoomToolsAlways(boolean show)
Sets whether the zoom tools (zoom in/out buttons) in the toolbar should always be shown even if the graph view
is not editable.
|
void |
setVertexRenderer(VertexRenderer<V> renderer)
Sets an individual renderer for the vertices of the graph.
|
void |
setVPASTolerance(int tolerance)
Sets the tolerance value of the Vertex Position Adjustment System (VPAS).
|
void |
setZoom(int z)
Sets the current zoom value in percent.
|
<N extends Vertex,L extends Edge> |
transferGraph(GraphTransferProtocol<N,L> gtp)
Transfers a graph of another graph view into this one.
|
protected void |
writeConfigurationData(Configuration cd)
Writes the configuration data of the view.
|
void |
zoomIn()
Zooms in the graph view.
|
void |
zoomOut()
Zooms out of the graph view.
|
addHeaderBarComponent, addHeaderBarSeparator, addImpl, beforeRemove, close, extendTitle, getContentPanel, getTitle, highlight, highlight, isClosable, isVisible, loadConfiguration, loadConfiguration, removeAll, removeHeaderBarComponent, saveConfiguration, saveConfiguration, setBorder, setCloseButtonToolTip, setLayout, setVisible, toString
isRepaintDisabled, repaint, setRepaintDisabled
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, 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, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
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, processContainerEvent, processEvent, remove, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
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, 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, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String VISUALGRAPHFILE_EXT
public static final java.awt.Color DEF_VERTEXBACKGROUND
public static final java.awt.Color DEF_VERTEXFOREGROUND
public static final int DEF_VERTEXEDGEWIDTH
public static final java.awt.Color DEF_EDGECOLOR
public static final int DEF_EDGELINEWIDTH
public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory) throws java.lang.IllegalArgumentException
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphFactory
- the factory of the graph that creates the vertices and edgesjava.lang.IllegalArgumentException
- public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory, boolean closable) throws java.lang.IllegalArgumentException
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphFactory
- the factory of the graph that creates the vertices and edgesclosable
- true
if the graph view can be closed by the user using the "X" in the header bar otherwise false
(if a graph view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)java.lang.IllegalArgumentException
- public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory, GraphLayout graphLayout) throws java.lang.IllegalArgumentException
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphLayout
- the graph layout to layout the vertices of the graph automatically or null
for the default layoutjava.lang.IllegalArgumentException
- public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory, GraphLayout graphLayout, boolean closable) throws java.lang.IllegalArgumentException
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphFactory
- the factory of the graph that creates the vertices and edgesgraphLayout
- the graph layout to layout the vertices of the graph automatically or null
for the default layoutclosable
- true
if the graph view can be closed by the user using the "X" in the header bar otherwise false
(if a graph view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)java.lang.IllegalArgumentException
- public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory, boolean closable, LanguageFile langFile, java.lang.String langID) throws java.lang.IllegalArgumentException
LanguageFile
and a language id to display language dependent
messages or tooltips in the graph view. The following language labels are available:
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphFactory
- the factory of the graph that creates the vertices and edgesclosable
- true
if the graph view can be closed by the user using the "X" in the header bar otherwise false
(if a graph view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)langFile
- the language file or null
if the graph view should not use language dependent labels, tooltips or messages (in this case the predefined labels, tooltips and messages are shown)langID
- the language idjava.lang.IllegalArgumentException
- public GraphView(java.lang.String title, Graph<V,E> graph, GraphFactory<V,E> graphFactory, GraphLayout graphLayout, boolean closable, LanguageFile langFile, java.lang.String langID) throws java.lang.IllegalArgumentException
LanguageFile
and a language id to display language dependent
messages or tooltips in the graph view. The following language labels are available:
GraphLayout
.title
- the title of the view which is displayed in the header bargraph
- the graphgraphFactory
- the factory of the graph that creates the vertices and edgesgraphLayout
- the graph layout to layout the vertices of the graph automatically or null
for the default layoutclosable
- true
if the graph view can be closed by the user using the "X" in the header bar otherwise false
(if a graph view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)langFile
- the language file or null
if the graph view should not use language dependent labels, tooltips or messages (in this case the predefined labels, tooltips and messages are shown)langID
- the language idjava.lang.IllegalArgumentException
- public boolean getAutoRepaint()
getAutoRepaint
in class View
true
if auto repainting is allowed otherwise false
public void setAutoRepaint(boolean autoRepaint)
BaseComponent.repaint()
on your own to visualize the changes you made to a component or view.
BaseComponent.repaint()
method of the view is automatically
invoked to make the changes visible. But ensure that this does not overload the EDT (event dispatch thread).n
objects in a loop and you activate the auto repaint option.n
calls to BaseComponent.repaint()
instead of one call at the end of the loop.GuiRequest
) and in consequence of that
the algorithm must wait until the pending event is processed in the EDT.setAutoRepaint
in class View
autoRepaint
- true
if auto repainting should be enabled otherwise false
public final void addGraphViewListener(GraphViewListener<V,E> listener)
listener
- the listenerpublic final void removeGraphViewListener(GraphViewListener<V,E> listener)
listener
- the listenerpublic final boolean isEditable()
true
if user may modify the graph otherwise false
public final void setEditable(boolean editable)
setShowCursorToolAlways(boolean)
/setShowZoomToolsAlways(boolean)
.
editable
- true
if user may modify the graph otherwise false
hasRestorableEditMode()
public final boolean hasRestorableEditMode()
true
if the previous edit state is restoreable otherwise false
public final void setRestorableEditMode(boolean restorable)
restorable
- true
if it should be possible that the previous edit mode is restorable otherwise false
public final void setShowZoomToolsAlways(boolean show)
show
- true
if the zoom buttons should be visible even if the graph view is not editable otherwise false
public final void setShowCursorToolAlways(boolean show)
show
- true
if the cursor button should be visible even if the graph view is not editable otherwise false
public final void setHideGraphToolsAlways(boolean hide)
hide
- true
if the graph buttons should be invisible even if the graph view is editable otherwise false
public GraphView.SelectionType getSelectionType()
public void setSelectionType(GraphView.SelectionType type)
type
- the selection typepublic int getLastZoom()
v
you have to apply (v / lastZoom) * zoom
.
public int getZoom()
public void setZoom(int z)
z
- the zoom, like 100%, 50%, 150%, ...public void zoomIn()
public void zoomOut()
public int getEdgeOffsetDistance()
public void setEdgeOffsetDistance(int distance) throws java.lang.IllegalArgumentException
distance
- the distancejava.lang.IllegalArgumentException
- < 0
public int getVPASTolerance()
public void setVPASTolerance(int tolerance) throws java.lang.IllegalArgumentException
tolerance
- the tolerance of the VPAS (by default: 5 pixels)java.lang.IllegalArgumentException
- < 0
public boolean hasDynamicEdgeLabeling()
true
if dynamic edge labeling is enabled otherwise false
public void setDynamicEdgeLabeling(boolean enable)
enable
- true
if dynamic edge labeling is enabled otherwise false
public void setVertexRenderer(VertexRenderer<V> renderer) throws java.lang.IllegalArgumentException
renderer
- the rendererjava.lang.IllegalArgumentException
- public void setEdgeRenderer(EdgeRenderer<E> renderer) throws java.lang.IllegalArgumentException
renderer
- the rendererjava.lang.IllegalArgumentException
- public java.awt.Color getSelectionColor()
public void setSelectionColor(java.awt.Color c) throws java.lang.IllegalArgumentException
c
- the selection colorjava.lang.IllegalArgumentException
- public java.awt.Color getEdgeToolColor()
public void setEdgeToolColor(java.awt.Color c) throws java.lang.IllegalArgumentException
c
- the color of the edge tool pathjava.lang.IllegalArgumentException
- public final int getVisualVertexCount()
public final GraphView.VisualVertex getVisualVertex(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getVisualVertexCount()
)public final GraphView.VisualVertex getVisualVertex(Vertex v)
v
- the vertex its visual component is searchednull
if the graph view has no visual vertex for the specified onepublic final GraphView.VisualVertex getVisualVertexByID(int id)
id
- the identifier of the vertex its visual component is searchednull
if the graph view has no visual vertex for the specified vertex idpublic final GraphView.VisualVertex getVisualVertexByCaption(java.lang.String caption)
caption
- the caption of the vertex its visual component is searchednull
if the graph view has no visual vertex with the specified captionpublic final int getSelectedVertexCount()
public final GraphView.VisualVertex getSelectedVertex(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getSelectedVertexCount()
)public final int getVisualEdgeCount()
public final GraphView.VisualEdge getVisualEdge(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getVisualEdgeCount()
)public final GraphView.VisualEdge getVisualEdge(Edge e)
e
- the edge its visual component is searchednull
if the graph view has no visual edge for the specified onepublic final GraphView.VisualEdge getVisualEdgeByID(int id)
id
- the identifier of the edge its visual component is searchednull
if the graph view has no visual edge for the specified edge idpublic final int getSelectedEdgeCount()
public final GraphView.VisualEdge getSelectedEdge(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getSelectedEdgeCount()
)public void selectVertex(GraphView.VisualVertex v, boolean multiSelect)
v
- the vertexmultiSelect
- true
if multi select should be used (that means more than one vertex or edge can be selected) otherwise false
public void selectVertices(java.util.List<GraphView.VisualVertex> vertices)
vertices
- the list of vertices that should be selectedpublic void selectEdge(GraphView.VisualEdge e, boolean multiSelect)
e
- the edgemultiSelect
- true
if multi select should be used (that means more than one edge or vertex can be selected) otherwise false
public void selectEdges(java.util.List<GraphView.VisualEdge> edges)
edges
- the list of edges that should be selectedpublic void deselectAll()
public void removeAllVertices()
public void removeAllEdges()
public GraphFactory<V,E> getGraphFactory()
public Graph<V,E> getGraph()
public void setGraph(Graph<V,E> graph) throws java.lang.IllegalArgumentException
layoutGraph(GraphLayout)
otherwise existing vertices will be positioned at (0,0).
graph
- the graphjava.lang.IllegalArgumentException
- layoutGraph(GraphLayout)
public void layoutGraph(GraphLayout graphLayout) throws java.lang.IllegalArgumentException
GraphLayout
.
graphLayout
- the graph layout to layout the vertices of the graph automaticallyjava.lang.IllegalArgumentException
- createCircleGraphLayout()
public <N extends Vertex,L extends Edge> void transferGraph(GraphTransferProtocol<N,L> gtp) throws java.lang.IllegalArgumentException
gtp
- the graph transfer protocoljava.lang.IllegalArgumentException
- public GraphView.CircleGraphLayout createCircleGraphLayout()
GraphView.CircleGraphLayout
.layoutGraph(GraphLayout)
public java.awt.Font getFont()
getFont
in interface java.awt.MenuContainer
getFont
in class java.awt.Component
public void setFont(java.awt.Font f)
setFont
in class javax.swing.JComponent
f
- the fontpublic void load(java.io.File file) throws java.lang.IllegalArgumentException, java.io.IOException
file
- the file (if the file does not end with VISUALGRAPHFILE_EXT
then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- public void load(java.lang.String filename) throws java.lang.IllegalArgumentException, java.io.IOException
filename
- the file name (if the file name does not end with VISUALGRAPHFILE_EXT
then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- public void save(java.io.File file) throws java.lang.IllegalArgumentException, java.io.IOException
file
- the file (if the file does not end with VISUALGRAPHFILE_EXT
then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- resetVisualAppearance()
public void save(java.lang.String filename) throws java.lang.IllegalArgumentException, java.io.IOException
filename
- the file name (if the file name does not end with VISUALGRAPHFILE_EXT
then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- resetVisualAppearance()
public void saveAsPNG(java.io.File file) throws java.lang.IllegalArgumentException, java.io.IOException
file
- the file (if the file does not end with ".png" then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- public void saveAsPNG(java.lang.String filename) throws java.lang.IllegalArgumentException, java.io.IOException
filename
- the filename (if the file name does not end with ".png" then the extension is added)java.lang.IllegalArgumentException
- java.io.IOException
- public void reset()
reset
in class View
removeAllVertices()
,
removeAllEdges()
,
resetVisualAppearance()
public void resetVisualAppearance()
DEF_VERTEXBACKGROUND
,
DEF_VERTEXFOREGROUND
,
DEF_VERTEXEDGEWIDTH
,
DEF_EDGECOLOR
,
DEF_EDGELINEWIDTH
public GraphView.VisualVertex getVertexFromPosition(int x, int y)
x
- the x positiony
- the y positionnull
if there is no vertexpublic GraphView.VisualEdge getEdgeFromPosition(int x, int y)
x
- the x positiony
- the y positionnull
if there is no edgepublic int getScaledVertexRadius(GraphView.VisualVertex v)
v
- the vertexpublic void addVisualObject(CustomVisualObject cvo) throws java.lang.IllegalArgumentException
cvo
- the visual objectjava.lang.IllegalArgumentException
- public void removeVisualObject(CustomVisualObject cvo)
cvo
- the visual object that should be removedpublic void removeAllVisualObjects()
public int getVisualObjectCount()
public CustomVisualObject getVisualObject(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getVisualObjectCount()
)public void serialize(Serializer s)
Serializable
s
- the serializer for the objectpublic void deserialize(Serializer s)
Serializable
s
- the serializerprotected void repaintComponent()
BaseComponent.repaint()
. You can override this method to repaint sub-components but ensure that
the super type method is invoked too meaning:
protected void repaintComponent() { // repaint the parent super.repaintComponent(); // repaint sub-components ... }
repaintComponent
in class BaseComponent
protected void autoRepaint()
autoRepaint
in class View
protected void readConfigurationData(Configuration cd)
... protected void readConfigurationData(Configuration cd) { super.readConfigurationData(cd); // load custom data like // foreground = cd.getColor("foreground"); // ... } ...Furthermore it is read the toolbar orientation (key "toolBarOrientation"), the zoom value (key "zoom"), the selection color (key "selColor") and the edge tool color (key "edgeToolColor") of the graph view.
readConfigurationData
in class View
cd
- the configuration dataprotected void writeConfigurationData(Configuration cd)
... protected void writeConfigurationData(Configuration cd) { super.writeConfigurationData(cd); // write custom data like // cd.addColor("foreground", foreground); // ... } ...Furthermore it is written the toolbar orientation (key "toolBarOrientation"), the zoom value (key "zoom"), the selection color (key "selColor") and the edge tool color (key "edgeToolColor") of the graph view.
writeConfigurationData
in class View
cd
- the configuration dataprotected final GraphView.VisualVertex createVisualVertex(int x, int y)
fireVertexAdded(VisualVertex)
.x
- the x position of the vertexy
- the y position of the vertexnull
if vertex could not be addedprotected final void removeVisualVertex(GraphView.VisualVertex v)
fireVertexRemoved(VisualVertex)
.v
- the vertex that should be removedprotected final GraphView.VisualEdge createVisualEdge(GraphView.VisualVertex predecessor, GraphView.VisualVertex successor) throws java.lang.IllegalArgumentException
fireEdgeAdded(VisualEdge)
.predecessor
- the predecessor of the edgesuccessor
- the successor of the edgenull
if edge could not be addedjava.lang.IllegalArgumentException
- protected final GraphView.VisualEdge createVisualEdge(GraphView.VisualVertex predecessor, GraphView.VisualVertex successor, boolean directed) throws java.lang.IllegalArgumentException
fireEdgeAdded(VisualEdge)
.predecessor
- the predecessor of the edgesuccessor
- the successor of the edgedirected
- true
if the edge should be directed or false
if the edge should be undirectednull
if edge could not be addedjava.lang.IllegalArgumentException
- protected final void removeVisualEdge(GraphView.VisualEdge e)
e
- the edge that should be removedprotected final void addToolbarButton(javax.swing.JButton button) throws java.lang.IllegalArgumentException
button
- the buttonjava.lang.IllegalArgumentException
- protected void selectTool(lavesdk.algorithm.plugin.views.GraphView.Tool tool)
tool
- the toolprotected void beforePaint(java.awt.Graphics2D g)
g
- the graphics contextprotected void afterPaint(java.awt.Graphics2D g)
g
- the graphics contextprotected boolean beforeVisualVertexCreated(int x, int y)
x
- the x position of the vertex centery
- the y position of the vertex centertrue
if vertex may be created otherwise false
protected boolean beforeVisualEdgeCreated(GraphView.VisualVertex predecessor, GraphView.VisualVertex successor, boolean directed)
predecessor
- the predecessor of the edgesuccessor
- the successor of the edgedirected
- true
if the edge should be directed or false
if the edge should be undirectedtrue
if edge may be created otherwise false
protected void afterVisualVertexCreated(GraphView.VisualVertex vv)
vv
- visual vertex that was createdprotected void afterVisualEdgeCreated(GraphView.VisualEdge ve)
ve
- visual edge that was createdprotected void loadAdvancedVertexProperties(PropertiesListModel plm, V vertex)
Vertex
and adds them to
the properties list model.
Vertex
are covered by the graph view.plm
- the properties list modelvertex
- the vertex which properties should be loadedprotected void applyAdvancedVertexProperties(PropertiesListModel plm, V vertex)
Vertex
are covered by the graph view.plm
- the properties list modelvertex
- the vertex which properties changedprotected void loadAdvancedEdgeProperties(PropertiesListModel plm, E edge)
Edge
and adds them to
the properties list model.
Edge
are covered by the graph view.plm
- the properties list modeledge
- the edge which properties should be loadedprotected void applyAdvancedEdgeProperties(PropertiesListModel plm, E edge)
Edge
are covered by the graph view.plm
- the properties list modeledge
- the edge which properties changedprotected boolean ignoreKeyboardInput()
true
if keyboard input for modification of object data should be ignored otherwise false
protected void applyKeyboardInput(V vertex, java.lang.String input)
vertex
- the vertexinput
- the input stringprotected void applyKeyboardInput(E edge, java.lang.String input)
edge
- the edgeinput
- the input stringprotected java.util.List<GraphView.EdgeOffset> requestOffsetEdges(GraphView.VisualVertex v, GraphView.VisualVertex u)
0
denotes no bending, an offset of 1
or
-1
is the weakest bending in two different directions, and so on.v
- the visual vertex vu
- the visual vertex unull
if their are no edges between the two vertices that have to be updated