|
mxGraph 2.1.0.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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 parent,
mxCellState child)
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 edge,
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 edge,
mxCellState opposite,
boolean source)
Returns the nearest point in the list of absolute points or the center of the opposite terminal. |
mxRectangle |
getPerimeterBounds(mxCellState terminal,
double border)
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 terminal,
mxPoint next,
boolean orthogonal)
Returns a point that defines the location of the intersection point between the perimeter and the line between the center of the shape and the given point. |
mxPoint |
getPerimeterPoint(mxCellState terminal,
mxPoint next,
boolean orthogonal,
double border)
Returns a point that defines the location of the intersection point between the perimeter and the line between the center of the shape and the given point. |
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. |
mxCellState |
getTerminalPort(mxCellState state,
mxCellState terminal,
boolean source)
Returns a cell state that represents the source or target terminal or port for the given edge. |
mxPoint |
getTranslate()
Returns the current translation. |
Object |
getVisibleTerminal(Object edge,
boolean source)
Returns the nearest ancestor terminal that is visible. |
double |
getWordWrapWidth(mxCellState state)
Returns the width for wrapping the label of the given state at scale 1. |
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 validate. |
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 |
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 |
updateFixedTerminalPoint(mxCellState edge,
mxCellState terminal,
boolean source,
mxConnectionConstraint constraint)
Sets the fixed source or target terminal point on the given edge. |
void |
updateFixedTerminalPoints(mxCellState edge,
mxCellState source,
mxCellState target)
Sets the initial absolute terminal points in the given state before the edge style is computed. |
void |
updateFloatingTerminalPoint(mxCellState edge,
mxCellState start,
mxCellState end,
boolean source)
Updates the absolute terminal point in the given state for the given start and end state, where start is the source if source is true. |
void |
updateFloatingTerminalPoints(mxCellState state,
mxCellState source,
mxCellState target)
Updates the terminal points in the given state after the edge style was computed for the edge. |
void |
updateLabel(mxCellState state)
Updates the label of the given state. |
void |
updateLabelBounds(mxCellState state)
Updates the label bounds in the given state. |
void |
updatePoints(mxCellState edge,
List<mxPoint> points,
mxCellState source,
mxCellState target)
Updates the absolute points in the given state using the specified array of points as the relative points. |
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 parent, mxCellState child)
public void updateLabel(mxCellState state)
public double getWordWrapWidth(mxCellState state)
public void updateLabelBounds(mxCellState state)
public mxRectangle updateBoundingBox(mxCellState state)
state
- Cell state whose bounding box should be
updated.public void updateFixedTerminalPoints(mxCellState edge, mxCellState source, mxCellState target)
edge
- Cell state whose initial terminal points should be updated.source
- Cell state which represents the source terminal.target
- Cell state which represents the target terminal.public void updateFixedTerminalPoint(mxCellState edge, mxCellState terminal, boolean source, mxConnectionConstraint constraint)
edge
- Cell state whose initial terminal points should be
updated.public void updatePoints(mxCellState edge, List<mxPoint> points, mxCellState source, mxCellState target)
edge
- Cell state whose absolute points should be updated.points
- Array of points that constitute the relative points.source
- Cell state that represents the source terminal.target
- Cell state that represents the target terminal.public mxPoint transformControlPoint(mxCellState state, mxPoint pt)
public mxEdgeStyle.mxEdgeStyleFunction getEdgeStyle(mxCellState edge, List<mxPoint> points, Object source, Object target)
public void updateFloatingTerminalPoints(mxCellState state, mxCellState source, mxCellState target)
state
- Cell state whose terminal points should be updated.source
- Cell state that represents the source terminal.target
- Cell state that represents the target terminal.public void updateFloatingTerminalPoint(mxCellState edge, mxCellState start, mxCellState end, boolean source)
edge
- Cell state whose terminal point should be updated.start
- Cell state for the terminal on "this" side of the edge.end
- Cell state for the terminal on the other side of the edge.source
- Boolean indicating if start is the source terminal state.public mxCellState getTerminalPort(mxCellState state, mxCellState terminal, boolean source)
public mxPoint getPerimeterPoint(mxCellState terminal, mxPoint next, boolean orthogonal)
public mxPoint getPerimeterPoint(mxCellState terminal, mxPoint next, boolean orthogonal, double border)
terminal
- Cell state for the source or target terminal.next
- Point that lies outside of the given terminal.orthogonal
- Boolean that specifies if the orthogonal projection onto
the perimeter should be returned. If this is false then the intersection
of the perimeter and the line between the next and the center point is
returned.border
- Optional border between the perimeter and the shape.public double getRoutingCenterX(mxCellState state)
public double getRoutingCenterY(mxCellState state)
public mxRectangle getPerimeterBounds(mxCellState terminal, double border)
public mxPerimeter.mxPerimeterFunction getPerimeterFunction(mxCellState state)
public mxPoint getNextPoint(mxCellState edge, mxCellState opposite, boolean source)
edge
- Cell state that represents the edge.opposite
- Cell state that represents the opposite terminal.source
- Boolean indicating if the next point for the source or target
should be returned.
public Object getVisibleTerminal(Object edge, boolean source)
edge
- Cell whose visible terminal should be returned.source
- 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.
|
mxGraph 2.1.0.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |