mxGraph 2.1.1.2


com.mxgraph.model
Class mxGeometry

java.lang.Object
  extended by com.mxgraph.util.mxPoint
      extended by com.mxgraph.util.mxRectangle
          extended by com.mxgraph.model.mxGeometry
All Implemented Interfaces:
Serializable, Cloneable

public class mxGeometry
extends mxRectangle

Represents the geometry of a cell. For vertices, the geometry consists of the x- and y-location, as well as the width and height. For edges, the geometry either defines the source- and target-terminal, or it defines the respective terminal points. For edges, if the geometry is relative (default), then the x-coordinate is used to describe the distance from the center of the edge from -1 to 1 with 0 being the center of the edge and the default value, and the y-coordinate is used to describe the absolute, orthogonal distance in pixels from that point. In addition, the offset is used as an absolute offset vector from the resulting point.

See Also:
Serialized Form

Field Summary
protected  mxRectangle alternateBounds
          Stores alternate values for x, y, width and height in a rectangle.
protected  mxPoint offset
          Holds the offset of the label for edges.
protected  List<mxPoint> points
          List of mxPoints which specifies the control points along the edge.
protected  boolean relative
          Specifies if the coordinates in the geometry are to be interpreted as relative coordinates.
protected  mxPoint sourcePoint
          Defines the source- and target-point of the edge.
protected  mxPoint targetPoint
          Defines the source- and target-point of the edge.
static boolean TRANSLATE_CONTROL_POINTS
          Global switch to translate the points in translate.
 
Fields inherited from class com.mxgraph.util.mxRectangle
height, width
 
Fields inherited from class com.mxgraph.util.mxPoint
x, y
 
Constructor Summary
mxGeometry()
          Constructs a new geometry at (0, 0) with the width and height set to 0.
mxGeometry(double x, double y, double width, double height)
          Constructs a geometry using the given parameters.
 
Method Summary
 Object clone()
          Returns a clone of the cell.
 mxRectangle getAlternateBounds()
          Returns the alternate bounds.
 mxPoint getOffset()
          Returns the offset.
 List<mxPoint> getPoints()
          Returns the list of control points.
 mxPoint getSourcePoint()
          Returns the source point.
 mxPoint getTargetPoint()
          Returns the target point.
 mxPoint getTerminalPoint(boolean isSource)
          Returns the point representing the source or target point of this edge.
 boolean isRelative()
          Returns true of the geometry is relative.
 void setAlternateBounds(mxRectangle rect)
          Sets the alternate bounds to the given rectangle.
 void setOffset(mxPoint offset)
          Sets the offset to the given point.
 void setPoints(List<mxPoint> value)
          Sets the list of control points to the given list.
 void setRelative(boolean value)
          Sets the relative state of the geometry.
 void setSourcePoint(mxPoint sourcePoint)
          Sets the source point.
 void setTargetPoint(mxPoint targetPoint)
          Sets the target point.
 mxPoint setTerminalPoint(mxPoint point, boolean isSource)
          Sets the sourcePoint or targetPoint to the given point and returns the new point.
 void swap()
          Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle.
 void translate(double dx, double dy)
          Translates the geometry by the specified amount.
 
Methods inherited from class com.mxgraph.util.mxRectangle
add, contains, equals, getCenterX, getCenterY, getHeight, getRectangle, getWidth, grow, intersectLine, setHeight, setRect, setWidth, toString
 
Methods inherited from class com.mxgraph.util.mxPoint
getPoint, getX, getY, setX, setY
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRANSLATE_CONTROL_POINTS

public static transient boolean TRANSLATE_CONTROL_POINTS
Global switch to translate the points in translate. Default is true.


alternateBounds

protected mxRectangle alternateBounds
Stores alternate values for x, y, width and height in a rectangle. Default is null.


sourcePoint

protected mxPoint sourcePoint
Defines the source- and target-point of the edge. This is used if the corresponding edge does not have a source vertex. Otherwise it is ignored. Default is null.


targetPoint

