Search in sources :

Example 1 with GraphChangeListener

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);
                    }
                }
            });
        }
    };
}
Also used : GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) GraphChangeEvent(au.gov.asd.tac.constellation.graph.monitor.GraphChangeEvent)

Example 2 with GraphChangeListener

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));
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) UndoRedo(org.openide.awt.UndoRedo) GraphChangeEvent(au.gov.asd.tac.constellation.graph.monitor.GraphChangeEvent) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Example 3 with GraphChangeListener

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;
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) GraphVisualManagerFactory(au.gov.asd.tac.constellation.graph.interaction.framework.GraphVisualManagerFactory) DeveloperPreferenceKeys(au.gov.asd.tac.constellation.preferences.DeveloperPreferenceKeys) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ServiceProvider(org.openide.util.lookup.ServiceProvider) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) NbPreferences(org.openide.util.NbPreferences) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) Preferences(java.util.prefs.Preferences) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) NbPreferences(org.openide.util.NbPreferences) Preferences(java.util.prefs.Preferences)

Example 4 with GraphChangeListener

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) {
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Frame(java.awt.Frame) GLVisualProcessor(au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor) Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) DefaultIconProvider(au.gov.asd.tac.constellation.utilities.icon.DefaultIconProvider) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) WindowAdapter(java.awt.event.WindowAdapter) JFXPanel(javafx.embed.swing.JFXPanel) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) Component(java.awt.Component) WindowEvent(java.awt.event.WindowEvent) VisualProcessor(au.gov.asd.tac.constellation.utilities.visual.VisualProcessor) VisualProperty(au.gov.asd.tac.constellation.utilities.visual.VisualProperty) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) ConnectionMode(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) GLVisualProcessor(au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Aggregations

GraphChangeListener (au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener)4 Graph (au.gov.asd.tac.constellation.graph.Graph)3 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)2 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)2 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)2 GraphChangeEvent (au.gov.asd.tac.constellation.graph.monitor.GraphChangeEvent)2 GraphVisualAccess (au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess)2 VisualManager (au.gov.asd.tac.constellation.utilities.visual.VisualManager)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 GraphVisualManagerFactory (au.gov.asd.tac.constellation.graph.interaction.framework.GraphVisualManagerFactory)1 Blaze (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)1 ConnectionMode (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode)1 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)1 DeveloperPreferenceKeys (au.gov.asd.tac.constellation.preferences.DeveloperPreferenceKeys)1 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)1 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)1 DefaultIconProvider (au.gov.asd.tac.constellation.utilities.icon.DefaultIconProvider)1 VisualChangeBuilder (au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder)1 VisualProcessor (au.gov.asd.tac.constellation.utilities.visual.VisualProcessor)1