use of org.cytoscape.view.presentation.property.values.ArrowShape in project cytoscape-impl by cytoscape.
the class GraphGraphicsTest method drawCurrentFull.
private long drawCurrentFull(Random rand) {
final float nodeSizeFactor = 50f;
float size = (float) canvasSize;
long begin = System.nanoTime();
for (int i = 0; i < numNodes; i++) {
float x = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
float y = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
currentGraphGraphics.drawNodeFull((byte) (i % (int) GraphGraphics.s_last_shape), x, y, (x + (rand.nextFloat() * nodeSizeFactor)), (y + (rand.nextFloat() * nodeSizeFactor)), Color.blue, 1.0f + (i % 10), null, Color.yellow);
}
long end = System.nanoTime();
long nodeDur = end - begin;
BasicStroke edgeStroke = new BasicStroke(1f);
begin = System.nanoTime();
for (int i = 0; i < numEdges; i++) {
ArrowShape arrow = ARROWS[i % 7];
currentGraphGraphics.drawEdgeFull(arrow, rand.nextFloat() * (20f), Color.red, arrow, rand.nextFloat() * (20f), Color.orange, rand.nextFloat() * (rand.nextBoolean() ? size : -size), rand.nextFloat() * (rand.nextBoolean() ? size : -size), currentGraphGraphics.m_noAnchors, rand.nextFloat() * (rand.nextBoolean() ? size : -size), rand.nextFloat() * (rand.nextBoolean() ? size : -size), 1f, edgeStroke, Color.green);
}
end = System.nanoTime();
long duration = (end - begin) + nodeDur;
// } catch (IOException ioe) { ioe.printStackTrace(); }
return duration;
}
use of org.cytoscape.view.presentation.property.values.ArrowShape in project cytoscape-impl by cytoscape.
the class VisualStyleSerializerTest method testCy270Vizmap.
@Test
@SuppressWarnings("unchecked")
public void testCy270Vizmap() throws Exception {
Properties props = loadVizmapProps("v270_vizmap.props");
Set<VisualStyle> styles = serializer.createVisualStyles(props);
assertEquals(2, styles.size());
assertVisualStylesNotNull(styles, new String[] { "default", "Binary_SIF_Version_1" });
// Test visual styles (defaults, mappings and dependencies)
// -----
VisualStyle s = getVisualStyleByTitle(styles, "Binary_SIF_Version_1");
assertEquals(new Color(255, 153, 153), s.getDefaultValue(NODE_FILL_COLOR));
assertEquals(new Color(255, 255, 0), s.getDefaultValue(NODE_SELECTED_PAINT));
assertEquals(NodeShapeVisualProperty.ELLIPSE, s.getDefaultValue(NODE_SHAPE));
assertEquals(70, s.getDefaultValue(NODE_WIDTH).intValue());
assertEquals(30, s.getDefaultValue(NODE_HEIGHT).intValue());
assertEquals(35, s.getDefaultValue(NODE_SIZE).intValue());
assertEquals(125, s.getDefaultValue(NODE_TRANSPARENCY).intValue());
assertEquals(new Color(0, 0, 0), s.getDefaultValue(NODE_BORDER_PAINT));
assertEquals(1, s.getDefaultValue(NODE_BORDER_WIDTH).intValue());
assertEquals(255, s.getDefaultValue(NODE_BORDER_TRANSPARENCY).intValue());
assertEquals("", s.getDefaultValue(NODE_LABEL));
assertEquals(Font.decode("Default-PLAIN-12"), s.getDefaultValue(NODE_LABEL_FONT_FACE));
assertEquals(12, s.getDefaultValue(NODE_LABEL_FONT_SIZE).intValue());
assertEquals(new Color(0, 0, 0), s.getDefaultValue(NODE_LABEL_COLOR));
assertEquals(100, s.getDefaultValue(NODE_LABEL_WIDTH).intValue());
assertEquals(255, s.getDefaultValue(NODE_LABEL_TRANSPARENCY).intValue());
assertEquals(LineTypeVisualProperty.SOLID, s.getDefaultValue(NODE_BORDER_LINE_TYPE));
assertEquals("", s.getDefaultValue(NODE_TOOLTIP));
assertEquals(Boolean.TRUE, s.getDefaultValue(NODE_NESTED_NETWORK_IMAGE_VISIBLE));
assertEquals(4, s.getDefaultValue(EDGE_WIDTH).intValue());
assertEquals(new Color(0, 0, 0), s.getDefaultValue(EDGE_UNSELECTED_PAINT));
assertEquals(new Color(0, 0, 0), s.getDefaultValue(EDGE_STROKE_UNSELECTED_PAINT));
assertEquals(new Color(255, 0, 0), s.getDefaultValue(EDGE_STROKE_SELECTED_PAINT));
assertEquals(255, s.getDefaultValue(EDGE_TRANSPARENCY).intValue());
assertEquals(LineTypeVisualProperty.SOLID, s.getDefaultValue(EDGE_LINE_TYPE));
assertEquals("", s.getDefaultValue(EDGE_LABEL));
assertEquals(Font.decode("SanSerif-PLAIN-10"), s.getDefaultValue(EDGE_LABEL_FONT_FACE));
assertEquals(10, s.getDefaultValue(EDGE_LABEL_FONT_SIZE).intValue());
assertEquals(new Color(0, 0, 0), s.getDefaultValue(EDGE_LABEL_COLOR));
assertEquals(255, s.getDefaultValue(EDGE_LABEL_TRANSPARENCY).intValue());
assertEquals(ArrowShapeVisualProperty.NONE, s.getDefaultValue(EDGE_SOURCE_ARROW_SHAPE));
assertEquals(ArrowShapeVisualProperty.NONE, s.getDefaultValue(EDGE_TARGET_ARROW_SHAPE));
assertEquals("", s.getDefaultValue(EDGE_TOOLTIP));
PassthroughMapping<String, String> nLabelMp = (PassthroughMapping<String, String>) s.getVisualMappingFunction(NODE_LABEL);
assertEquals("biopax.node_label", nLabelMp.getMappingColumnName());
assertEquals(String.class, nLabelMp.getMappingColumnType());
assertNull(s.getVisualMappingFunction(EDGE_LABEL));
DiscreteMapping<String, Paint> nColorMp = (DiscreteMapping<String, Paint>) s.getVisualMappingFunction(NODE_FILL_COLOR);
assertEquals("biopax.entity_type", nColorMp.getMappingColumnName());
assertEquals(String.class, nColorMp.getMappingColumnType());
assertEquals(new Color(153, 153, 255), nColorMp.getMapValue("Complex"));
assertNull(nColorMp.getMapValue("Protein"));
DiscreteMapping<String, Paint> eColorMp = (DiscreteMapping<String, Paint>) s.getVisualMappingFunction(EDGE_STROKE_UNSELECTED_PAINT);
assertEquals(INTERACTION, eColorMp.getMappingColumnName());
assertEquals(String.class, eColorMp.getMappingColumnType());
// Test a few entries
assertEquals(new Color(255, 192, 0), eColorMp.getMapValue("COMPONENT_OF"));
assertEquals(new Color(255, 0, 0), eColorMp.getMapValue("CO_CONTROL_DEPENDENT_ANTI"));
assertEquals(new Color(0, 176, 80), eColorMp.getMapValue("CO_CONTROL_DEPENDENT_SIMILAR"));
assertEquals(new Color(253, 149, 166), eColorMp.getMapValue("CO_CONTROL_INDEPENDENT_ANTI"));
assertEquals(new Color(0, 176, 80), eColorMp.getMapValue("CO_CONTROL_DEPENDENT_SIMILAR"));
DiscreteMapping<String, ArrowShape> eTgtArrowMp = (DiscreteMapping<String, ArrowShape>) s.getVisualMappingFunction(EDGE_TARGET_ARROW_SHAPE);
assertEquals(INTERACTION, eTgtArrowMp.getMappingColumnName());
assertEquals(String.class, eTgtArrowMp.getMappingColumnType());
assertEquals(ArrowShapeVisualProperty.ARROW, eTgtArrowMp.getMapValue("COMPONENT_OF"));
assertEquals(ArrowShapeVisualProperty.ARROW, eTgtArrowMp.getMapValue("METABOLIC_CATALYSIS"));
assertEquals(ArrowShapeVisualProperty.ARROW, eTgtArrowMp.getMapValue("SEQUENTIAL_CATALYSIS"));
assertEquals(ArrowShapeVisualProperty.ARROW, eTgtArrowMp.getMapValue("SEQUENTIAL_CATALYSIS"));
assertEquals(ArrowShapeVisualProperty.ARROW, eTgtArrowMp.getMapValue("STATE_CHANGE"));
assertNull(eTgtArrowMp.getMapValue("INTERACTS_WITH"));
VisualPropertyDependency<?> dep1 = getDependency(s, NODE_SIZE_LOCKED_DEPENDENCY);
assertFalse(dep1.isDependencyEnabled());
}
use of org.cytoscape.view.presentation.property.values.ArrowShape in project cytoscape-impl by cytoscape.
the class DEdgeDetails method getTargetArrowShape.
@Override
public ArrowShape getTargetArrowShape(final CyEdge edge) {
// Check bypass
final DEdgeView dev = dGraphView.getDEdgeView(edge);
if (dev.isValueLocked(EDGE_TARGET_ARROW_SHAPE)) {
final ArrowShape tgtArrow = dev.getVisualProperty(EDGE_TARGET_ARROW_SHAPE);
final String shapeID = tgtArrow.getSerializableString();
return DArrowShape.parseArrowText(shapeID).getPresentationShape();
}
final ArrowShape arrow = m_targetArrows.get(edge);
if (arrow == null)
return m_targetArrowDefault == null ? super.getTargetArrowShape(edge) : m_targetArrowDefault;
return arrow;
}
use of org.cytoscape.view.presentation.property.values.ArrowShape in project cytoscape-impl by cytoscape.
the class EdgeViewDefaultSupport method setViewDefault.
@Override
protected <V> void setViewDefault(final VisualProperty<V> vp, V value) {
if (value == null)
value = (V) vp.getDefault();
//
if (vp == EDGE_STROKE_SELECTED_PAINT) {
setSelectedPaint((Paint) value);
} else if (vp == EDGE_STROKE_UNSELECTED_PAINT) {
setUnselectedPaint((Paint) value);
} else if (vp == EDGE_UNSELECTED_PAINT) {
setUnselectedPaint((Paint) value);
} else if (vp == EDGE_SELECTED_PAINT) {
setSelectedPaint((Paint) value);
} else if (vp == EDGE_TRANSPARENCY) {
setTransparency(((Number) value).intValue());
} else if (vp == EDGE_WIDTH) {
final float newWidth = ((Number) value).floatValue();
Float currentWidth = edgeDetails.m_widthDefault.floatValue();
if (currentWidth.floatValue() != newWidth) {
setWidth(newWidth);
setStroke(DLineType.getDLineType(lineType).getStroke(newWidth), lineType);
}
} else if (vp == EDGE_LINE_TYPE) {
lineType = (LineType) value;
final Stroke newStroke = DLineType.getDLineType(lineType).getStroke(edgeDetails.m_widthDefault.floatValue());
setStroke(newStroke, lineType);
} else if (vp == EDGE_SOURCE_ARROW_UNSELECTED_PAINT) {
setSourceArrowUnselectedPaint((Paint) value);
} else if (vp == EDGE_TARGET_ARROW_UNSELECTED_PAINT) {
setTargetArrowUnselectedPaint((Paint) value);
} else if (vp == EDGE_TARGET_ARROW_SHAPE) {
final ArrowShape shape = (ArrowShape) value;
final String shapeID = shape.getSerializableString();
setTargetArrow(DArrowShape.parseArrowText(shapeID).getPresentationShape());
} else if (vp == EDGE_SOURCE_ARROW_SHAPE) {
final ArrowShape shape = (ArrowShape) value;
final String shapeID = shape.getSerializableString();
setSourceArrow(DArrowShape.parseArrowText(shapeID).getPresentationShape());
} else if (vp == EDGE_SOURCE_ARROW_SIZE) {
double newSize = ((Number) value).doubleValue();
setSourceArrowSize(newSize);
} else if (vp == EDGE_TARGET_ARROW_SIZE) {
double newSize = ((Number) value).doubleValue();
setTargetArrowSize(newSize);
} else if (vp == EDGE_LABEL) {
setText((String) value);
} else if (vp == EDGE_LABEL_FONT_FACE) {
final int fontSize = edgeDetails.m_labelFontDefault.getSize();
setFont((Font) value, fontSize);
} else if (vp == EDGE_LABEL_FONT_SIZE) {
final int currentFontSize = edgeDetails.m_labelFontDefault.getSize();
final int newFontSize = ((Number) value).intValue();
if (currentFontSize != newFontSize)
setFont(edgeDetails.m_labelFontDefault, newFontSize);
} else if (vp == EDGE_LABEL_COLOR) {
setTextPaint((Paint) value);
} else if (vp == EDGE_LABEL_TRANSPARENCY) {
final int newLabelTransparency = ((Number) value).intValue();
final int currentLabelTransparency = edgeDetails.labelTransparencyDefault;
if (newLabelTransparency != currentLabelTransparency)
setLabelTransparency(newLabelTransparency);
} else if (vp == DVisualLexicon.EDGE_LABEL_WIDTH) {
double newSize = ((Number) value).doubleValue();
setLabelWidth(newSize);
} else if (vp == EDGE_CURVED) {
setCurved((Boolean) value);
} else if (vp == EDGE_BEND) {
setBend((Bend) value);
} else {
synchronized (lock) {
edgeDetails.setDefaultValue(vp, value);
}
}
}
use of org.cytoscape.view.presentation.property.values.ArrowShape in project cytoscape-impl by cytoscape.
the class VisualPropertyIconFactory method createIcon.
public static <V> Icon createIcon(V value, int w, int h) {
if (value == null)
return null;
Icon icon = null;
if (value instanceof Color) {
icon = new ColorIcon((Color) value, w, h, value.toString());
} else if (value instanceof NodeShape) {
final DNodeShape dShape;
if (NodeShapeVisualProperty.isDefaultShape((NodeShape) value))
dShape = DNodeShape.getDShape((NodeShape) value);
else
dShape = (DNodeShape) value;
icon = new NodeIcon(dShape.getShape(), w, h, dShape.getDisplayName());
} else if (value instanceof LineType) {
icon = new StrokeIcon(DLineType.getDLineType((LineType) value).getStroke(2f), w, h, value.toString());
} else if (value instanceof CyCustomGraphics) {
final String name = ((CyCustomGraphics) value).getDisplayName();
if (name != null)
icon = new CustomGraphicsIcon(((CyCustomGraphics) value), w, h, name);
} else if (value instanceof ObjectPosition) {
icon = new ObjectPositionIcon((ObjectPosition) value, w, h, "Label");
} else if (value instanceof Font) {
icon = new FontFaceIcon((Font) value, w, h, "");
} else if (value instanceof ArrowShape) {
final ArrowShape arrowShape = (ArrowShape) value;
final DArrowShape dShape;
if (ArrowShapeVisualProperty.isDefaultShape(arrowShape))
dShape = DArrowShape.getArrowShape(arrowShape);
else
dShape = DArrowShape.NONE;
if (dShape.getShape() == null)
// No arrow
icon = new TextIcon(value, w, h, "");
else
icon = new ArrowIcon(dShape.getShape(), w, h, dShape.getDisplayName());
} else if (value instanceof Bend) {
icon = new EdgeBendIcon((Bend) value, w, h, value.toString());
} else {
// If not found, use return value of toString() as icon.
icon = new TextIcon(value, w, h, value.toString());
}
return icon;
}
Aggregations