protected mxPoint targetPoint
Defines the source- and target-point of the edge. This is used if the corresponding edge does not have a source vertex. Otherwise it is ignored. Default is null.


points

protected List<mxPoint> points
List of mxPoints which specifies the control points along the edge. These points are the intermediate points on the edge, for the endpoints use targetPoint and sourcePoint or set the terminals of the edge to a non-null value. Default is null.


offset

protected mxPoint offset
Holds the offset of the label for edges. This is the absolute vector between the center of the edge and the top, left point of the label. Default is null.


relative

protected boolean relative
Specifies if the coordinates in the geometry are to be interpreted as relative coordinates. Default is false. This is used to mark a geometry with an x- and y-coordinate that is used to describe an edge label position, or a relative location with respect to a parent cell's width and height.

Constructor Detail

mxGeometry

public mxGeometry()
Constructs a new geometry at (0, 0) with the width and height set to 0.


mxGeometry

public mxGeometry(double x,
                  double y,
                  double width,
                  double height)
Constructs a geometry using the given parameters.

Parameters:
x - X-coordinate of the new geometry.
y - Y-coordinate of the new geometry.
width - Width of the new geometry.
height - Height of the new geometry.
Method Detail

getAlternateBounds

public mxRectangle getAlternateBounds()
Returns the alternate bounds.


setAlternateBounds

public void setAlternateBounds(mxRectangle rect)
Sets the alternate bounds to the given rectangle.

Parameters:
rect - Rectangle to be used for the alternate bounds.

getSourcePoint

public mxPoint getSourcePoint()
Returns the source point.

Returns:
Returns the source point.

setSourcePoint

public void setSourcePoint(mxPoint sourcePoint)
Sets the source point.

Parameters:
sourcePoint - Source point to be used.

getTargetPoint

public mxPoint getTargetPoint()
Returns the target point.

Returns:
Returns the target point.

setTargetPoint

public void setTargetPoint(mxPoint targetPoint)
Sets the target point.

Parameters:
targetPoint - Target point to be used.

getPoints

public List<mxPoint> getPoints()
Returns the list of control points.


setPoints

public void setPoints(List<mxPoint> value)
Sets the list of control points to the given list.

Parameters:
value - List that contains the new control points.

getOffset

public mxPoint getOffset()
Returns the offset.


setOffset

public void setOffset(mxPoint offset)
Sets the offset to the given point.

Parameters:
offset - Point to be used for the offset.

isRelative

public boolean isRelative()
Returns true of the geometry is relative.


setRelative

public void setRelative(boolean value)
Sets the relative state of the geometry.

Parameters:
value - Boolean value to be used as the new relative state.

swap

public void swap()
Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle. This operation is carried-out in-place, that is, using the existing geometry instance. If this operation is called during a graph model transactional change, then the geometry should be cloned before calling this method and setting the geometry of the cell using mxGraphModel.setGeometry.


getTerminalPoint

public mxPoint getTerminalPoint(boolean isSource)
Returns the point representing the source or target point of this edge. This is only used if the edge has no source or target vertex.

Parameters:
isSource - Boolean that specifies if the source or target point should be returned.
Returns:
Returns the source or target point.

setTerminalPoint

public mxPoint setTerminalPoint(mxPoint point,
                                boolean isSource)
Sets the sourcePoint or targetPoint to the given point and returns the new point.

Parameters:
point - Point to be used as the new source or target point.
isSource - Boolean that specifies if the source or target point should be set.
Returns:
Returns the new point.

translate

public void translate(double dx,
                      double dy)
Translates the geometry by the specified amount. That is, x and y of the geometry, the sourcePoint, targetPoint and all elements of points are translated by the given amount. X and y are only translated if the geometry is not relative. If TRANSLATE_CONTROL_POINTS is false, then are not modified by this function.

Parameters:
dx - Integer that specifies the x-coordinate of the translation.
dy - Integer that specifies the y-coordinate of the translation.

clone

public Object clone()
Returns a clone of the cell.

Overrides:
clone in class mxRectangle

mxGraph 2.1.1.2


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.