use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class Blaze method valueOf.
/**
* Attempt to create a Blaze from data parsed out of supplied string.
* @param s String to parse to extract Blaze object.
* The string can take several formats:
* "{angle};{color}"
* "{angle};{RGBValueCode}"
* "{angle};{RGBValueArray}"
* "{angle};[{RGBValueArray}]"
* "{angle};{HTMLColorCode}"
* Where:
* "{angle}" is an integer angle
* "{color}" is a named color from ConstellationColor static colors
* "{RGBValueCode}" is a string of the format "RGBrrrgggbbb" for which
* "RGB" is fixed and rrr, ggg, bbb are 3 digit values for color values,
* ie: "RGB255000000" equates to red
* "{RGBValueArray}" is a comma separated list of 3 color components in
* the range 0.0 to 1.0 for red, green, blue components.
* "{HTMLColorCode}" is a HTML representation of color of the form
* "#FF0000" for red.
* @return Blaze generated from supplied string, if parsing is possible.
* null is returned if string is null or 0 length.
* @throws IllegalBlazeFormatException if Blaze cannot be constructed from
* supplied string.
*/
public static Blaze valueOf(final String s) {
if (s != null) {
final Matcher m = BLAZE_PATTERN.matcher(s);
if (m.matches()) {
final int angle = Integer.valueOf(m.group(1));
final ConstellationColor color = ConstellationColor.getColorValue(m.group(2));
if (color == null) {
throw new IllegalBlazeFormatException("Undefined colour for blaze.");
}
return new Blaze(angle, color);
}
}
return null;
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class NodeLabelBatcher method setTopLabelColors.
public GLRenderableUpdateTask setTopLabelColors(final VisualAccess access) {
final int numTopLabels = Math.min(LabelUtilities.MAX_LABELS_TO_DRAW, access.getTopLabelCount());
for (int i = 0; i < numTopLabels; i++) {
final ConstellationColor labelColor = access.getTopLabelColor(i);
labelTopInfoReference.setRow(labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue(), labelTopInfoReference.get(i, 3), i);
}
return gl -> labelTopInfo.set(labelTopInfoReference);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class FpsBatcher method updateColors.
public GLRenderableUpdateTask updateColors(final ConstellationColor color) {
final ColorOperation operation = this::bufferColorInfo;
final FloatBufferConnection connector = gl -> batch.connectFloatBuffer(gl, colorTarget);
final BufferDisconnection disconnector = gl -> batch.disconnectBuffer(gl, colorTarget);
final int width = COLOR_BUFFER_WIDTH;
final boolean[] updateMask = new boolean[width];
Arrays.fill(updateMask, true);
final int maskSize = updateMask.length;
final int numChanges = 2;
final FloatBuffer updateBuffer = Buffers.newDirectFloatBuffer(maskSize * numChanges);
final int[] bufferUpdatePositions = new int[numChanges];
int updatePos = 0;
for (int i = 0; i < numChanges; i++) {
final int updatedPosition = operation.buffer(i, updateBuffer, color);
if (updatedPosition >= 0) {
bufferUpdatePositions[updatePos++] = updatedPosition;
}
}
final int numUpdates = updatePos;
updateBuffer.flip();
return gl -> {
final FloatBuffer buffer = connector.connect(gl);
for (int i = 0; i < numUpdates; i++) {
buffer.position(bufferUpdatePositions[i] * maskSize);
for (boolean update : updateMask) {
if (update) {
buffer.put(updateBuffer.get());
} else {
buffer.get();
}
}
}
disconnector.disconnect(gl);
};
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class GraphVisualAccessNGTest method testGetVertexColorAttributesNotFound.
/**
* Test of getVertexColor method when attributes are not found, of class
* GraphVisualAccess.
*
* @throws InterruptedException
*/
@Test
public void testGetVertexColorAttributesNotFound() throws InterruptedException {
System.out.println("getVertexColorAttributeNotFound");
final GraphVisualAccess instance = new GraphVisualAccess(graph);
instance.beginUpdate();
final ConstellationColor colour1 = instance.getVertexColor(0);
final ConstellationColor colour2 = instance.getVertexColor(1);
instance.endUpdate();
assertEquals(colour1, VisualGraphDefaults.DEFAULT_VERTEX_COLOR);
assertEquals(colour2, VisualGraphDefaults.DEFAULT_VERTEX_COLOR);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class GraphVisualAccessNGTest method testGetGraphAttributesOneLineFunctionsAttributesAdded.
/**
* Test of the following methods when attributes are added, of class
* GraphVisualAccess: getBackgroundColor, getHighlightColor, getBlazeSize,
* getBlazeOpacity, getConnectionOpacity
*
* @throws InterruptedException
*/
@Test
public void testGetGraphAttributesOneLineFunctionsAttributesAdded() throws InterruptedException {
System.out.println("getGraphAttributesOneLineFunctionsAttributesAdded");
final WritableGraph wg = graph.getWritableGraph("Graph Visual Access", true);
try {
final int graphBackgroundColourAttribute = VisualConcept.GraphAttribute.BACKGROUND_COLOR.ensure(wg);
final int graphHighlightColourAttribute = VisualConcept.GraphAttribute.HIGHLIGHT_COLOR.ensure(wg);
final int graphBlazeSizeAttribute = VisualConcept.GraphAttribute.BLAZE_SIZE.ensure(wg);
final int graphBlazeOpacityAttribute = VisualConcept.GraphAttribute.BLAZE_OPACITY.ensure(wg);
final int graphConnectionOpacityAttribute = VisualConcept.GraphAttribute.CONNECTION_OPACITY.ensure(wg);
wg.setObjectValue(graphBackgroundColourAttribute, 0, ConstellationColor.BANANA);
wg.setObjectValue(graphHighlightColourAttribute, 0, ConstellationColor.CARROT);
wg.setFloatValue(graphBlazeSizeAttribute, 0, 0.5f);
wg.setFloatValue(graphBlazeOpacityAttribute, 0, 0.6f);
wg.setFloatValue(graphConnectionOpacityAttribute, 0, 0.7f);
} finally {
wg.commit();
}
final GraphVisualAccess instance = new GraphVisualAccess(graph);
instance.beginUpdate();
instance.updateInternally();
final ConstellationColor backgroundColour = instance.getBackgroundColor();
final ConstellationColor highlightColour = instance.getHighlightColor();
final float blazeSize = instance.getBlazeSize();
final float blazeOpacity = instance.getBlazeOpacity();
final float connectionOpacity = instance.getConnectionOpacity();
instance.endUpdate();
assertEquals(backgroundColour, ConstellationColor.BANANA);
assertEquals(highlightColour, ConstellationColor.CARROT);
assertEquals(blazeSize, 0.5f);
assertEquals(blazeOpacity, 0.6f);
assertEquals(connectionOpacity, 0.7f);
}
Aggregations