public class mxGraphView extends mxEventSource
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.Modifier and Type | Class and Description |
---|---|
static class |
mxGraphView.mxCurrentRootChange
Action to change the current root in a view.
|
mxEventSource.mxIEventListener
Modifier and Type | Field and Description |
---|---|
protected java.lang.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 java.util.Hashtable<java.lang.Object,mxCellState> |
states
Maps from cells to cell states.
|
protected mxPoint |
translate
Point that specifies the current translation.
|
eventListeners, eventsEnabled, eventSource
Constructor and Description |
---|
mxGraphView(mxGraph graph)
Constructs a new view for the given graph.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(java.lang.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(java.lang.Object cell)
Creates and returns a cell state for the given cell.
|
mxRectangle |
getBoundingBox(mxCellState state)
Shortcut to validateCell with visible set to true.
|
mxRectangle |
getBoundingBox(mxCellState state,
boolean recurse)
Returns the bounding box of the shape and the label for the given cell
state and its children if recurse is true.
|
mxRectangle |
getBoundingBox(java.lang.Object[] cells)
Returns the bounding box for an array of cells or null, if no cells are
specified.
|
mxRectangle |
getBounds(java.lang.Object[] cells)
Returns the bounding box for an array of cells or null, if no cells are
specified.
|
mxRectangle |
getBounds(java.lang.Object[] cells,
boolean boundingBox)
Returns the bounding box for an array of cells or null, if no cells are
specified.
|
mxCellState[] |
getCellStates(java.lang.Object[] cells)
Returns the states for the given array of cells.
|
java.lang.Object |
getCurrentRoot()
Returns the current root.
|
mxEdgeStyle.mxEdgeStyleFunction |
getEdgeStyle(mxCellState edge,
java.util.List<mxPoint> points,
java.lang.Object source,
java.lang.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(java.lang.Object cell)
Returns the state for the given cell or null if no state is defined for
the cell.
|
mxCellState |
getState(java.lang.Object cell,
boolean create)
Returns the cell state for the given cell.
|
java.util.Hashtable<java.lang.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.
|
java.lang.Object |
getVisibleTerminal(java.lang.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(java.lang.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(java.lang.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.
|
java.lang.Object |
setCurrentRoot(java.lang.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(java.util.Hashtable<java.lang.Object,mxCellState> states)
Returns the dictionary that maps from cells to states.
|
void |
setTranslate(mxPoint value)
Sets the current translation and invalidates the view.
|
java.lang.String |
toString() |
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 |
updateCellState(mxCellState state)
Updates the given cell state.
|
void |
updateEdgeBounds(mxCellState state)
Updates the given state using the bounding box of the absolute points.
|
void |
updateEdgeState(mxCellState state,
mxGeometry geo)
Validates the given cell state.
|
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,
java.util.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 |
updateVertexState(mxCellState state,
mxGeometry geo)
Validates the given cell state.
|
void |
validate()
First validates all bounds and then validates all points recursively on
all visible cells.
|
java.lang.Object |
validateCell(java.lang.Object cell)
Shortcut to validateCell with visible set to true.
|
java.lang.Object |
validateCell(java.lang.Object cell,
boolean visible)
Recursively creates the cell state for the given cell if visible is true
and the given cell is visible.
|
mxCellState |
validateCellState(java.lang.Object cell)
Shortcut to validateCellState with recurse set to true.
|
mxCellState |
validateCellState(java.lang.Object cell,
boolean recurse)
Validates the cell state for the given cell.
|
addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource
protected mxGraph graph
protected java.lang.Object currentRoot
protected mxRectangle graphBounds
protected double scale
protected mxPoint translate
protected java.util.Hashtable<java.lang.Object,mxCellState> states
public mxGraphView(mxGraph graph)
graph
- Reference to the enclosing graph.public mxGraph getGraph()
public java.util.Hashtable<java.lang.Object,mxCellState> getStates()
public void setStates(java.util.Hashtable<java.lang.Object,mxCellState> states)
public mxRectangle getGraphBounds()
public void setGraphBounds(mxRectangle value)
public java.lang.Object getCurrentRoot()
public java.lang.Object setCurrentRoot(java.lang.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(java.lang.Object[] cells)
cells
- public mxRectangle getBoundingBox(java.lang.Object[] cells)
cells
- public mxRectangle getBounds(java.lang.Object[] cells, boolean boundingBox)
cells
- public void reload()
public void revalidate()
public void invalidate()
public void clear(java.lang.Object cell, boolean force, boolean recurse)
cell
- force
- recurse
- public void invalidate(java.lang.Object cell)
public void validate()
public mxRectangle getBoundingBox(mxCellState state)
public mxRectangle getBoundingBox(mxCellState state, boolean recurse)
state
- Cell state whose bounding box should be returned.recurse
- Boolean indicating if the children should be included.public java.lang.Object validateCell(java.lang.Object cell)
public java.lang.Object validateCell(java.lang.Object cell, boolean visible)
cell
- Cell whose cell state should be created.visible
- Boolean indicating if the cell should be visible.public mxCellState validateCellState(java.lang.Object cell)
public mxCellState validateCellState(java.lang.Object cell, boolean recurse)
cell
- Cell whose cell state should be validated.recurse
- Boolean indicating if the children of the cell should be
validated.public void updateCellState(mxCellState state)
state
- Cell state to be updated.public void updateVertexState(mxCellState state, mxGeometry geo)
public void updateEdgeState(mxCellState state, mxGeometry geo)
public void updateVertexLabelOffset(mxCellState state)
state
- Cell state whose absolute offset should be updated.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, java.util.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, java.util.List<mxPoint> points, java.lang.Object source, java.lang.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 java.lang.Object getVisibleTerminal(java.lang.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(java.lang.Object[] cells)
public mxCellState getState(java.lang.Object cell)
cell
- Cell whose state should be returned.public mxCellState getState(java.lang.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(java.lang.Object cell)
cell
- mxCell for which the mxCellState should be removed.public mxCellState createState(java.lang.Object cell)
cell
- Cell for which a new state should be created.public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2010-2017 Gaudenz Alder, JGraph Ltd. All rights reserved.