Search in sources :

Example 1 with WidthStroke

use of org.cytoscape.ding.impl.strokes.WidthStroke in project cytoscape-impl by cytoscape.

the class DEdgeDetails method getStroke.

@Override
public Stroke getStroke(final CyEdge edge) {
    Stroke stroke = null;
    final DEdgeView dev = dGraphView.getDEdgeView(edge);
    if (dev == null)
        return null;
    if (dev.isValueLocked(EDGE_LINE_TYPE) || dev.isValueLocked(EDGE_WIDTH)) {
        // If one of these properties are locked, the stroke has to be recreated
        final LineType lineType = dev.getVisualProperty(EDGE_LINE_TYPE);
        stroke = DLineType.getDLineType(lineType).getStroke(getWidth(edge));
        // We need to handle animated edges with some care...
        if (stroke instanceof AnimatedStroke) {
            Stroke oldStroke = m_strokes.get(edge);
            if (oldStroke != null && oldStroke.getClass().equals(stroke.getClass()))
                stroke = ((WidthStroke) oldStroke).newInstanceForWidth(getWidth(edge));
        }
    } else {
        stroke = m_strokes.get(edge);
        if (stroke == null) {
            if (m_strokeDefault == null)
                stroke = super.getStroke(edge);
            else
                stroke = m_strokeDefault;
        }
    }
    if (stroke instanceof AnimatedStroke)
        dGraphView.addAnimatedEdge(dev);
    else
        dGraphView.removeAnimatedEdge(dev);
    return stroke;
}
Also used : WidthStroke(org.cytoscape.ding.impl.strokes.WidthStroke) WidthStroke(org.cytoscape.ding.impl.strokes.WidthStroke) BasicStroke(java.awt.BasicStroke) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) Stroke(java.awt.Stroke) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) LineType(org.cytoscape.view.presentation.property.values.LineType)

Aggregations

BasicStroke (java.awt.BasicStroke)1 Stroke (java.awt.Stroke)1 AnimatedStroke (org.cytoscape.ding.impl.strokes.AnimatedStroke)1 WidthStroke (org.cytoscape.ding.impl.strokes.WidthStroke)1 LineType (org.cytoscape.view.presentation.property.values.LineType)1