Author: mes
Date: 2009-11-20 15:28:55 -0800 (Fri, 20 Nov 2009)
New Revision: 18532
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/AbstractArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/Arrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/ArrowheadArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DeltaArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiamondArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiscArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfBottomArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfTopArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/NoArrow.java
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/TeeArrow.java
Modified:
corelibs/trunk/render.immed/src/cytoscape/render/immed/GraphGraphics.java
Log:
extracted arrows into separate classes yet magically maintained performance,
oooh, ahhh
Modified:
corelibs/trunk/render.immed/src/cytoscape/render/immed/GraphGraphics.java
===================================================================
--- corelibs/trunk/render.immed/src/cytoscape/render/immed/GraphGraphics.java
2009-11-20 20:50:08 UTC (rev 18531)
+++ corelibs/trunk/render.immed/src/cytoscape/render/immed/GraphGraphics.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -58,7 +58,11 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import cytoscape.render.immed.arrow.*;
+
/**
* The purpose of this class is to make the proper calls on a Graphics2D object
* to efficiently render nodes, labels, and edges. This is procedural
@@ -97,6 +101,7 @@
* thread.
*/
public final class GraphGraphics {
+
/**
*
*/
@@ -188,8 +193,9 @@
*/
public static final byte ARROW_ARROWHEAD = -8;
- private static final byte last_arrow_shape = ARROW_ARROWHEAD;
+ public static final List<Arrow> arrows;
+
/**
* This value is currently 64.
*/
@@ -208,6 +214,16 @@
static {
dummyGraphics = new GraphGraphics(null, false);
+
+ arrows = new ArrayList<Arrow>();
+ arrows.add( new NoArrow() );
+ arrows.add( new DeltaArrow() );
+ arrows.add( new DiscArrow() );
+ arrows.add( new DiamondArrow() );
+ arrows.add( new TeeArrow() );
+ arrows.add( new ArrowheadArrow() );
+ arrows.add( new HalfTopArrow() );
+ arrows.add( new HalfBottomArrow() );
}
private static final double DEF_SHAPE_SIZE = 32;
@@ -1247,50 +1263,18 @@
* @return
*/
public static Map<Byte, Shape> getNodeShapes() {
- return getShapes(ShapeTypes.NODE_SHAPE);
- }
-
- /**
- * Get list of arrow heads.
- *
- * @return
- */
- public static Map<Byte, Shape> getArrowShapes() {
- return getShapes(ShapeTypes.ARROW_SHAPE);
- }
-
- /**
- * Actually create map of shapes.
- *
- * @param type
- * @return
- */
- private static Map<Byte, Shape> getShapes(final ShapeTypes type) {
final Map<Byte, Shape> shapeMap = new HashMap<Byte, Shape>();
final int minIndex;
final int maxIndex;
- if (type == ShapeTypes.NODE_SHAPE) {
- minIndex = 0;
- maxIndex = s_last_shape;
- } else if (type == ShapeTypes.ARROW_SHAPE) {
- minIndex = last_arrow_shape;
- maxIndex = -1;
- } else {
- minIndex = 0;
- maxIndex = s_last_shape;
- }
+ minIndex = 0;
+ maxIndex = s_last_shape;
Shape shape;
for (int i = minIndex; i <= maxIndex; i++) {
- if (type == ShapeTypes.NODE_SHAPE) {
- shape = dummyGraphics.getShape((byte) i, 0, 0,
DEF_SHAPE_SIZE,
- DEF_SHAPE_SIZE);
- } else {
- shape =
dummyGraphics.computeUntransformedArrow((byte) i);
- }
+ shape = dummyGraphics.getShape((byte) i, 0, 0,
DEF_SHAPE_SIZE, DEF_SHAPE_SIZE);
if ((shape != null) && (shape.getClass() ==
GeneralPath.class)) {
final Shape copiedShape = (Shape)
((GeneralPath) shape).clone();
@@ -1303,6 +1287,19 @@
return shapeMap;
}
+ /**
+ * Get list of arrow heads.
+ *
+ * @return
+ */
+ public static Map<Byte, Shape> getArrowShapes() {
+ final Map<Byte, Shape> shapeMap = new HashMap<Byte, Shape>();
+ for ( Arrow a : arrows )
+ shapeMap.put( a.getType(), a.getArrowShape() );
+
+ return shapeMap;
+ }
+
private final static void computeRoundedRectangle(final double xMin,
final double yMin, final double xMax, final double yMax,
final double radius, final GeneralPath path2d) {
@@ -1565,6 +1562,7 @@
EdgeAnchors anchors, final float x1, final float y1,
final float edgeThickness, final Stroke edgeStroke,
final Paint edgePaint
) {
+ final long startTime = System.nanoTime();
final double curveFactor = CURVE_ELLIPTICAL;
if (anchors == null) {
@@ -2039,161 +2037,39 @@
/*
* Returns non-null if and only if an arrow is necessary for the arrow
type
- * specified. m_path2d and m_ellp2d may be mangled as a side effect.
- * arrowType must be one of the primitive arrow types or ARROW_NONE.
+ * specified.
*/
private final Shape computeUntransformedArrow(final byte arrowType) {
- switch (arrowType) {
- case ARROW_NONE:
- return null;
+ for ( Arrow a : arrows )
+ if ( a.getType() == arrowType )
+ return a.getArrowShape();
- case ARROW_DELTA:
- m_path2d.reset();
- m_path2d.moveTo(-2.0f, -0.5f);
- m_path2d.lineTo(0.0f, 0.0f);
- m_path2d.lineTo(-2.0f, 0.5f);
- m_path2d.closePath();
-
- return m_path2d;
-
- case ARROW_ARROWHEAD:
- m_path2d.reset();
- m_path2d.moveTo(-2.0f, -0.5f);
- m_path2d.quadTo(-1.0f, 0f, 0.0f, 0.0f);
- m_path2d.quadTo(-1.0f, 0f, -2.0f, 0.5f);
- m_path2d.closePath();
-
- return m_path2d;
-
-
- case ARROW_DIAMOND:
- m_path2d.reset();
- m_path2d.moveTo(-1.0f, -0.5f);
- m_path2d.lineTo(0.0f, 0.0f);
- m_path2d.lineTo(-1.0f, 0.5f);
- m_path2d.lineTo(-2.0f, 0.0f);
- m_path2d.closePath();
-
- return m_path2d;
-
- case ARROW_DISC:
- m_ellp2d.setFrame(-0.5d, -0.5d, 1.0d, 1.0d);
-
- return m_ellp2d;
-
- case ARROW_TEE:
- m_path2d.reset();
- m_path2d.moveTo(-0.125f, -1.0f);
- m_path2d.lineTo(0.125f, -1.0f);
- m_path2d.lineTo(0.125f, 1.0f);
- m_path2d.lineTo(-0.125f, 1.0f);
- m_path2d.closePath();
-
- return m_path2d;
-
- // The half arrow shapes are meant to align exactly with
- // the Parallel stroke provided by Cytoscape. Any other
- // stroke will not line up well.
-
- case ARROW_HALF_TOP:
- m_path2d.reset();
- m_path2d.moveTo(-0.3f,-0.1f);
- m_path2d.lineTo(-1.3f, -1.1f);
- m_path2d.lineTo(-1.435f, -1.1f);
- m_path2d.lineTo(-0.535f, -0.2f);
- m_path2d.lineTo(-0.535f, -0.1f);
- m_path2d.closePath();
-
- return m_path2d;
-
- case ARROW_HALF_BOTTOM:
- m_path2d.reset();
- m_path2d.moveTo(-0.3f,0.1f);
- m_path2d.lineTo(-1.3f,1.1f);
- m_path2d.lineTo(-1.435f, 1.1f);
- m_path2d.lineTo(-0.535f, 0.2f);
- m_path2d.lineTo(-0.535f, 0.1f);
- m_path2d.closePath();
-
- return m_path2d;
-
- default:
- return null;
- }
+ return null;
}
/*
* The ratio parameter specifies the ratio of arrow size (disc
diameter) to
* edge thickness (only used for some arrow types). Returns non-null if
and
- * only if a cap is necessary for the arrow type specified. If non-null
is
- * returned then m_path2d and m_arc2d may be mangled as a side effect.
+ * only if a cap is necessary for the arrow type specified.
*/
private final Shape computeUntransformedArrowCap(final byte arrowType,
final double ratio) {
- switch (arrowType) {
- case ARROW_NONE:
- m_arc2d.setArc(-0.5d, -0.5d, 1.0d, 1.0d, 270.0d, 180.0d,
- Arc2D.CHORD);
+ for ( Arrow a : arrows )
+ if ( a.getType() == arrowType )
+ return a.getCapShape(ratio);
- return m_arc2d;
-
- case ARROW_DIAMOND:
- m_path2d.reset();
- m_path2d.moveTo(0.0f, -0.5f);
- m_path2d.lineTo(1.0f, -0.5f);
- m_path2d.lineTo(0.0f, 0.0f);
- m_path2d.lineTo(1.0f, 0.5f);
- m_path2d.lineTo(0.0f, 0.5f);
- m_path2d.closePath();
-
- return m_path2d;
-
- case ARROW_DISC:
-
- final double theta = Math.toDegrees(Math.asin(1.0d /
ratio));
- m_arc2d.setArc(0.0d, ratio / -2.0d, ratio, ratio,
180.0d - theta,
- theta * 2, Arc2D.OPEN);
- m_path2d.reset();
- m_path2d.append(m_arc2d, false);
- m_path2d.lineTo(0.0f, 0.5f);
- m_path2d.lineTo(0.0f, -0.5f);
- m_path2d.closePath();
-
- return m_path2d;
-
- case ARROW_DELTA:
- case ARROW_ARROWHEAD:
- case ARROW_TEE:
- case ARROW_HALF_TOP:
- case ARROW_HALF_BOTTOM:
- default:
-
- return null;
- }
+ return null;
}
/*
*
*/
private final static double getT(final byte arrowType) {
- switch (arrowType) {
- case ARROW_NONE:
- return 0.0d;
+ for ( Arrow a : arrows )
+ if ( a.getType() == arrowType )
+ return a.getTOffset();
- case ARROW_DELTA:
- case ARROW_ARROWHEAD:
- case ARROW_DIAMOND:
- return 2.0d;
-
- case ARROW_HALF_TOP:
- case ARROW_HALF_BOTTOM:
- case ARROW_DISC:
- return 0.5d;
-
- case ARROW_TEE:
- default:
- return 0.125d;
- }
+ return 0.125;
}
/*
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/AbstractArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/AbstractArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/AbstractArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,75 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.Shape;
+
+/**
+ * Try to keep this package protected.
+ */
+class AbstractArrow implements Arrow {
+
+ protected final double tOffset;
+ protected final byte type;
+
+ protected Shape arrow;
+ protected Shape cap;
+
+ AbstractArrow(final byte type, final double tOffset) {
+ this.type = type;
+ this.tOffset = tOffset;
+ this.arrow = null;
+ this.cap = null;
+ }
+
+ public Shape getArrowShape() {
+ return arrow;
+ }
+
+ public Shape getCapShape(final double ratio) {
+ // ignore the ratio by default
+ return cap;
+ }
+
+ public byte getType() {
+ return type;
+ }
+
+ public double getTOffset() {
+ return tOffset;
+ }
+}
+
Added: corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/Arrow.java
===================================================================
--- corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/Arrow.java
(rev 0)
+++ corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/Arrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,46 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.Shape;
+
+public interface Arrow {
+ Shape getArrowShape();
+ Shape getCapShape(final double ratio);
+ byte getType();
+ double getTOffset();
+}
+
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/ArrowheadArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/ArrowheadArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/ArrowheadArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,58 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class ArrowheadArrow extends AbstractArrow {
+
+ public ArrowheadArrow() {
+ super(GraphGraphics.ARROW_ARROWHEAD,2.0);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-2.0f, -0.5f);
+ arrowGP.quadTo(-1.0f, 0f, 0.0f, 0.0f);
+ arrowGP.quadTo(-1.0f, 0f, -2.0f, 0.5f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // no cap
+ }
+}
+
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DeltaArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DeltaArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DeltaArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,57 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class DeltaArrow extends AbstractArrow {
+
+ public DeltaArrow() {
+ super(GraphGraphics.ARROW_DELTA,2.0);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-2.0f, -0.5f);
+ arrowGP.lineTo(0.0f, 0.0f);
+ arrowGP.lineTo(-2.0f, 0.5f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // no cap
+ }
+}
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiamondArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiamondArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiamondArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,68 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class DiamondArrow extends AbstractArrow {
+
+ public DiamondArrow() {
+ super(GraphGraphics.ARROW_DIAMOND,2.0);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-1.0f, -0.5f);
+ arrowGP.lineTo(0.0f, 0.0f);
+ arrowGP.lineTo(-1.0f, 0.5f);
+ arrowGP.lineTo(-2.0f, 0.0f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // create the cap
+ GeneralPath capGP = new GeneralPath();
+ capGP.moveTo(0.0f, -0.5f);
+ capGP.lineTo(1.0f, -0.5f);
+ capGP.lineTo(0.0f, 0.0f);
+ capGP.lineTo(1.0f, 0.5f);
+ capGP.lineTo(0.0f, 0.5f);
+ capGP.closePath();
+
+ cap = capGP;
+ }
+}
+
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiscArrow.java
===================================================================
--- corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiscArrow.java
(rev 0)
+++ corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/DiscArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,86 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.Shape;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Arc2D;
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class DiscArrow extends AbstractArrow {
+
+ private final GeneralPath capGP;
+ private final Arc2D.Double capA;
+
+ private double currentRatio;
+
+ public DiscArrow() {
+ super(GraphGraphics.ARROW_DISC,0.5);
+
+ // create the arrow
+ final Ellipse2D.Double arrowE = new Ellipse2D.Double();
+ arrowE.setFrame(-0.5d, -0.5d, 1.0d, 1.0d);
+
+ arrow = arrowE;
+
+ // cap is calculated dynamically below!
+ capGP = new GeneralPath();
+ capA = new Arc2D.Double();
+
+ currentRatio = Double.NaN;
+ }
+
+ public synchronized Shape getCapShape(final double ratio) {
+ // only recreate the shape if we need to
+ if ( currentRatio != Double.NaN && ratio == currentRatio )
+ return capGP;
+
+ currentRatio = ratio;
+ final double theta = Math.toDegrees(Math.asin(1.0d / ratio));
+
+ capA.setArc(0.0d, ratio / -2.0d, ratio, ratio, 180.0d - theta,
theta * 2, Arc2D.OPEN);
+
+ capGP.reset();
+ capGP.append(capA, false);
+ capGP.lineTo(0.0f, 0.5f);
+ capGP.lineTo(0.0f, -0.5f);
+ capGP.closePath();
+
+ return capGP;
+ }
+}
+
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfBottomArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfBottomArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfBottomArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,59 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class HalfBottomArrow extends AbstractArrow {
+
+ public HalfBottomArrow() {
+ super(GraphGraphics.ARROW_HALF_BOTTOM,0.5);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-0.3f,0.1f);
+ arrowGP.lineTo(-1.3f,1.1f);
+ arrowGP.lineTo(-1.435f, 1.1f);
+ arrowGP.lineTo(-0.535f, 0.2f);
+ arrowGP.lineTo(-0.535f, 0.1f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // no cap
+ }
+}
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfTopArrow.java
===================================================================
---
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfTopArrow.java
(rev 0)
+++
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/HalfTopArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,60 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class HalfTopArrow extends AbstractArrow {
+
+ public HalfTopArrow() {
+ super(GraphGraphics.ARROW_HALF_TOP,0.5);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-0.3f,-0.1f);
+ arrowGP.lineTo(-1.3f, -1.1f);
+ arrowGP.lineTo(-1.435f, -1.1f);
+ arrowGP.lineTo(-0.535f, -0.2f);
+ arrowGP.lineTo(-0.535f, -0.1f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // no cap
+ }
+}
+
Added: corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/NoArrow.java
===================================================================
--- corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/NoArrow.java
(rev 0)
+++ corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/NoArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,55 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.Arc2D;
+import cytoscape.render.immed.GraphGraphics;
+
+public class NoArrow extends AbstractArrow {
+
+ public NoArrow() {
+ super(GraphGraphics.ARROW_NONE,0.0);
+
+ // no arrow
+
+ // create the cap
+ Arc2D.Double capA = new Arc2D.Double();
+ capA.setArc(-0.5, -0.5, 1.0, 1.0, 270.0, 180.0, Arc2D.CHORD);
+
+ cap = capA;
+ }
+}
+
Added:
corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/TeeArrow.java
===================================================================
--- corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/TeeArrow.java
(rev 0)
+++ corelibs/trunk/render.immed/src/cytoscape/render/immed/arrow/TeeArrow.java
2009-11-20 23:28:55 UTC (rev 18532)
@@ -0,0 +1,58 @@
+
+/*
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.render.immed.arrow;
+
+import java.awt.geom.GeneralPath;
+import cytoscape.render.immed.GraphGraphics;
+
+public class TeeArrow extends AbstractArrow {
+
+ public TeeArrow() {
+ super(GraphGraphics.ARROW_TEE,0.125);
+
+ // create the arrow
+ GeneralPath arrowGP = new GeneralPath();
+ arrowGP.moveTo(-0.125f, -1.0f);
+ arrowGP.lineTo(0.125f, -1.0f);
+ arrowGP.lineTo(0.125f, 1.0f);
+ arrowGP.lineTo(-0.125f, 1.0f);
+ arrowGP.closePath();
+
+ arrow = arrowGP;
+
+ // no cap
+ }
+}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=.