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();
}
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;
}
Aggregations