Author: kono
Date: 2011-12-22 15:21:20 -0800 (Thu, 22 Dec 2011)
New Revision: 27862
Added:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Handle.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/EdgeBendVisualProperty.java
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Bend.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
Log:
Ported Edge Bend from 2.8.2. Next, use new Handle and Bend interface in the
new Visual Property.
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Bend.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Bend.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Bend.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -3,6 +3,7 @@
import java.awt.geom.Point2D;
import java.util.List;
+
/**
* A class that encapsulates the representation of the bend used for a
* particular EdgeView.
@@ -10,6 +11,15 @@
* @author Mike Smoot (mes5k)
*/
public interface Bend {
+
+// List<Handle> getAllHandles();
+// void addHandle(final Handle handle);
+//
+// void removeHandle(final int handleIndex);
+// void removeHandle(final Handle handle);
+// void removeAllHandles();
+//
+// int getIndex(final Handle handle);
/**
* Given a list of points removes all existing handles/handlePoints and
adds
Added:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Handle.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Handle.java
(rev 0)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/Handle.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -0,0 +1,10 @@
+package org.cytoscape.ding;
+
+public interface Handle {
+
+ double getXFraction();
+ double getYFraction();
+
+ void setXFraction(final double x);
+ void setYFraction(final double y);
+}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -33,11 +33,20 @@
import java.awt.Stroke;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.cytoscape.ding.EdgeView;
+import org.cytoscape.graph.render.immed.EdgeAnchors;
import org.cytoscape.graph.render.immed.GraphGraphics;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.util.intr.IntEnumerator;
+import org.cytoscape.util.intr.IntIterator;
import org.cytoscape.util.intr.IntObjHash;
+import org.cytoscape.util.intr.MinIntHeap;
class DEdgeDetails extends IntermediateEdgeDetails {
@@ -65,6 +74,9 @@
Map<Integer, Paint> m_unselectedPaints = new HashMap<Integer, Paint>();
Map<Integer, Paint> m_selectedPaints = new HashMap<Integer, Paint>();
+
+ // Curved or not
+ Map<Integer, Integer> m_lineType = new HashMap<Integer, Integer>();
private Byte m_sourceArrowDefault;
private Paint m_sourceArrowPaintDefault;
@@ -84,6 +96,8 @@
private Paint m_colorLowDetailDefault;
private Color m_selectedColorLowDetailDefault;
+
+ private Integer m_lineTypeDefault;
private boolean isCleared = false;
@@ -118,6 +132,8 @@
m_selectedColorsLowDetail = new IntObjHash();
selected = new HashSet<Integer>();
+
+ m_lineType = new HashMap<Integer, Integer>();
isCleared = true;
}
@@ -147,6 +163,8 @@
m_selectedPaints.remove(edgeIdx);
m_unselectedPaints.remove(edgeIdx);
+
+ m_lineType.remove(edgeIdx);
selected.remove(edgeIdx);
}
@@ -678,4 +696,221 @@
else
return (segmentThickness(edge) +
DEdgeView.DEFAULT_ARROW_SIZE);
}
+
+
+
+ public Integer lineType(final int edge) {
+ final Integer lineType = m_lineType.get(edge);
+ if (lineType == null)
+ if (m_lineTypeDefault == null)
+ return EdgeView.STRAIGHT_LINES;
+ else
+ return m_lineTypeDefault;
+
+ return lineType;
+ }
+
+ public void setLineTypeDefault(int lineType) {
+ this.m_lineTypeDefault = lineType;
+ }
+
+
+ // Used by bends
+ private final MinIntHeap m_heap = new MinIntHeap();
+ private final float[] m_extentsBuff = new float[4];
+
+ @Override
+ public EdgeAnchors anchors(final int edge) {
+ //TODO: Why NOT op is here?
+// final EdgeAnchors returnThis = (EdgeAnchors)
(m_view.getDEdgeView(~edge));
+ final DEdgeView edgeView = (DEdgeView)
m_view.getDEdgeView(edge);
+ final EdgeAnchors returnThis = edgeView;
+
+ if (returnThis.numAnchors() > 0)
+ return returnThis;
+
+ final CyNetwork graph = m_view.m_drawPersp;
+
+ final int srcNodeIndex =
edgeView.getModel().getSource().getIndex();
+ final int trgNodeIndex =
edgeView.getModel().getTarget().getIndex();
+
+ // Calculate anchors necessary for self edges.
+ if (srcNodeIndex == trgNodeIndex) {
+ m_view.m_spacial.exists(srcNodeIndex, m_extentsBuff, 0);
+
+ final double w = ((double) m_extentsBuff[2]) -
m_extentsBuff[0];
+ final double h = ((double) m_extentsBuff[3]) -
m_extentsBuff[1];
+ final double x = (((double) m_extentsBuff[0]) +
m_extentsBuff[2]) / 2.0d;
+ final double y = (((double) m_extentsBuff[1]) +
m_extentsBuff[3]) / 2.0d;
+ final double nodeSize = Math.max(w, h);
+ int i = 0;
+
+ final List<CyEdge> selfEdgeList =
graph.getConnectingEdgeList(edgeView.getModel().getSource(),
edgeView.getModel().getSource(), CyEdge.Type.ANY);
+ //final IntIterator selfEdges =
graph.edgesConnecting(srcNodeIndex, srcNodeIndex, true, true, true);
+
+ for(final CyEdge selfEdge: selfEdgeList) {
+// while (selfEdges.hasNext()) {
+// final int e2 = selfEdges.nextInt();
+ final int e2 = selfEdge.getIndex();
+
+ if (e2 == edge)
+ break;
+
+ if (((EdgeAnchors)
m_view.getDEdgeView(e2)).numAnchors() == 0)
+ i++;
+ }
+
+ final int inx = i;
+
+ return new EdgeAnchors() {
+ public int numAnchors() {
+ return 2;
+ }
+
+ public void getAnchor(int anchorInx,
float[] anchorArr, int offset) {
+ if (anchorInx == 0) {
+ anchorArr[offset] =
(float) (x - (((inx + 3) * nodeSize) / 2.0d));
+ anchorArr[offset + 1] =
(float) y;
+ } else if (anchorInx == 1) {
+ anchorArr[offset] =
(float) x;
+ anchorArr[offset + 1] =
(float) (y - (((inx + 3) * nodeSize) / 2.0d));
+ }
+ }
+ };
+ }
+
+ // Now add "invisible" anchors to edges for the case where
multiple edges
+ // exist between two nodes. This has no effect if user
specified anchors
+ // exist on the edge.
+ while (true) {
+
+ // By consistently ordering the source and target
nodes, dx and dy will always
+ // be calculated according to the same orientation.
This allows the offset
+ // calculation to toggle the edges from side to side
without any overlap.
+ final int tmpSrcIndex = Math.min( srcNodeIndex,
trgNodeIndex );
+ final int tmpTrgIndex = Math.max( srcNodeIndex,
trgNodeIndex );
+
+ // Sort the connecting edges.
+ final CyNode tmpSrc = graph.getNode(tmpSrcIndex);
+ final CyNode tmpTrg = graph.getNode(tmpTrgIndex);
+ final List<CyEdge> conEdgeList =
graph.getConnectingEdgeList(tmpSrc, tmpTrg, CyEdge.Type.ANY);
+// final IntIterator conEdges =
graph.edgesConnecting(tmpSrc, tmpTrg,
+//
true, true, true);
+ m_heap.empty();
+
+ for(final CyEdge conEdge: conEdgeList) {
+// while (conEdges.hasNext()) {
+// m_heap.toss(conEdges.nextInt());
+ m_heap.toss(conEdge.getIndex());
+ }
+
+ final IntEnumerator otherEdges =
m_heap.orderedElements(false);
+
+ int otherEdge = otherEdges.nextInt();
+
+ // If the first other edge is the same as this edge,
+ // (i.e. we're at the end of the list?).
+ if (otherEdge == edge)
+ break;
+
+ // So we don't count the other edge twice?
+ int i = (((EdgeAnchors)
m_view.getDEdgeView(otherEdge)).numAnchors() == 0) ? 1 : 0;
+
+ // Count the number of other edges.
+ while (true) {
+ if (edge == (otherEdge = otherEdges.nextInt()))
+ break;
+
+ if (((EdgeAnchors)
m_view.getDEdgeView(otherEdge)).numAnchors() == 0)
+ i++;
+ }
+
+ final int inx = i;
+
+ // Get source node size and position.
+ m_view.m_spacial.exists(tmpSrcIndex, m_extentsBuff, 0);
+ final double srcW = ((double) m_extentsBuff[2]) -
m_extentsBuff[0];
+ final double srcH = ((double) m_extentsBuff[3]) -
m_extentsBuff[1];
+ final double srcX = (((double) m_extentsBuff[0]) +
m_extentsBuff[2]) / 2.0d;
+ final double srcY = (((double) m_extentsBuff[1]) +
m_extentsBuff[3]) / 2.0d;
+
+ // Get target node size and position.
+ m_view.m_spacial.exists(tmpTrgIndex, m_extentsBuff, 0);
+ final double trgW = ((double) m_extentsBuff[2]) -
m_extentsBuff[0];
+ final double trgH = ((double) m_extentsBuff[3]) -
m_extentsBuff[1];
+ final double trgX = (((double) m_extentsBuff[0]) +
m_extentsBuff[2]) / 2.0d;
+ final double trgY = (((double) m_extentsBuff[1]) +
m_extentsBuff[3]) / 2.0d;
+
+ // Used for determining the space between the edges.
+ final double nodeSize =
Math.max(Math.max(Math.max(srcW, srcH), trgW), trgH);
+
+ // Midpoint between nodes.
+ final double midX = (srcX + trgX) / 2;
+ final double midY = (srcY + trgY) / 2;
+
+ // Distance in X and Y dimensions.
+ // Note that dx and dy may be negative. This is OK,
because this will ensure
+ // that the handle is always correctly placed offset
from the midpoint of,
+ // and perpendicular to, the original edge.
+ final double dx = trgX - srcX;
+ final double dy = trgY - srcY;
+
+ // Distance or length between nodes.
+ final double len = Math.sqrt((dx * dx) + (dy * dy));
+
+ if (((float) len) == 0.0f)
+ break;
+
+ // This determines which side of the first edge and how
far from the first
+ // edge the other edge should be placed.
+ // - Divide by 2 puts consecutive edges at the same
distance from the center
+ // because of integer math.
+ // - Modulo puts consecutive edges on opposite sides.
+ // - Node size is for consistent scaling.
+ final double offset = ((inx + 1) / 2) * (inx % 2 == 0 ?
1 : -1) * nodeSize;
+
+ // Depending on orientation sine or cosine. This
adjusts the length
+ // of the offset according the appropriate X and Y
dimensions.
+ final double normX = dx / len;
+ final double normY = dy / len;
+
+ // Calculate the anchor points.
+ final double anchorX = midX + (offset * normY);
+ final double anchorY = midY - (offset * normX);
+
+ return new EdgeAnchors() {
+ public int numAnchors() {
+ return 1;
+ }
+
+ public void getAnchor(int inx, float[]
arr, int off) {
+ arr[off] = (float) anchorX;
+ arr[off + 1] = (float) anchorY;
+ }
+ };
+ }
+
+ return returnThis;
+ }
+
+ @Override
+ public float anchorSize(final int edge, final int anchorInx) {
+ if (m_view.getDEdgeView(edge).isSelected() && (((DEdgeView)
m_view.getDEdgeView(edge)).numAnchors() > 0))
+ return m_view.getAnchorSize();
+ else
+ return 0.0f;
+ }
+
+ @Override
+ public Paint anchorPaint(final int edge, int anchorInx) {
+// final DEdgeView edgeView = (DEdgeView)
m_view.getDEdgeView(edge);
+
+ if (lineType(edge) == DEdgeView.STRAIGHT_LINES)
+ anchorInx = anchorInx / 2;
+
+ if (m_view.m_selectedAnchors.count((edge << 6) | anchorInx) > 0)
+ return m_view.getAnchorSelectedPaint();
+ else
+ return m_view.getAnchorUnselectedPaint();
+ }
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -80,8 +80,10 @@
Paint m_targetSelectedPaint;
int m_sourceEdgeEnd; // One of the EdgeView edge end constants.
int m_targetEdgeEnd; // Ditto.
- ArrayList<Point2D> m_anchors; // A list of Point2D objects.
- int m_lineType;
+
+ List<Point2D> m_anchors; // A list of Point2D objects.
+
+ //int m_lineType;
String m_toolTipText = null;
private LineType lineType;
@@ -111,7 +113,7 @@
m_sourceEdgeEnd = GraphGraphics.ARROW_NONE;
m_targetEdgeEnd = GraphGraphics.ARROW_NONE;
m_anchors = null;
- m_lineType = EdgeView.STRAIGHT_LINES;
+ //m_lineType = EdgeView.STRAIGHT_LINES;
}
@Override
@@ -177,41 +179,28 @@
}
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+ @Override
public Stroke getStroke() {
synchronized (m_view.m_lock) {
return m_view.m_edgeDetails.segmentStroke(m_inx);
}
}
- /**
- * DOCUMENT ME!
- *
- * @param lineType
- * DOCUMENT ME!
- */
+ @Override
public void setLineType(int lineType) {
if ((lineType == EdgeView.CURVED_LINES)
|| (lineType == EdgeView.STRAIGHT_LINES)) {
synchronized (m_view.m_lock) {
- m_lineType = lineType;
+ m_view.m_edgeDetails.m_lineType.put(m_inx,
lineType);
m_view.m_contentChanged = true;
}
} else
throw new IllegalArgumentException("unrecognized line
type");
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+ @Override
public int getLineType() {
- return m_lineType;
+ return m_view.m_edgeDetails.lineType(m_inx);
}
@@ -690,11 +679,6 @@
}
// Interface org.cytoscape.ding.Bend:
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public int numHandles() {
synchronized (m_view.m_lock) {
if (m_anchors == null)
@@ -823,19 +807,15 @@
addHandleFoo(pt);
}
- /**
- * DOCUMENT ME!
- *
- * @param pt
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+
public int addHandleFoo(Point2D pt) {
synchronized (m_view.m_lock) {
+
+ System.out.println("!!ADD Ancor called: ");
+
if ((m_anchors == null) || (m_anchors.size() == 0)) {
addHandle(0, pt);
-
+ // Index of this handle, which is first (0)
return 0;
}
@@ -876,22 +856,18 @@
}
}
- /**
- * DOCUMENT ME!
- *
- * @param insertInx
- * DOCUMENT ME!
- * @param pt
- * DOCUMENT ME!
- */
- public void addHandle(int insertInx, Point2D pt) {
+ @Override
+ public void addHandle(final int insertInx, final Point2D pt) {
synchronized (m_view.m_lock) {
final Point2D.Float addThis = new Point2D.Float();
addThis.setLocation(pt);
- if (m_anchors == null)
+ // This is the first time to use this data structure.
+ if (m_anchors == null) {
+ System.out.println("manc is null. Create
arraylist");
m_anchors = new ArrayList<Point2D>();
-
+ }
+
m_anchors.add(insertInx, addThis);
if (m_selected) {
@@ -1025,11 +1001,7 @@
}
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+ @Override
public Point2D[] getDrawPoints() {
synchronized (m_view.m_lock) {
final Point2D[] returnThis = new Point2D[(m_anchors ==
null) ? 0
@@ -1045,36 +1017,22 @@
}
// Interface org.cytoscape.graph.render.immed.EdgeAnchors:
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
+ @Override
public int numAnchors() {
if (m_anchors == null)
return 0;
-
- if (m_lineType == EdgeView.CURVED_LINES)
+
+ if (m_view.m_edgeDetails.lineType(m_inx) ==
EdgeView.CURVED_LINES)
return m_anchors.size();
else
-
return 2 * m_anchors.size();
}
- /**
- * DOCUMENT ME!
- *
- * @param anchorIndex
- * DOCUMENT ME!
- * @param anchorArr
- * DOCUMENT ME!
- * @param offset
- * DOCUMENT ME!
- */
+ @Override
public void getAnchor(int anchorIndex, float[] anchorArr, int offset) {
final Point2D.Float anchor;
- if (m_lineType == EdgeView.CURVED_LINES)
+ if (m_view.m_edgeDetails.lineType(m_inx) ==
EdgeView.CURVED_LINES)
anchor = (Point2D.Float) m_anchors.get(anchorIndex);
else
anchor = (Point2D.Float) m_anchors.get(anchorIndex / 2);
@@ -1083,32 +1041,16 @@
anchorArr[offset + 1] = anchor.y;
}
- // Auxillary methods for edge anchors.
- /**
- * DOCUMENT ME!
- *
- * @param position
- * DOCUMENT ME!
- */
+ // TODO: Can we remove this?
public void setTextAnchor(int position) {
// System.out.println("setTextAnchor");
}
- /**
- * DOCUMENT ME!
- *
- * @param justify
- * DOCUMENT ME!
- */
+
public void setJustify(int justify) {
// System.out.println("setJustify");
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public int getTextAnchor() {
// System.out.println("getTextAnchor");
@@ -1343,6 +1285,12 @@
m_view.showGraphObject(this);
else
m_view.hideGraphObject(this);
+ } else if(vp == DVisualLexicon.EDGE_CURVED) {
+ final Boolean curved = (Boolean) value;
+ if(curved)
+ setLineType(EdgeView.CURVED_LINES);
+ else
+ setLineType(EdgeView.STRAIGHT_LINES);
}
visualProperties.put(vp, value);
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -35,6 +35,7 @@
import java.util.Map;
import java.util.Set;
+import org.cytoscape.ding.Bend;
import org.cytoscape.ding.DNodeShape;
import org.cytoscape.ding.ObjectPosition;
import org.cytoscape.ding.customgraphics.CustomGraphicsManager;
@@ -51,6 +52,7 @@
import org.cytoscape.ding.impl.strokes.VerticalSlashStroke;
import org.cytoscape.ding.impl.strokes.ZigzagStroke;
import org.cytoscape.ding.impl.visualproperty.CustomGraphicsVisualProperty;
+import org.cytoscape.ding.impl.visualproperty.EdgeBendVisualProperty;
import org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty;
import org.cytoscape.graph.render.immed.GraphGraphics;
import org.cytoscape.model.CyEdge;
@@ -236,6 +238,14 @@
Color.BLACK, MinimalVisualLexicon.PAINT_RANGE,
"EDGE_TARGET_ARROW_UNSELECTED_PAINT",
"Edge Target Arrow Unselected Paint", CyEdge.class);
+
+ public static final VisualProperty<Bend> EDGE_BEND = new
EdgeBendVisualProperty(
+ EdgeBendVisualProperty.DEFAULT_EDGE_BEND, "EDGE_BEND",
+ "Edge Bend");
+
+ public static final VisualProperty<Boolean> EDGE_CURVED = new
BooleanVisualProperty(false, "EDGE_CURVED",
+ "Edge Curved", CyEdge.class);
+
// TODO: Implement if possible (in rendering engine)
// public static final VisualProperty<ObjectPosition> EDGE_LABEL_POSITION
= new ObjectPositionVisualProperty(
@@ -390,6 +400,10 @@
addVisualProperty(EDGE_TARGET_ARROW_SELECTED_PAINT,
EDGE_SELECTED_PAINT);
addVisualProperty(EDGE_SOURCE_ARROW_UNSELECTED_PAINT,
EDGE_UNSELECTED_PAINT);
addVisualProperty(EDGE_TARGET_ARROW_UNSELECTED_PAINT,
EDGE_UNSELECTED_PAINT);
+
+ // Define edge end related VP
+ addVisualProperty(EDGE_BEND, EDGE);
+ addVisualProperty(EDGE_CURVED, EDGE);
//addVisualProperty(EDGE_LABEL_POSITION, EDGE);
@@ -419,6 +433,9 @@
//
addIdentifierMapping(CyEdge.class,"edgeOpacity",EDGE_TRANPARENCY);
// TODO add more!
+
+ addIdentifierMapping(CyEdge.class, "edgeBend", EDGE_BEND);
+ addIdentifierMapping(CyEdge.class, "edgeCurved", EDGE_CURVED);
}
static Set<VisualProperty<?>> getGraphicsPositionVP() {
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -34,6 +34,7 @@
import java.awt.Stroke;
import org.cytoscape.ding.DArrowShape;
+import org.cytoscape.ding.EdgeView;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
import org.cytoscape.view.presentation.property.RichVisualLexicon;
@@ -63,6 +64,7 @@
private Paint selectedPaint;
private Color labelColor;
+
<T, V extends T> void setEdgeViewDefault(VisualProperty<? extends T>
vp, V value) {
@@ -115,8 +117,19 @@
labelTransparency = ((Number) value).intValue();
setTextPaint(labelColor);
}
+ } else if(vp == DVisualLexicon.EDGE_CURVED) {
+ setCurved((Boolean) value);
}
}
+
+ void setCurved(final Boolean curved) {
+ synchronized (lock) {
+ if(curved)
+
edgeDetails.setLineTypeDefault(EdgeView.CURVED_LINES);
+ else
+
edgeDetails.setLineTypeDefault(EdgeView.STRAIGHT_LINES);
+ }
+ }
void setTransparency(int trans) {
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2011-12-22 22:21:47 UTC (rev 27861)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -496,51 +496,51 @@
private int toggleSelectedEdge(int chosenEdge, MouseEvent e) {
int chosenEdgeSelected = 0;
+
+ // Set Edge Bend.
if (e.isControlDown() && ((m_lastRenderDetail &
GraphRenderer.LOD_EDGE_ANCHORS) != 0)) {
- m_view.m_selectedAnchors.empty();
+
+ m_view.m_selectedAnchors.empty();
+ m_ptBuff[0] = m_lastXMousePos;
+ m_ptBuff[1] = m_lastYMousePos;
+ m_view.xformComponentToNodeCoords(m_ptBuff);
+ // Store current handle list
+ m_undoable_edit = new ViewChangeEdit(m_view,
ViewChangeEdit.SavedObjs.SELECTED_EDGES, "Add Edge Handle", m_undo);
+ final int chosenInx = ((DEdgeView)
m_view.getDEdgeView(chosenEdge)).addHandleFoo(new Point2D.Float(
+ (float) m_ptBuff[0], (float)
m_ptBuff[1]));
+
+ m_view.m_selectedAnchors.insert(((chosenEdge) << 6) |
chosenInx);
+ }
+
+ final boolean wasSelected =
m_view.getDEdgeView(chosenEdge).isSelected();
+
+ if (wasSelected && e.isShiftDown()) {
+ ((DEdgeView)
m_view.getDEdgeView(chosenEdge)).unselectInternal();
+ chosenEdgeSelected = -1;
+ } else if (!wasSelected) {
+ ((DEdgeView)
m_view.getDEdgeView(chosenEdge)).selectInternal(false);
+ chosenEdgeSelected = 1;
+
+ if ((m_lastRenderDetail &
GraphRenderer.LOD_EDGE_ANCHORS) != 0) {
m_ptBuff[0] = m_lastXMousePos;
m_ptBuff[1] = m_lastYMousePos;
m_view.xformComponentToNodeCoords(m_ptBuff);
- // Store current handle list
- m_undoable_edit = new
ViewChangeEdit(m_view,ViewChangeEdit.SavedObjs.SELECTED_EDGES,"Add Edge
Handle",m_undo);
- final int chosenInx = ((DEdgeView)
m_view.getDEdgeView(chosenEdge))
-
.addHandleFoo(new Point2D.Float((float) m_ptBuff[0],
-
(float)
m_ptBuff[1]));
- m_view.m_selectedAnchors.insert(((chosenEdge)
<< 6) | chosenInx);
- }
- final boolean wasSelected =
m_view.getDEdgeView(chosenEdge).isSelected();
+ final IntEnumerator hits =
m_view.m_spacialA.queryOverlap((float) m_ptBuff[0], (float) m_ptBuff[1],
+ (float) m_ptBuff[0], (float)
m_ptBuff[1], null, 0, false);
- if (wasSelected && e.isShiftDown()) {
- ((DEdgeView)
m_view.getDEdgeView(chosenEdge)).unselectInternal();
- chosenEdgeSelected = -1;
- } else if (!wasSelected) {
- ((DEdgeView)
m_view.getDEdgeView(chosenEdge)).selectInternal(false);
- chosenEdgeSelected = 1;
+ if (hits.numRemaining() > 0) {
+ final int hit = hits.nextInt();
- if ((m_lastRenderDetail &
GraphRenderer.LOD_EDGE_ANCHORS) != 0) {
- m_ptBuff[0] = m_lastXMousePos;
- m_ptBuff[1] = m_lastYMousePos;
-
m_view.xformComponentToNodeCoords(m_ptBuff);
-
- final IntEnumerator hits =
m_view.m_spacialA.queryOverlap((float) m_ptBuff[0],
-
(float) m_ptBuff[1],
-
(float) m_ptBuff[0],
-
(float) m_ptBuff[1],
-
null, 0, false);
-
- if (hits.numRemaining() > 0) {
- final int hit = hits.nextInt();
-
- if
(m_view.m_selectedAnchors.count(hit) == 0)
-
m_view.m_selectedAnchors.insert(hit);
- }
+ if (m_view.m_selectedAnchors.count(hit)
== 0)
+
m_view.m_selectedAnchors.insert(hit);
}
}
+ }
- m_button1NodeDrag = true;
- m_view.m_contentChanged = true;
- return chosenEdgeSelected;
+ m_button1NodeDrag = true;
+ m_view.m_contentChanged = true;
+ return chosenEdgeSelected;
}
@@ -1061,7 +1061,6 @@
@Override
void singleLeftClick(MouseEvent e) {
- //System.out.println("MousePressed ---->
singleLeftClick");
m_undoable_edit = null;
m_currMouseButton = 1;
@@ -1113,9 +1112,8 @@
toggleChosenAnchor(chosenAnchor, e);
}
- if (chosenEdge >= 0) {
+ if (chosenEdge >= 0)
chosenEdgeSelected =
toggleSelectedEdge(chosenEdge, e);
- }
if ((chosenNode < 0) && (chosenEdge < 0) &&
(chosenAnchor < 0)) {
m_selectionRect = new
Rectangle(m_lastXMousePos, m_lastYMousePos, 0, 0);
@@ -1161,11 +1159,15 @@
@Override
void singleLeftControlClick(MouseEvent e) {
- //System.out.println("MousePressed ---->
singleLeftControlClick");
+ System.out.println("MousePressed ---->
singleLeftControlClick");
+
// clicking on empty space
if ((getChosenNode() < 0) && (getChosenEdge() < 0) &&
(getChosenAnchor() < 0)) {
popup.createEmptySpaceMenu(e.getX(),
e.getY(),"NEW");
}
+
+ // Cascade
+ this.singleLeftClick(e);
}
@Override
Added:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/EdgeBendVisualProperty.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/EdgeBendVisualProperty.java
(rev 0)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/EdgeBendVisualProperty.java
2011-12-22 23:21:20 UTC (rev 27862)
@@ -0,0 +1,128 @@
+package org.cytoscape.ding.impl.visualproperty;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.cytoscape.ding.Bend;
+import org.cytoscape.ding.Handle;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.view.model.AbstractVisualProperty;
+import org.cytoscape.view.model.ContinuousRange;
+import org.cytoscape.view.model.Range;
+
+public class EdgeBendVisualProperty extends AbstractVisualProperty<Bend> {
+
+ private static final Range<Bend> EDGE_BEND_RANGE;
+ public static final Bend DEFAULT_EDGE_BEND = new DefaultBend();
+
+ static {
+ EDGE_BEND_RANGE = new ContinuousRange<Bend>(Bend.class,
DEFAULT_EDGE_BEND, DEFAULT_EDGE_BEND, true, true);
+ }
+
+ public EdgeBendVisualProperty(Bend defaultValue, String id, String
displayName) {
+ super(defaultValue, EDGE_BEND_RANGE, id, displayName,
CyEdge.class);
+ }
+
+ @Override
+ public String toSerializableString(final Bend value) {
+ return value.toString();
+ }
+
+ @Override
+ public Bend parseSerializableString(String value) {
+ // TODO: Implement parser for String representation of Bend.
+ return DEFAULT_EDGE_BEND;
+ }
+
+
+ private static final class DefaultBend implements Bend {
+
+ @Override
+ public void setHandles(List<Point2D> bendPoints) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Point2D> getHandles() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void moveHandle(int handleIndex, Point2D handlePosition)
{
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Point2D getSourceHandlePoint() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Point2D getTargetHandlePoint() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addHandle(Point2D handlePosition) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addHandle(int handleIndex, Point2D handlePosition) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeHandle(Point2D handlePosition) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeHandle(int handleIndex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeAllHandles() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean handleAlreadyExists(Point2D handlePosition) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void drawSelected() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drawUnselected() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Point2D[] getDrawPoints() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ }
+
+
+}
--
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=en.