|
JGraph X 1.2.0.8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mxgraph.util.mxEventSource
com.mxgraph.view.mxGraphView
public class mxGraphView
Implements a view for the graph. This class is in charge of computing the
absolute coordinates for the relative child geometries, the points for
perimeters and edge styles and keeping them cached in cell states for
faster retrieval. The states are updated whenever the model or the view
state (translate, scale) changes. The scale and translate are honoured in
the bounds.
This class fires the following events:
mxEvent.UNDO fires after the root was changed in setCurrentRoot. The
edit
property contains the mxUndoableEdit which contains the
mxCurrentRootChange.
mxEvent.SCALE_AND_TRANSLATE fires after the scale and transle have been
changed in scaleAndTranslate. The scale
, previousScale
,
translate
and previousTranslate
properties contain
the new and previous scale and translate, respectively.
mxEvent.SCALE fires after the scale was changed in setScale. The
scale
and previousScale
properties contain the
new and previous scale.
mxEvent.TRANSLATE fires after the translate was changed in setTranslate. The
translate
and previousTranslate
properties contain
the new and previous value for translate.
mxEvent.UP and mxEvent.DOWN fire if the current root is changed by executing
a mxCurrentRootChange. The event name depends on the location of the root
in the cell hierarchy with respect to the current root. The
root
and previous
properties contain the new and
previous root, respectively.
Nested Class Summary | |
---|---|
static class |
mxGraphView.mxCurrentRootChange
Action to change the current root in a view. |
Nested classes/interfaces inherited from class com.mxgraph.util.mxEventSource |
---|
mxEventSource.mxIEventListener |
Field Summary | |
---|---|
protected Object |
currentRoot
mxCell that acts as the root of the displayed cell hierarchy. |
protected mxGraph |
graph
Reference to the enclosing graph. |
protected mxRectangle |
graphBounds
Caches the current bounds of the graph. |
protected double |
scale
Specifies the scale. |
protected Hashtable<Object,mxCellState> |
states
Maps from cells to cell states. |
protected mxPoint |
translate
Point that specifies the current translation. |
Fields inherited from class com.mxgraph.util.mxEventSource |
---|
eventListeners, eventsEnabled, eventSource |
Constructor Summary | |
---|---|
mxGraphView(mxGraph graph)
Constructs a new view for the given graph. |
Method Summary | |
---|---|
protected void |
childMoved(mxCellState parentState,
mxCellState childState)
Invoked when a child state was moved as a result of late evaluation of its position. |
void |
clear(Object cell,
boolean force,
boolean recurse)
Removes the state of the given cell and all descendants if the given cell is not the current root. |
mxCellState |
createState(Object cell)
Creates and returns a cell state for the given cell. |
mxRectangle |
getBoundingBox(Object[] cells)
Returns the bounding box for an array of cells or null, if no cells are specified. |
mxRectangle |
getBounds(Object[] cells)
Returns the bounding box for an array of cells or null, if no cells are specified. |
mxRectangle |
getBounds(Object[] cells,
boolean boundingBox)
Returns the bounding box for an array of cells or null, if no cells are specified. |
mxCellState[] |
getCellStates(Object[] cells)
Returns the states for the given array of cells. |
Object |
getCurrentRoot()
Returns the current root. |
mxEdgeStyle.mxEdgeStyleFunction |
getEdgeStyle(mxCellState edgeState,
List<mxPoint> points,
Object source,
Object target)
Returns the edge style function to be used to compute the absolute points for the given state, control points and terminals. |
mxGraph |
getGraph()
Returns the enclosing graph. |
mxRectangle |
getGraphBounds()
Returns the cached diagram bounds. |
mxPoint |
getNextPoint(mxCellState state,
Object opposite,
boolean isSource)
Returns the nearest point in the list of absolute points or the center of the opposite terminal. |
mxRectangle |
getPerimeterBounds(mxCellState terminal,
mxCellState edge,
boolean isSource)
Returns the perimeter bounds for the given terminal, edge pair. |
mxPerimeter.mxPerimeterFunction |
getPerimeterFunction(mxCellState state)
Returns the perimeter function for the given state. |
mxPoint |
getPerimeterPoint(mxCellState state,
Object start,
Object end,
boolean isSource)
Returns a point that defines the location of the connection point between the edge represented by the given state and the source or target end of the edge, depending on isSource. |
mxPoint |
getPoint(mxCellState state)
Returns the absolute center point along the given edge. |
mxPoint |
getPoint(mxCellState state,
mxGeometry geometry)
Returns the absolute point on the edge for the given relative geometry as a point. |
mxPoint |
getRelativePoint(mxCellState edgeState,
double x,
double y)
Gets the relative point that describes the given, absolute label position for the given edge state. |
double |
getRoutingCenterX(mxCellState state)
Returns the x-coordinate of the center point for automatic routing. |
double |
getRoutingCenterY(mxCellState state)
Returns the y-coordinate of the center point for automatic routing. |
double |
getScale()
Returns the current scale. |
mxCellState |
getState(Object cell)
Returns the state for the given cell or null if no state is defined for the cell. |
mxCellState |
getState(Object cell,
boolean create)
Returns the cell state for the given cell. |
Hashtable<Object,mxCellState> |
getStates()
Returns the dictionary that maps from cells to states. |
mxPoint |
getTranslate()
Returns the current translation. |
Object |
getVisibleTerminal(Object edge,
boolean isSource)
Returns the nearest ancestor terminal that is visible. |
void |
invalidate()
Invalidates all cell states. |
void |
invalidate(Object cell)
Invalidates the state of the given cell, all its descendants and connected edges. |
void |
reload()
Removes all existing cell states and invokes revalidate. |
mxCellState |
removeState(Object cell)
Removes and returns the mxCellState for the given cell. |
void |
revalidate()
|
void |
scaleAndTranslate(double scale,
double dx,
double dy)
Sets the scale and translation. |
Object |
setCurrentRoot(Object root)
Sets and returns the current root and fires an undo event. |
void |
setGraphBounds(mxRectangle value)
Sets the graph bounds. |
void |
setScale(double value)
Sets the current scale and revalidates the view. |
void |
setStates(Hashtable<Object,mxCellState> states)
Returns the dictionary that maps from cells to states. |
void |
setTerminalPoints(mxCellState state)
Sets the initial absolute terminal points in the given state. |
void |
setTranslate(mxPoint value)
Sets the current translation and invalidates the view. |
mxPoint |
transformControlPoint(mxCellState state,
mxPoint pt)
Transforms the given control point to an absolute point. |
mxRectangle |
updateBoundingBox(mxCellState state)
Updates the bounding box in the given cell state. |
void |
updateEdgeBounds(mxCellState state)
Updates the given state using the bounding box of the absolute points. |
void |
updateLabelBounds(mxCellState state)
Updates the label bounds in the given state. |
void |
updatePoints(mxCellState state,
List<mxPoint> points,
Object source,
Object target)
Updates the absolute points in the given state using the specified array of points as the relative points. |
void |
updateTerminalPoint(mxCellState state,
Object start,
Object end,
boolean isSource)
Updates the absolute terminal point in the given state for the given start and end state, where start is the source if isSource is true. |
void |
updateTerminalPoints(mxCellState state,
Object source,
Object target)
Updates the terminal points in the given state. |
void |
updateVertexLabelOffset(mxCellState state)
Updates the absoluteOffset of the given vertex cell state. |
void |
validate()
First validates all bounds and then validates all points recursively on all visible cells. |
void |
validateBounds(mxCellState parentState,
Object cell)
Validates the bounds of the given parent's child using the given parent state as the origin for the child. |
mxRectangle |
validatePoints(mxCellState parentState,
Object cell)
Validates the points for the state of the given cell recursively if the cell is not collapsed and returns the bounding box of all visited states as a rectangle. |
Methods inherited from class com.mxgraph.util.mxEventSource |
---|
addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected mxGraph graph
protected Object currentRoot
protected mxRectangle graphBounds
protected double scale
protected mxPoint translate
protected Hashtable<Object,mxCellState> states
Constructor Detail |
---|
public mxGraphView(mxGraph graph)
graph
- Reference to the enclosing graph.Method Detail |
---|
public mxGraph getGraph()
public Hashtable<Object,mxCellState> getStates()
public void setStates(Hashtable<Object,mxCellState> states)
public mxRectangle getGraphBounds()
public void setGraphBounds(mxRectangle value)
public Object getCurrentRoot()
public Object setCurrentRoot(Object root)
root
- mxCell that specifies the root of the displayed cell hierarchy.
public void scaleAndTranslate(double scale, double dx, double dy)
scale
- Decimal value that specifies the new scale (1 is 100%).dx
- X-coordinate of the translation.dy
- Y-coordinate of the translation.public double getScale()
public void setScale(double value)
value
- New scale to be used.public mxPoint getTranslate()
public void setTranslate(mxPoint value)
value
- New translation to be used.public mxRectangle getBounds(Object[] cells)
cells
-
public mxRectangle getBoundingBox(Object[] cells)
cells
-
public mxRectangle getBounds(Object[] cells, boolean boundingBox)
cells
-
public void reload()
public void revalidate()
public void invalidate()
public void clear(Object cell, boolean force, boolean recurse)
cell
- force
- recurse
- public void invalidate(Object cell)
public void validate()
public void validateBounds(mxCellState parentState, Object cell)
parentState
- Object that represents the state of the parent cell.cell
- Cell for which the bounds in the state should be updated.public void updateVertexLabelOffset(mxCellState state)
state
- Cell state whose absolute offset should be updated.public mxRectangle validatePoints(mxCellState parentState, Object cell)
parentState
- Object that represents the state of the parent cell.cell
- Cell for which the points in the state should be updated.
protected void childMoved(mxCellState parentState, mxCellState childState)
public void updateLabelBounds(mxCellState state)
public mxRectangle updateBoundingBox(mxCellState state)
state
- Cell state whose bounding box should be
updated.public void setTerminalPoints(mxCellState state)
state
- Cell state whose initial terminal points should be
updated.public void updatePoints(mxCellState state, List<mxPoint> points, Object source, Object target)
state
- Cell state whose absolute points should be updated.points
- Array of points that constitute the relative points.source
- Cell that represents the visual source.target
- Cell that represents the visual target.public mxPoint transformControlPoint(mxCellState state, mxPoint pt)
public mxEdgeStyle.mxEdgeStyleFunction getEdgeStyle(mxCellState edgeState, List<mxPoint> points, Object source, Object target)
public void updateTerminalPoints(mxCellState state, Object source, Object target)
state
- Cell state whose terminal points should be updated.source
- Cell that represents the visual source.target
- Cell that represents the visual target.public void updateTerminalPoint(mxCellState state, Object start, Object end, boolean isSource)
state
- Cell state whose terminal point should be updated.start
- Cell state for the source or target terminal.end
- Cell state for the opposite terminal.isSource
- Boolean indicating if start is the state of the source
terminal.public mxPoint getPerimeterPoint(mxCellState state, Object start, Object end, boolean isSource)
state
- Cell state of the connecting edge.start
- Cell state for the source or target terminal.end
- Cell state for the opposite terminal.isSource
- Boolean indicating if start is the state of the source
terminal.
public double getRoutingCenterX(mxCellState state)
public double getRoutingCenterY(mxCellState state)
public mxRectangle getPerimeterBounds(mxCellState terminal, mxCellState edge, boolean isSource)
public mxPerimeter.mxPerimeterFunction getPerimeterFunction(mxCellState state)
public mxPoint getNextPoint(mxCellState state, Object opposite, boolean isSource)
state
- Cell state that represents the edge.opposite
- Cell that represents the opposite terminal.isSource
- Boolean indicating if the next point for the source or target
should be returned.
public Object getVisibleTerminal(Object edge, boolean isSource)
edge
- Cell whose visible terminal should be returned.isSource
- Boolean that specifies if the source or target terminal
should be returned.
public void updateEdgeBounds(mxCellState state)
state
- Cell state whose bounds should be updated.public mxPoint getPoint(mxCellState state)
public mxPoint getPoint(mxCellState state, mxGeometry geometry)
state
- Represents the state of the parent edge.geometry
- Optional geometry that represents the relative location.
public mxPoint getRelativePoint(mxCellState edgeState, double x, double y)
public mxCellState[] getCellStates(Object[] cells)
public mxCellState getState(Object cell)
cell
- Cell whose state should be returned.
public mxCellState getState(Object cell, boolean create)
cell
- Cell for which a new state should be returned.create
- Boolean indicating if a new state should be created if it
does not yet exist.
public mxCellState removeState(Object cell)
cell
- mxCell for which the mxCellState should be removed.
public mxCellState createState(Object cell)
cell
- Cell for which a new state should be created.
|
JGraph X 1.2.0.8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |