use of org.cytoscape.view.model.events.ViewChangeRecord in project cytoscape-impl by cytoscape.
the class AbstractDViewModel method fireViewChangedEvent.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected <T, V extends T> void fireViewChangedEvent(final VisualProperty<? extends T> vp, final V value, final boolean lockedValue) {
final ViewChangeRecord record = new ViewChangeRecord(this, vp, value, lockedValue);
getEventHelper().addEventPayload(getDGraphView(), record, ViewChangedEvent.class);
}
use of org.cytoscape.view.model.events.ViewChangeRecord in project cytoscape-impl by cytoscape.
the class NodeChangeListener method handleEvent.
public void handleEvent(ViewChangedEvent<?> e) {
if (ignoreChanges) {
// System.out.println("Ignoring changes");
return;
}
CyNetworkView networkView = e.getSource();
if (!groupMap.containsKey(networkView))
return;
Set<CyNode> groupNodes = groupMap.get(networkView);
Set<CyNode> nodes = nodeMap.get(networkView);
Collection<?> payload = e.getPayloadCollection();
for (ViewChangeRecord vcr : (Collection<ViewChangeRecord>) payload) {
// Only care about nodes
if (!(vcr.getView().getModel() instanceof CyNode))
continue;
View<CyNode> nodeView = vcr.getView();
VisualProperty<?> property = vcr.getVisualProperty();
if (property.equals(BasicVisualLexicon.NODE_X_LOCATION) || property.equals(BasicVisualLexicon.NODE_Y_LOCATION) || property.equals(BasicVisualLexicon.NODE_WIDTH) || property.equals(BasicVisualLexicon.NODE_HEIGHT)) {
CyNode node = nodeView.getModel();
// System.out.println("Got geometry change for "+node);
if (groupNodes.contains(node)) {
// System.out.println("It's a group: "+node);
try {
updateGroupLocation(networkView, nodeView);
} catch (Exception ee) {
ee.printStackTrace();
}
}
// System.out.println("It's a node: "+node);
try {
updateNodeLocation(networkView, nodeView);
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
final CyEventHelper cyEventHelper = cyGroupManager.getService(CyEventHelper.class);
// Do we need to update the view?
cyEventHelper.flushPayloadEvents();
}
Aggregations