Search in sources :

Example 61 with ConstellationColor

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;
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Matcher(java.util.regex.Matcher)

Example 62 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream) GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LabelUtilities(au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities) IOException(java.io.IOException) ArrayList(java.util.ArrayList) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) NodeGlyphStreamContext(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStreamContext) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) Collections(java.util.Collections)

Example 63 with ConstellationColor

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);
    };
}
Also used : Arrays(java.util.Arrays) GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) IOException(java.io.IOException) GL2ES3(com.jogamp.opengl.GL2ES3) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) GLTools(au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools) FloatBuffer(java.nio.FloatBuffer)

Example 64 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Test(org.testng.annotations.Test)

Example 65 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

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