use of au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener in project constellation by constellation-app.
the class DualGraph method createLockingManager.
private LockingManager<LockingStoreGraph> createLockingManager() {
return new LockingManager<LockingStoreGraph>() {
@Override
protected void update(final Object description, final Object editor) {
final GraphChangeEvent event = new GraphChangeEvent(previousEvent, DualGraph.this, editor, description);
previousEvent = event;
SwingUtilities.invokeLater(() -> {
synchronized (graphChangeListeners) {
for (final GraphChangeListener listener : graphChangeListeners) {
listener.graphChanged(event);
}
}
});
}
};
}
use of au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener in project constellation by constellation-app.
the class DualGraphFlushTester method main.
public static void main(String[] args) throws InterruptedException {
StoreGraph g = new StoreGraph();
Graph dg = new DualGraph(g, true);
dg.setUndoManager(new UndoRedo.Manager());
WritableGraph wg = dg.getWritableGraph("sdfgsdfg", true);
final int x = VisualConcept.VertexAttribute.X.ensure(wg);
final int y = VisualConcept.VertexAttribute.Y.ensure(wg);
final int z = VisualConcept.VertexAttribute.Z.ensure(wg);
final int id = VisualConcept.VertexAttribute.IDENTIFIER.ensure(wg);
for (int i = 0; i < 1000; i++) {
final int vxId = wg.addVertex();
wg.setFloatValue(x, vxId, i);
wg.setFloatValue(y, vxId, i);
wg.setFloatValue(z, vxId, i);
wg.setStringValue(id, vxId, String.valueOf(i));
}
wg.commit();
final float[] coordSums = new float[1000];
GraphChangeListener gcl = (GraphChangeEvent event) -> {
ReadableGraph rg = dg.getReadableGraph();
try {
for (int i = 0; i < 1000; i++) {
final int vxId = rg.getVertex(i);
coordSums[i] = rg.getFloatValue(x, vxId) + rg.getFloatValue(y, vxId) + rg.getFloatValue(z, vxId);
}
} finally {
rg.release();
}
};
dg.addGraphChangeListener(gcl);
long time = System.currentTimeMillis();
wg = dg.getWritableGraph("test", false);
for (int i = 0; i < 100000; i++) {
for (int j = 0; j < 1000; j++) {
final int vxId = wg.getVertex(j);
wg.setFloatValue(x, vxId, wg.getFloatValue(x, vxId) + 1);
wg.setFloatValue(y, vxId, wg.getFloatValue(y, vxId) + 2);
wg.setFloatValue(z, vxId, wg.getFloatValue(z, vxId) + 3);
}
wg = wg.flush(false);
}
wg.commit();
LOGGER.log(Level.INFO, "took: {0}", (System.currentTimeMillis() - time));
Thread.sleep(3000);
LOGGER.log(Level.INFO, "{0}", Arrays.toString(coordSums));
}
use of au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener 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.monitor.GraphChangeListener 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