Search in sources :

Example 1 with AnimatedStroke

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

the class DGraphView method actionPerformed.

/**
 ****************************************************
 * Animation handling.  Currently, this only supports *
 * edge marquee, but could be extended in the future  *
 * to support other kinds of animations.              *
 ****************************************************
 */
@Override
public void actionPerformed(ActionEvent e) {
    // If we're not even drawing dashed edges, no sense in trying to do marquee
    if ((m_networkCanvas.getLastRenderDetail() & GraphRenderer.LOD_DASHED_EDGES) == 0) {
        return;
    }
    List<DEdgeView> removeMe = new ArrayList<>();
    for (DEdgeView edgeView : animatedEdges) {
        CyEdge edge = edgeView.getModel();
        Stroke s = m_edgeDetails.getStroke(edge);
        if (s != null && s instanceof AnimatedStroke) {
            Stroke as = ((AnimatedStroke) s).newInstanceForNextOffset();
            synchronized (m_lock) {
                m_edgeDetails.overrideStroke(edge, as);
                setContentChanged();
            }
        } else if (s == null) {
            removeMe.add(edgeView);
        }
    }
    // We do this this way to avoid the overhead of concurrent maps since this should be relatively rare
    if (removeMe.size() != 0) {
        for (DEdgeView edgeView : removeMe) animatedEdges.remove(edgeView);
    }
    // Redraw?
    m_networkCanvas.repaint();
// updateView();
}
Also used : AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) Stroke(java.awt.Stroke) ArrayList(java.util.ArrayList) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) CyEdge(org.cytoscape.model.CyEdge)

Example 2 with AnimatedStroke

use of org.cytoscape.ding.impl.strokes.AnimatedStroke 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

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