Search in sources :

Example 1 with Blaze

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

the class AddCustomBlazePlugin method setBlazeColor.

/**
 * If a blaze exists on the specified vertex, set its color.
 *
 * @param wg
 * @param blazeId
 * @param vxId
 * @param cv
 */
private static void setBlazeColor(final GraphWriteMethods wg, final int blazeId, final int vxId, final ConstellationColor cv) {
    Blaze blaze = (Blaze) wg.getObjectValue(blazeId, vxId);
    if (blaze == null) {
        blaze = BlazeUtilities.DEFAULT_BLAZE;
    }
    final Blaze blazec = new Blaze(blaze.getAngle(), cv);
    wg.setObjectValue(blazeId, vxId, blazec);
}
Also used : Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)

Example 2 with Blaze

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

the class BlazeAttributeDescriptionNGTest method testConvertFromString.

/**
 * Test of convertFromString method, of class BlazeAttributeDescription.
 */
@Test
public void testConvertFromString() {
    System.out.println("convertFromString");
    final BlazeAttributeDescription instance = new BlazeAttributeDescription();
    final Blaze nullResult = instance.convertFromString(null);
    // default value is null
    assertNull(nullResult);
    final Blaze blankResult = instance.convertFromString("   ");
    // also default value
    assertNull(blankResult);
    final Blaze dodgyBlazeResult = instance.convertFromString("Not a blaze");
    assertNull(dodgyBlazeResult);
    final Blaze validBlazeResult = instance.convertFromString("42;RGB254255106");
    final Blaze expectedBlaze = new Blaze(42, ConstellationColor.BANANA);
    assertEquals(validBlazeResult, expectedBlaze);
}
Also used : Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) Test(org.testng.annotations.Test)

Example 3 with Blaze

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

the class SelectBlazesPluginNGTest method testSelectBlazes.

@Test
public void testSelectBlazes() throws Exception {
    // setup attributes
    final int vertexBlazeAttribute = VisualConcept.VertexAttribute.BLAZE.ensure(graph);
    final int vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // add a node to the graph
    final int vxId0 = graph.addVertex();
    PluginExecution.withPlugin(VisualGraphPluginRegistry.SELECT_BLAZES).executeNow(graph);
    assertEquals(graph.getBooleanValue(vertexSelectedAttribute, vxId0), false);
    // add a blaze
    graph.setObjectValue(vertexBlazeAttribute, vxId0, new Blaze(0, ConstellationColor.BANANA));
    PluginExecution.withPlugin(VisualGraphPluginRegistry.SELECT_BLAZES).executeNow(graph);
    assertEquals(graph.getBooleanValue(vertexSelectedAttribute, vxId0), true);
}
Also used : Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) Test(org.testng.annotations.Test)

Example 4 with Blaze

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

the class GLVisualProcessorGraphTester method createGraph.

public static StoreGraph createGraph() {
    StoreGraph g = new StoreGraph();
    final int v1 = g.addVertex();
    final int v2 = g.addVertex();
    final int t1 = g.addTransaction(v1, v2, false);
    final int t2 = g.addTransaction(v1, v2, false);
    final int t3 = g.addTransaction(v1, v2, true);
    final int t4 = g.addTransaction(v2, v1, true);
    final int loop = g.addTransaction(v1, v1, false);
    final int xAttr = VisualConcept.VertexAttribute.X.ensure(g);
    final int yAttr = VisualConcept.VertexAttribute.Y.ensure(g);
    final int zAttr = VisualConcept.VertexAttribute.Z.ensure(g);
    final int bgIconAttr = VisualConcept.VertexAttribute.BACKGROUND_ICON.ensure(g);
    final int iconAttr = VisualConcept.VertexAttribute.FOREGROUND_ICON.ensure(g);
    final int backgroundColorAttr = VisualConcept.GraphAttribute.BACKGROUND_COLOR.ensure(g);
    final int cameraAttr = VisualConcept.GraphAttribute.CAMERA.ensure(g);
    final int blazeAttr = VisualConcept.VertexAttribute.BLAZE.ensure(g);
    final int widthAttr = VisualConcept.TransactionAttribute.WIDTH.ensure(g);
    g.setDoubleValue(widthAttr, t1, 0.8);
    g.setDoubleValue(widthAttr, t2, 1.0);
    g.setDoubleValue(widthAttr, t3, 1.2);
    g.setDoubleValue(widthAttr, t4, 1.4);
    g.setDoubleValue(widthAttr, loop, 1.6);
    g.setIntValue(xAttr, v1, -2);
    g.setIntValue(xAttr, v2, 2);
    g.setIntValue(yAttr, v1, 0);
    g.setIntValue(yAttr, v2, 0);
    g.setIntValue(zAttr, v1, -10);
    g.setIntValue(zAttr, v2, -10);
    g.setStringValue(bgIconAttr, v1, DefaultIconProvider.FLAT_SQUARE.getExtendedName());
    g.setStringValue(bgIconAttr, v2, DefaultIconProvider.FLAT_SQUARE.getExtendedName());
    g.setStringValue(iconAttr, v1, DefaultIconProvider.UNKNOWN.getExtendedName());
    g.setStringValue(iconAttr, v2, DefaultIconProvider.UNKNOWN.getExtendedName());
    g.setObjectValue(blazeAttr, v1, new Blaze(0, ConstellationColor.AZURE));
    g.setObjectValue(cameraAttr, 0, new Camera());
    g.setObjectValue(backgroundColorAttr, 0, ConstellationColor.NIGHT_SKY);
    g.setPrimaryKey(GraphElementType.VERTEX, xAttr);
    g.setPrimaryKey(GraphElementType.TRANSACTION, widthAttr);
    return g;
}
Also used : Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Example 5 with Blaze

use of au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze 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

Blaze (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)12 Test (org.testng.annotations.Test)4 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)3 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)2 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)2 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)2 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)2 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)2 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)2 BitSet (java.util.BitSet)2 Rectangle (javafx.scene.shape.Rectangle)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)1 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)1 BooleanAttributeDescription (au.gov.asd.tac.constellation.graph.attribute.BooleanAttributeDescription)1 FloatAttributeDescription (au.gov.asd.tac.constellation.graph.attribute.FloatAttributeDescription)1 StringAttributeDescription (au.gov.asd.tac.constellation.graph.attribute.StringAttributeDescription)1 InteractiveGraphPluginRegistry (au.gov.asd.tac.constellation.graph.interaction.InteractiveGraphPluginRegistry)1 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)1