Skip to content

Commit

Permalink
CYTOSCAPE-12787 Add support for edge z-order.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekucera committed Feb 9, 2021
1 parent 54f86a7 commit 95138b7
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,30 @@ public class BasicVisualLexicon extends AbstractVisualLexicon {
"EDGE_LABEL_WIDTH", "Edge Label Width", CyEdge.class);


/**
* The strategy to use to render edges when there are more than one edge between a pair of nodes.
* <p><strong>Additional Details: </strong> {@see org.cytoscape.view.presentation.property.EdgeStackingVisualProperty} </p>
*/
public static final VisualProperty<EdgeStacking> EDGE_STACKING = new EdgeStackingVisualProperty(
EdgeStackingVisualProperty.AUTO_BEND, "EDGE_STACKING", "Edge Stacking", CyEdge.class);

/**
* Controls how tightly packed edges are when there are more than one edge between a pair of nodes.
*/
public static final VisualProperty<Double> EDGE_STACKING_DENSITY = new DoubleVisualProperty(0.5, // default must be 0.5 for backwards compatibility
new ContinuousRange<>(Double.class, 0.0, 1.0, true, true),
"EDGE_STACKING_DENSITY", "Stacking Density", CyEdge.class);


/**
* When rendering edges in 2D, edges with a higher Z-order will be rendered on top of edges with lower Z-order.
* If two edges overlap and have the same Z-order then the order they are rendered in is unpredictable.
* <p><strong>Property Type: </strong> {@see java.lang.Double} </p>
* <p><strong>Property Range:</strong> {@see java.lang.Double#NEGATIVE_INFINITY} &LT;= value &LT;= {@see java.lang.Double#POSITIVE_INFINITY}</p>
*/
public static final VisualProperty<Double> EDGE_Z_ORDER = new DoubleVisualProperty(0.0, ARBITRARY_DOUBLE_RANGE,
"EDGE_Z_ORDER", "Edge Z Order", true, CyEdge.class);

// ////// Network VP ////////
/**
* The zoom level of the network view.
Expand Down Expand Up @@ -629,6 +646,7 @@ protected void addVisualProperties(final VisualProperty<NullDataType> root) {
addVisualProperty(EDGE_LABEL_WIDTH, EDGE);
addVisualProperty(EDGE_STACKING, EDGE);
addVisualProperty(EDGE_STACKING_DENSITY, EDGE);
addVisualProperty(EDGE_Z_ORDER, EDGE);

// Level 3 - 4: Node-related VP
addVisualProperty(NODE_FILL_COLOR, NODE_PAINT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testLexiconInstances() {

@Test
public void test2DLexicon() throws Exception {
assertEquals(64, richLex.getAllVisualProperties().size());
assertEquals(65, richLex.getAllVisualProperties().size());
}

@Test
Expand All @@ -93,7 +93,7 @@ public void testGetAllDecendents() throws Exception {
assertEquals(26, nodeChildren.size());

Collection<VisualProperty<?>> edgeChildren = richLex.getAllDescendants(BasicVisualLexicon.EDGE);
assertEquals(24, edgeChildren.size());
assertEquals(25, edgeChildren.size());

Collection<VisualProperty<?>> leaf = richLex.getAllDescendants(BasicVisualLexicon.EDGE_LABEL_COLOR);
assertEquals(0, leaf.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.spacial.SpacialIndex2D;
import org.cytoscape.view.model.spacial.NetworkSpacialIndex2D;


/**
Expand Down Expand Up @@ -55,11 +55,11 @@ public interface CyNetworkViewSnapshot extends CyNetworkView {
CyNetworkView getMutableNetworkView();

/**
* Returns an immutable SpacialIndex2D object that can be used to query the bounds
* Returns an immutable NetworkSpacialIndex2D object that can be used to query the bounds
* of nodes in the network view, or null if the SpacialIndex has been turned off.
* @see CyNetworkViewFactoryConfig#setEnableSpacialIndex2D(boolean)
*/
SpacialIndex2D<Long> getSpacialIndex2D();
NetworkSpacialIndex2D getSpacialIndex2D();

/**
* Returns the immutable node View for the given view SUID.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.cytoscape.view.model.spacial;

import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.View;

public interface EdgeSpacialIndex2DEnumerator {

int size();

boolean hasNext();

View<CyEdge> nextEdge();

View<CyEdge> nextEdgeWithNodeExtents(float[] sourceExtents, float[] targetExtents, View<CyNode>[] nodes);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.cytoscape.view.model.spacial;

/**
* A spacial index used to query for locations of Nodes and Edges in a 2D representation of a network.
*/
public interface NetworkSpacialIndex2D extends SpacialIndex2D<Long> {


public NodeSpacialIndex2DEnumerator queryAllNodes();

public NodeSpacialIndex2DEnumerator queryOverlapNodes(float xMin, float yMin, float xMax, float yMax);


public EdgeSpacialIndex2DEnumerator queryAllEdges();

public EdgeSpacialIndex2DEnumerator queryOverlapEdges(float xMin, float yMin, float xMax, float yMax);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.cytoscape.view.model.spacial;

import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.View;

public interface NodeSpacialIndex2DEnumerator extends SpacialIndex2DEnumerator<Long> {

public View<CyNode> nextNode();

public View<CyNode> nextNodeExtents(float[] extents);

}

0 comments on commit 95138b7

Please sign in to comment.