Search in sources :

Example 1 with VisualSchemaFactory

use of au.gov.asd.tac.constellation.graph.schema.visual.VisualSchemaFactory in project constellation by constellation-app.

the class HierarchicalControllerTopComponent method setNode.

/**
 * Make the graph in the specified node the source for the clustering model.
 * <p>
 * If another graph is attached to the model, it is detached first.
 *
 * @param node The GraphNode containing the graph to be displayed.
 */
private void setNode(final GraphNode node) {
    if (graphNode != null) {
        graph.removeGraphChangeListener(this);
    }
    if (node != null) {
        graphNode = node;
        graph = graphNode.getGraph();
        final ReadableGraph rg = graph.getReadableGraph();
        try {
            final int stateAttr = ClusteringConcept.MetaAttribute.HIERARCHICAL_CLUSTERING_STATE.get(rg);
            state = stateAttr != Graph.NOT_FOUND ? (HierarchicalState) rg.getObjectValue(stateAttr, 0) : null;
            if (rg.getSchema() != null && !(rg.getSchema().getFactory() instanceof VisualSchemaFactory)) {
                interactiveButton.setSelected(false);
                interactiveButton.setText(TOGGLE_ENABLED);
                interactivityPermitted = false;
            } else if (state != null) {
                interactiveButton.setText(state.isInteractive() ? TOGGLE_ENABLED : TOGGLE_DISABLED);
                interactiveButton.setSelected(state.isInteractive());
                colorClustersCheckBox.setSelected(state.isColored());
                interactivityPermitted = true;
            } else {
                interactiveButton.setText(TOGGLE_DISABLED);
                interactiveButton.setSelected(true);
                colorClustersCheckBox.setSelected(true);
                interactivityPermitted = true;
            }
        } finally {
            rg.release();
        }
        graph.addGraphChangeListener(this);
    } else {
        graphNode = null;
        graph = null;
        state = null;
    }
    setGroups(false);
}
Also used : VisualSchemaFactory(au.gov.asd.tac.constellation.graph.schema.visual.VisualSchemaFactory) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph)

Aggregations

ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 VisualSchemaFactory (au.gov.asd.tac.constellation.graph.schema.visual.VisualSchemaFactory)1