Search in sources :

Example 41 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class BlazeUtilitiesNGTest method testGetSelectionNoBlazes.

/**
 * Test of getSelection method, of class BlazeUtilities. No blazes on the graph
 */
@Test
public void testGetSelectionNoBlazes() {
    System.out.println("getSelectionNoBlazes");
    graph.setObjectValue(vertexBlazeAttribute, vxId3, null);
    graph.setObjectValue(vertexBlazeAttribute, vxId4, null);
    final Graph g = new DualGraph(schema, graph);
    final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, null);
    final BitSet resultBitSet = result.getKey();
    final ConstellationColor resultColour = result.getValue();
    assertEquals(resultBitSet.cardinality(), 3);
    assertTrue(resultBitSet.get(vxId1));
    assertFalse(resultBitSet.get(vxId2));
    assertTrue(resultBitSet.get(vxId3));
    assertTrue(resultBitSet.get(vxId4));
    assertEquals(resultColour, ConstellationColor.LIGHT_BLUE);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 42 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class BlazeUtilitiesNGTest method testGetSelection.

/**
 * Test of getSelection method, of class BlazeUtilities. Blazes on the graph
 */
@Test
public void testGetSelection() {
    System.out.println("getSelection");
    final Graph g = new DualGraph(schema, graph);
    final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, null);
    final BitSet resultBitSet = result.getKey();
    final ConstellationColor resultColour = result.getValue();
    assertEquals(resultBitSet.cardinality(), 3);
    assertTrue(resultBitSet.get(vxId1));
    assertFalse(resultBitSet.get(vxId2));
    assertTrue(resultBitSet.get(vxId3));
    assertTrue(resultBitSet.get(vxId4));
    assertEquals(resultColour, ConstellationColor.BLUE);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 43 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class BlazeUtilitiesNGTest method testGetSelectionColourInput.

/**
 * Test of getSelection method, of class BlazeUtilities. Colour input added
 */
@Test
public void testGetSelectionColourInput() {
    System.out.println("getSelectionColourInput");
    final Graph g = new DualGraph(schema, graph);
    final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, ConstellationColor.BANANA);
    final BitSet resultBitSet = result.getKey();
    final ConstellationColor resultColour = result.getValue();
    assertEquals(resultBitSet.cardinality(), 3);
    assertTrue(resultBitSet.get(vxId1));
    assertFalse(resultBitSet.get(vxId2));
    assertTrue(resultBitSet.get(vxId3));
    assertTrue(resultBitSet.get(vxId4));
    assertEquals(resultColour, ConstellationColor.BANANA);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 44 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class ClusterUtilities method colorClusters.

/**
 * Set the color of the vertices and transactions in clusters such that each
 * cluster has a unique color.
 * <p>
 * A cluster is identified by the integer clusterId attribute; all vertices
 * will the same cluster value are in the same cluster.
 * <p>
 * The graph meta-color attributes are changed to refer to this (vertex +
 * transaction) attribute.
 *
 * @param wg The graph to modify.
 * @param clusterId The cluster attribute to work with
 * @param vxColorId The cluster vertex color attribute id.
 * @param txColorId The cluster transaction color attribute id.
 */
public static void colorClusters(final GraphWriteMethods wg, final int clusterId, final int vxColorId, final int txColorId) {
    final int vxCount = wg.getVertexCount();
    // How many clusters are there?
    final Map<Integer, Integer> clusterMap = new HashMap<>();
    for (int position = 0; position < vxCount; position++) {
        final int vxId = wg.getVertex(position);
        final int cluster = wg.getIntValue(clusterId, vxId);
        if (!clusterMap.containsKey(cluster)) {
            clusterMap.put(cluster, clusterMap.size());
        }
    }
    final int nClusters = clusterMap.size();
    final ConstellationColor[] palette = ConstellationColor.createPalettePhi(nClusters, 0, 0.5F, 0.95F);
    for (int position = 0; position < vxCount; position++) {
        final int vxId = wg.getVertex(position);
        final int cluster = wg.getIntValue(clusterId, vxId);
        wg.setObjectValue(vxColorId, vxId, palette[clusterMap.get(cluster)]);
    }
    final int txVisibilityId = VisualConcept.TransactionAttribute.VISIBILITY.ensure(wg);
    final int txCount = wg.getTransactionCount();
    for (int position = 0; position < txCount; position++) {
        final int txId = wg.getTransaction(position);
        final int vxSrcId = wg.getTransactionSourceVertex(txId);
        final int vxDstId = wg.getTransactionDestinationVertex(txId);
        final int srcCluster = wg.getIntValue(clusterId, vxSrcId);
        final int dstCluster = wg.getIntValue(clusterId, vxDstId);
        final boolean isSameCluster = srcCluster == dstCluster;
        final ConstellationColor cv;
        final float visibility;
        if (isSameCluster) {
            cv = palette[clusterMap.get(srcCluster)];
            visibility = 1;
        } else {
            cv = ConstellationColor.DARK_GREY;
            visibility = 0;
        }
        wg.setObjectValue(txColorId, txId, cv);
        wg.setFloatValue(txVisibilityId, txId, visibility);
    }
    setColorRef(wg, wg.getAttributeName(vxColorId), wg.getAttributeName(txColorId));
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) HashMap(java.util.HashMap)

Example 45 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class CreateTransactionTypePlugin method edit.

@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final String name = parameters.getStringValue(NAME_PARAMETER_ID);
    if (name == null) {
        throw new IllegalArgumentException("A name must be supplied");
    }
    final String description = parameters.getStringValue(DESCRIPTION_PARAMETER_ID);
    if (description == null) {
        throw new IllegalArgumentException("A description must be supplied");
    }
    final ConstellationColor color = parameters.getColorValue(COLOR_PARAMETER_ID);
    final String lsName = parameters.getStringValue(LINE_STYLE_PARAMETER_ID);
    final LineStyle lineStyle = LineStyle.valueOf(lsName);
    final boolean directed = parameters.getBooleanValue(DIRECTED_PARAMETER_ID);
    final String stype = parameters.getStringValue(SUPER_TYPE_PARAMETER_ID);
    final SchemaTransactionType superType = stype != null ? SchemaTransactionTypeUtilities.getType(stype) : null;
    final String otype = parameters.getStringValue(OVERRIDDEN_TYPE_PARAMETER_ID);
    final SchemaTransactionType overridenType = otype != null ? SchemaTransactionTypeUtilities.getType(otype) : null;
    final boolean incomplete = parameters.getBooleanValue(INCOMPLETE_PARAMETER_ID);
    final Map<String, String> properties = null;
    final SchemaTransactionType stt = new SchemaTransactionType(name, description, color, lineStyle, directed, superType, overridenType, properties, incomplete);
    SchemaTransactionTypeUtilities.addCustomType(stt, true);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) LineStyle(au.gov.asd.tac.constellation.utilities.visual.LineStyle)

Aggregations

ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)67 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)11 Color (java.awt.Color)9 BitSet (java.util.BitSet)9 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 IOException (java.io.IOException)7 Graph (au.gov.asd.tac.constellation.graph.Graph)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 List (java.util.List)6 File (java.io.File)5 HashMap (java.util.HashMap)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)4 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)4 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)4 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)4 VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)4 GLRenderableUpdateTask (au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask)4 TextureUnits (au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits)4