use of au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess in project constellation by constellation-app.
the class GLInteractiveVisualManagerFactory method constructVisualManager.
@Override
public VisualManager constructVisualManager(Graph graph) {
final GraphVisualAccess access = new GraphVisualAccess(graph);
try (final ReadableGraph rg = graph.getReadableGraph()) {
access.updateModCounts(rg);
}
final Preferences prefs = NbPreferences.forModule(DeveloperPreferenceKeys.class);
final InteractiveGLVisualProcessor processor = new InteractiveGLVisualProcessor(prefs.getBoolean(DeveloperPreferenceKeys.DEBUG_GL, DeveloperPreferenceKeys.DEBUG_GL_DEFAULT), prefs.getBoolean(DeveloperPreferenceKeys.PRINT_GL_CAPABILITIES, DeveloperPreferenceKeys.PRINT_GL_CAPABILITIES_DEFAULT));
final VisualManager manager = new VisualManager(access, processor);
final GraphChangeListener changeDetector = event -> manager.updateFromIndigenousChanges();
final DefaultInteractionEventHandler eventHandler = new DefaultInteractionEventHandler(graph, manager, processor, processor);
processor.addDropTargetToCanvas(new GraphRendererDropTarget(graph, manager, processor));
graph.addGraphChangeListener(changeDetector);
changeDetector.graphChanged(null);
processor.startVisualising(manager);
processor.setEventHandler(eventHandler);
return manager;
}
use of au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess in project constellation by constellation-app.
the class GLVisualProcessorGraphTester method main.
public static void main(String[] args) {
final GLVisualProcessorDemo demo = new GLVisualProcessorDemo();
final StoreGraph graph = createGraph();
final Graph dualGraph = new DualGraph(graph, false);
final GraphVisualAccess access = new GraphVisualAccess(dualGraph);
final GLVisualProcessor processor = new GLVisualProcessor();
final VisualManager visualManager = new VisualManager(access, processor);
processor.startVisualising(visualManager);
demo.runDemo(processor, visualManager);
final GraphChangeListener gct = (event) -> visualManager.updateFromIndigenousChanges();
gct.graphChanged(null);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
try {
WritableGraph wg = dualGraph.getWritableGraph("linkmode", false);
try {
final int connectionModeAttr = VisualConcept.GraphAttribute.CONNECTION_MODE.ensure(wg);
wg.setObjectValue(connectionModeAttr, 0, ConnectionMode.LINK);
} finally {
wg.commit();
}
} catch (InterruptedException ex) {
}
gct.graphChanged(null);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
try {
WritableGraph wg = dualGraph.getWritableGraph("transmode", false);
try {
final int connectionModeAttr = VisualConcept.GraphAttribute.CONNECTION_MODE.ensure(wg);
wg.setObjectValue(connectionModeAttr, 0, ConnectionMode.TRANSACTION);
} finally {
wg.commit();
}
} catch (InterruptedException ex) {
}
gct.graphChanged(null);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
final int[] changed = new int[] { 0, 1 };
try {
WritableGraph wg = dualGraph.getWritableGraph("blazin", false);
try {
final int blazeAttr = VisualConcept.VertexAttribute.BLAZE.ensure(wg);
for (int i = 0; i < 10000; i++) {
try {
Thread.sleep(1);
} catch (InterruptedException ex) {
}
wg.setObjectValue(blazeAttr, 0, new Blaze(((Blaze) wg.getObjectValue(blazeAttr, 0)).getAngle() + 1, ConstellationColor.BLUE));
wg = wg.flush(false);
visualManager.addSingleChangeOperation(new VisualChangeBuilder(VisualProperty.VERTEX_BLAZE_ANGLE).forItems(changed).build());
}
} finally {
wg.commit();
}
} catch (InterruptedException ex) {
}
}
Aggregations