Search in sources :

Example 26 with StoreGraph

use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.

the class BoundingBox2DNGTest method generateGraph.

@BeforeClass
public static void generateGraph() {
    baseGraph = new StoreGraph();
    int attrX = VisualConcept.VertexAttribute.X.ensure(baseGraph);
    if (attrX == Graph.NOT_FOUND) {
        fail();
    }
    int attrY = VisualConcept.VertexAttribute.Y.ensure(baseGraph);
    if (attrY == Graph.NOT_FOUND) {
        fail();
    }
    // Top left
    int vxId1 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId1, -1.0f);
    baseGraph.setFloatValue(attrY, vxId1, 1.0f);
    // Top right
    int vxId2 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId2, 1.0f);
    baseGraph.setFloatValue(attrY, vxId2, 1.0f);
    // Bottom right
    int vxId3 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId3, 1.0f);
    baseGraph.setFloatValue(attrY, vxId3, -1.0f);
    // Bottom left
    int vxId4 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId4, -1.0f);
    baseGraph.setFloatValue(attrY, vxId4, -1.0f);
}
Also used : StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeClass(org.testng.annotations.BeforeClass)

Example 27 with StoreGraph

use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.

the class BoundingBox2DTest method generateGraph.

@BeforeClass
public static void generateGraph() {
    baseGraph = new StoreGraph();
    int attrX = VisualConcept.VertexAttribute.X.ensure(baseGraph);
    if (attrX == Graph.NOT_FOUND) {
        fail();
    }
    int attrY = VisualConcept.VertexAttribute.Y.ensure(baseGraph);
    if (attrY == Graph.NOT_FOUND) {
        fail();
    }
    // Top left
    int vxId1 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId1, -1.0f);
    baseGraph.setFloatValue(attrY, vxId1, 1.0f);
    // Top right
    int vxId2 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId2, 1.0f);
    baseGraph.setFloatValue(attrY, vxId2, 1.0f);
    // Bottom right
    int vxId3 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId3, 1.0f);
    baseGraph.setFloatValue(attrY, vxId3, -1.0f);
    // Bottom left
    int vxId4 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId4, -1.0f);
    baseGraph.setFloatValue(attrY, vxId4, -1.0f);
}
Also used : StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with StoreGraph

use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.

the class BoundingBox2DTest method testConstructorThrowsException.

/**
 * Test the constructor throws an exception when given an empty graph.
 */
@Test(expectedExceptions = IllegalArgumentException.class)
public void testConstructorThrowsException() {
    StoreGraph emptyGraph = new StoreGraph();
    VisualConcept.VertexAttribute.X.ensure(emptyGraph);
    VisualConcept.VertexAttribute.Y.ensure(emptyGraph);
    // This should fail as the graph has no verticies.
    new BoundingBox2D(emptyGraph);
}
Also used : StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 29 with StoreGraph

use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.

the class BoundingBox3DNGTest method generateGraph.

@BeforeClass
public static void generateGraph() {
    baseGraph = new StoreGraph();
    int attrX = VisualConcept.VertexAttribute.X.ensure(baseGraph);
    if (attrX == Graph.NOT_FOUND) {
        fail();
    }
    int attrY = VisualConcept.VertexAttribute.Y.ensure(baseGraph);
    if (attrY == Graph.NOT_FOUND) {
        fail();
    }
    int attrZ = VisualConcept.VertexAttribute.Z.ensure(baseGraph);
    if (attrZ == Graph.NOT_FOUND) {
        fail();
    }
    // Top left front
    int vxId1 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId1, -1.0f);
    baseGraph.setFloatValue(attrY, vxId1, 1.0f);
    baseGraph.setFloatValue(attrZ, vxId1, 1.0f);
    // Top right front
    int vxId2 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId2, 1.0f);
    baseGraph.setFloatValue(attrY, vxId2, 1.0f);
    baseGraph.setFloatValue(attrZ, vxId2, 1.0f);
    // Bottom right front
    int vxId3 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId3, 1.0f);
    baseGraph.setFloatValue(attrY, vxId3, -1.0f);
    baseGraph.setFloatValue(attrZ, vxId3, 1.0f);
    // Bottom left front
    int vxId4 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId4, -1.0f);
    baseGraph.setFloatValue(attrY, vxId4, -1.0f);
    baseGraph.setFloatValue(attrZ, vxId4, 1.0f);
    // Top left back
    int vxId5 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId5, -1.0f);
    baseGraph.setFloatValue(attrY, vxId5, 1.0f);
    baseGraph.setFloatValue(attrZ, vxId5, -1.0f);
    // Top right back
    int vxId6 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId6, 1.0f);
    baseGraph.setFloatValue(attrY, vxId6, 1.0f);
    baseGraph.setFloatValue(attrZ, vxId6, -1.0f);
    // Bottom right back
    int vxId7 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId7, 1.0f);
    baseGraph.setFloatValue(attrY, vxId7, -1.0f);
    baseGraph.setFloatValue(attrZ, vxId7, -1.0f);
    // Bottom left back
    int vxId8 = baseGraph.addVertex();
    baseGraph.setFloatValue(attrX, vxId8, -1.0f);
    baseGraph.setFloatValue(attrY, vxId8, -1.0f);
    baseGraph.setFloatValue(attrZ, vxId8, -1.0f);
}
Also used : StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeClass(org.testng.annotations.BeforeClass)

Example 30 with StoreGraph

use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.

the class MergeNodesByPrefixNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    // Create graph.
    schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    // Add attributes.
    vertexIdentifierAttribute = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // Add vertices.
    vxId1 = graph.addVertex();
    vxId2 = graph.addVertex();
    vxId3 = graph.addVertex();
    vxId4 = graph.addVertex();
    vxId5 = graph.addVertex();
    // Set vertice identifiers.
    graph.setStringValue(vertexIdentifierAttribute, vxId1, "pre v1");
    graph.setStringValue(vertexIdentifierAttribute, vxId2, "pre v2");
    graph.setStringValue(vertexIdentifierAttribute, vxId3, "prefix v3");
    graph.setStringValue(vertexIdentifierAttribute, vxId4, "fix v4");
    graph.setStringValue(vertexIdentifierAttribute, vxId5, "fix v5");
    // Set vertice selection.
    graph.setBooleanValue(vertexSelectedAttribute, vxId1, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId2, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId3, false);
    graph.setBooleanValue(vertexSelectedAttribute, vxId4, false);
    graph.setBooleanValue(vertexSelectedAttribute, vxId5, false);
}
Also used : StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)170 Test (org.testng.annotations.Test)75 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)64 BeforeMethod (org.testng.annotations.BeforeMethod)61 ArrayList (java.util.ArrayList)19 Graph (au.gov.asd.tac.constellation.graph.Graph)17 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)17 HashMap (java.util.HashMap)14 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)13 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)11 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)11 HashSet (java.util.HashSet)11 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)10 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)10 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)9 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)8 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)8 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)7 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)7 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)7