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