Cytoscape 2.8.0 API

cytoscape.render.immed.nodeshape
Class TriangleNodeShape

java.lang.Object
  extended by cytoscape.render.immed.nodeshape.TriangleNodeShape
All Implemented Interfaces:
NodeShape

public class TriangleNodeShape
extends Object


Constructor Summary
TriangleNodeShape()
           
 
Method Summary
 boolean computeEdgeIntersection(float xMin, float yMin, float xMax, float yMax, float ptX, float ptY, float[] returnVal)
          A basic implementation that works by unwinding the path of the node shape into line segments and calculating whether each segment intersects the edge.
 Shape getShape(float xMin, float yMin, float xMax, float yMax)
          Returns a Shape object scaled to fit within the bounding box defined by the input parameters.
 byte getType()
          A legacy method to interact cleanly with the current implementation of GraphGraphics.
static boolean segmentIntersection(float[] returnVal, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
          Computes the intersection of the line segment from (x1,y1) to (x2,y2) with the line segment from (x3,y3) to (x4,y4).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriangleNodeShape

public TriangleNodeShape()
Method Detail

getShape

public Shape getShape(float xMin,
                      float yMin,
                      float xMax,
                      float yMax)
Description copied from interface: NodeShape
Returns a Shape object scaled to fit within the bounding box defined by the input parameters.


getType

public byte getType()
Description copied from interface: NodeShape
A legacy method to interact cleanly with the current implementation of GraphGraphics.

Specified by:
getType in interface NodeShape
Returns:
the byte associated with this node shape.

computeEdgeIntersection

public boolean computeEdgeIntersection(float xMin,
                                       float yMin,
                                       float xMax,
                                       float yMax,
                                       float ptX,
                                       float ptY,
                                       float[] returnVal)
A basic implementation that works by unwinding the path of the node shape into line segments and calculating whether each segment intersects the edge. For quadratic and cubic segments of the shape we flatten the curve and then iterate over the resulting segments to determine an intersection. For some shapes there may be faster methods for calculatring the intersection, in which case we encourage you to provide your own implementation of this method!

Specified by:
computeEdgeIntersection in interface NodeShape

segmentIntersection

public static boolean segmentIntersection(float[] returnVal,
                                          float x1,
                                          float y1,
                                          float x2,
                                          float y2,
                                          float x3,
                                          float y3,
                                          float x4,
                                          float y4)
Computes the intersection of the line segment from (x1,y1) to (x2,y2) with the line segment from (x3,y3) to (x4,y4). If no intersection exists, returns false. Otherwise returns true, and returnVal[0] is set to be the X coordinate of the intersection point and returnVal[1] is set to be the Y coordinate of the intersection point. If more than one intersection point exists, "the intersection point" is defined to be the intersection point closest to (x1,y1). A note about overlapping line segments. Because of floating point numbers' inability to be totally accurate, it is quite difficult to represent overlapping line segments with floating point coordinates without using an absolute-precision math package. Because of this, poorly behaved outcome may result when computing the intersection of two [nearly] overlapping line segments. The only way around this would be to round intersection points to the nearest 32-bit floating point quantity. But then dynamic range is greatly compromised.

Parameters:
returnVal - A two element array specifying the point where the two line segments intersect. Element 0 specifies the X location and Element 1 specifies the Y location. If this method returns false, this array will not be modified.
x1 - The X location of beginning of the first line segment.
y1 - The Y location of beginning of the first line segment.
x2 - The X location of ending of the first line segment.
y2 - The Y location of ending of the first line segment.
x3 - The X location of beginning of the second line segment.
y3 - The Y location of beginning of the second line segment.
x4 - The X location of ending of the second line segment.
y4 - The Y location of ending of the second line segment.
Returns:
Whether or not the line segments defined by the input points intersect.

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.