Search in sources :

Example 1 with ViewChangeRecord

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);
}
Also used : ViewChangeRecord(org.cytoscape.view.model.events.ViewChangeRecord)

Example 2 with ViewChangeRecord

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();
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) ViewChangeRecord(org.cytoscape.view.model.events.ViewChangeRecord) Collection(java.util.Collection) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

ViewChangeRecord (org.cytoscape.view.model.events.ViewChangeRecord)2 Collection (java.util.Collection)1 CyEventHelper (org.cytoscape.event.CyEventHelper)1 CyNode (org.cytoscape.model.CyNode)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1