public class Connection extends java.lang.Object implements Drawable2D, java.io.Serializable, Pluggable
Modifier and Type | Field and Description |
---|---|
private float |
angle |
private float |
boundingBoxSize |
private static java.util.List<Connection> |
connections |
private boolean |
isActive |
private boolean |
isSelected |
private Edge |
masterEdge |
private float |
scalingFactor |
private static long |
serialVersionUID |
private Edge |
slaveEdge |
private float |
tolerance |
Constructor and Description |
---|
Connection(Edge masterEdge,
Edge slaveEdge,
java.util.List<Connection> connections)
Creates a connection-object, specifying the two edges to be connected.
|
Connection(java.util.List<Connection> connections)
Creates a basic connection-object without specifying the two edges to be connected.
|
Modifier and Type | Method and Description |
---|---|
private void |
alignEdges(GShape slave,
Edge masterEdge,
Edge slaveEdge) |
private void |
alignShapes(GShape master,
GShape slave,
Edge masterEdge,
Edge slaveEdge) |
private float |
calculateAngleBetweenNormals(GShape master,
GShape slave) |
java.lang.String |
connect()
Connects the two edges of the connection if possible and returns a success/error-message
based on whether or not the connection could be made.
|
void |
connectEdges(Edge masterEdge,
Edge slaveEdge,
float angle)
Aligns and connects two given edges and their shapes in 3D-space at a given angle.
|
void |
draw2D(processing.core.PGraphics p,
Transformation t) |
float |
getAngle() |
static java.util.List<Connection> |
getConnections() |
int |
getControlType(int index) |
Edge |
getMasterEdge() |
java.lang.String |
getNameOfControl(int index) |
int |
getNumberOfControls() |
Edge |
getSlaveEdge() |
int |
getValue(int index) |
boolean |
isActive() |
private boolean |
isEqualEdge(Edge masterEdge,
Edge slaveEdge) |
boolean |
isSelected() |
void |
lockConnection(boolean locked)
Sets the locked-variable of the two edges of the connection to the given boolean value.
|
boolean |
mouseOver(Vector2D mousePosition)
Creates a rectangle around the representation of the connection and checks if the given mousePosition is within this rectangle
|
private void |
recalculateConnectedEdge(Edge edge) |
private float |
safeAngleBetween(Vector3D masterEdgeDirection,
Vector3D slaveEdgeDirection) |
void |
setActive(boolean isActive) |
void |
setAngle(float angle)
Sets the angle between the two shapes that are connected.
|
void |
setMasterEdge(Edge e) |
void |
setSelected(boolean b)
Sets the selection-status of the connection to b
|
void |
setSlaveEdge(Edge e) |
void |
setValue0(int size) |
void |
undoConnection()
Undos a connection between two edges.
|
private static final long serialVersionUID
private Edge masterEdge
private Edge slaveEdge
private float angle
private boolean isSelected
private boolean isActive
private static java.util.List<Connection> connections
private float tolerance
private float scalingFactor
private float boundingBoxSize
public Connection(java.util.List<Connection> connections)
connections
- The list of existing connectionspublic Connection(Edge masterEdge, Edge slaveEdge, java.util.List<Connection> connections)
masterEdge
- The edge contained by the shape considered to be master (will not be moved when connecting the two shapes)slaveEdge
- The edge contained by the shape considered to be slave (will be moved/rotated when connecting the two shapes)connections
- The list of existing connectionspublic static java.util.List<Connection> getConnections()
public Edge getMasterEdge()
public Edge getSlaveEdge()
public void setMasterEdge(Edge e)
e
- The masterEdge of the connectionpublic void setSlaveEdge(Edge e)
e
- The slaveEdge of the connectionpublic void draw2D(processing.core.PGraphics p, Transformation t)
draw2D
in interface Drawable2D
public void setSelected(boolean b)
b
- The new selection-status of the connectionpublic boolean isSelected()
public boolean mouseOver(Vector2D mousePosition)
mousePosition
- The position of the mousepublic void undoConnection()
private void recalculateConnectedEdge(Edge edge)
public java.lang.String connect()
public void lockConnection(boolean locked)
locked
- The value the locked-variable of the two edges is set topublic void setAngle(float angle)
angle
- the angle between the two shapes connected by this connection in degreespublic void connectEdges(Edge masterEdge, Edge slaveEdge, float angle)
masterEdge
- the edge of the shape that is considered master (will not be moved during this operation)slaveEdge
- the edge of the shape that is considered slave (will be moved/rotated to the master)angle
- the angle between master and slaveprivate float safeAngleBetween(Vector3D masterEdgeDirection, Vector3D slaveEdgeDirection)
private float calculateAngleBetweenNormals(GShape master, GShape slave)
public float getAngle()
public boolean isActive()
public int getNumberOfControls()
getNumberOfControls
in interface Pluggable
public int getControlType(int index)
getControlType
in interface Pluggable
public java.lang.String getNameOfControl(int index)
getNameOfControl
in interface Pluggable
public void setValue0(int size)