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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations