use of org.cytoscape.math.xform.AffineTransform3D in project cytoscape-impl by cytoscape.
the class ScaleLayouter method scaleGraph.
/**
* A scaleFactor of 1.0 does not move anything.
*
* @exception IllegalArgumentException if
* scaleFactor < 0.001 or if scaleFactor > 1000.0.
*/
public void scaleGraph(double scaleFactor, final Direction direction) {
if ((scaleFactor < 0.001d) || (scaleFactor > 1000.0d))
throw new IllegalArgumentException("scaleFactor is outside allowable range [0.001, 1000.0]");
if (m_translationToOrig == null)
return;
double xFactor = scaleFactor, yFactor = scaleFactor;
switch(direction) {
case X_AXIS_ONLY:
yFactor = 1.0;
break;
case Y_AXIS_ONLY:
xFactor = 1.0;
break;
case BOTH_AXES:
/* Intentionally empty. */
break;
}
final AffineTransform3D xform = m_translationToOrig.concatenatePost((new Scale3D(xFactor, yFactor, 1.0d)).concatenatePost(m_translationFromOrig));
for (CyNode node : m_graph.nodes()) {
if (!m_graph.isMovableNode(node))
continue;
m_pointBuff[0] = m_graph.getNodePosition(node, true);
m_pointBuff[1] = m_graph.getNodePosition(node, false);
m_pointBuff[2] = 0.0d;
xform.transformArr(m_pointBuff);
m_graph.setNodePosition(node, m_pointBuff[0], m_pointBuff[1]);
}
for (CyEdge edge : m_graph.edges()) {
if (!(m_graph.isMovableNode(edge.getSource())) && m_graph.isMovableNode(edge.getTarget()))
continue;
/* TODO support anchors
final int numAnchors = m_graph.getNumAnchors(edge);
for (int j = 0; j < numAnchors; j++) {
m_pointBuff[0] = m_graph.getAnchorPosition(edge, j, true);
m_pointBuff[1] = m_graph.getAnchorPosition(edge, j, false);
m_pointBuff[2] = 0.0d;
xform.transformArr(m_pointBuff);
m_graph.setAnchorPosition(edge, j, m_pointBuff[0], m_pointBuff[1]);
}
*/
}
}
use of org.cytoscape.math.xform.AffineTransform3D in project cytoscape-impl by cytoscape.
the class RotationLayouter method rotateGraph.
public void rotateGraph(double radians) {
if (m_translationToOrig == null)
return;
final AffineTransform3D xform = m_translationToOrig.concatenatePost((new AxisRotation3D(AxisRotation3D.Z_AXIS, radians)).concatenatePost(m_translationFromOrig));
for (CyNode node : m_graph.nodes()) {
if (!m_graph.isMovableNode(node))
continue;
m_pointBuff[0] = m_graph.getNodePosition(node, true);
m_pointBuff[1] = m_graph.getNodePosition(node, false);
m_pointBuff[2] = 0.0d;
xform.transformArr(m_pointBuff);
m_graph.setNodePosition(node, m_pointBuff[0], m_pointBuff[1]);
}
for (CyEdge edge : m_graph.edges()) {
if (!(m_graph.isMovableNode(edge.getSource()) && m_graph.isMovableNode(edge.getTarget())))
continue;
/* TODO support anchors
final int numAnchors = m_graph.getNumAnchors(edge);
for (int j = 0; j < numAnchors; j++) {
m_pointBuff[0] = m_graph.getAnchorPosition(edge, j, true);
m_pointBuff[1] = m_graph.getAnchorPosition(edge, j, false);
m_pointBuff[2] = 0.0d;
xform.transformArr(m_pointBuff);
m_graph.setAnchorPosition(edge, j, m_pointBuff[0], m_pointBuff[1]);
}
*/
}
}
Aggregations