Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

In this page you can find the example usage for java.awt Color getBlue.

Prototype

public int getBlue() 

Source Link

Document

Returns the blue component in the range 0-255 in the default sRGB space.

Usage

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Returns {@link #RED}, {@link #RED} or {@link #RED} to indicate the
 * range of the color.//w ww . j av  a2s. co  m
 * 
 * @param color The color to handle.
 * @return See above
 */
public static int getColorRange(Color color) {
    if (color == null)
        return -1;
    int r = color.getRed();
    int g = color.getGreen();
    int b = color.getBlue();
    if (g < r / 2 && b < r / 2)
        return RED_COLOR;
    if (r < g / 2 && b < g / 2)
        return GREEN_COLOR;
    return BLUE_COLOR;
}

From source file:net.ontopia.topicmaps.viz.VizTopicMapConfigurationManager.java

/**
 * Sets the color for this association or topic type in the topic map.
 *///from   w  ww . ja va 2 s  .c  o  m
private void setColor(TopicIF type, TopicIF occtype, Color c) {
    setOccurenceValue(type, occtype, c.getRed() + " " + c.getGreen() + " " + c.getBlue());
}

From source file:org.apache.fop.render.pcl.PCLGenerator.java

/**
 * Generates a user-defined pattern for a dithering pattern matching the grayscale value
 * of the color given.// www .j a  v a 2s. co  m
 * @param col the color to create the pattern for
 * @param patternID the pattern ID to use
 * @param ditherMatrixSize the size of the Bayer dither matrix to use (4 or 8 supported)
 * @throws IOException In case of an I/O error
 */
public void defineGrayscalePattern(Color col, int patternID, int ditherMatrixSize) throws IOException {
    ByteArrayOutputStream baout = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(baout);
    data.writeByte(0); //Format
    data.writeByte(0); //Continuation
    data.writeByte(1); //Pixel Encoding
    data.writeByte(0); //Reserved
    data.writeShort(8); //Width in Pixels
    data.writeShort(8); //Height in Pixels
    //data.writeShort(600); //X Resolution (didn't manage to get that to work)
    //data.writeShort(600); //Y Resolution
    int gray255 = convertToGray(col.getRed(), col.getGreen(), col.getBlue());

    byte[] pattern;
    if (ditherMatrixSize == 8) {
        pattern = DitherUtil.getBayerDither(DitherUtil.DITHER_MATRIX_8X8, gray255, false);
    } else {
        //Since a 4x4 pattern did not work, the 4x4 pattern is applied 4 times to an
        //8x8 pattern. Maybe this could be changed to use an 8x8 bayer dither pattern
        //instead of the 4x4 one.
        pattern = DitherUtil.getBayerDither(DitherUtil.DITHER_MATRIX_4X4, gray255, true);
    }
    data.write(pattern);
    if ((baout.size() % 2) > 0) {
        baout.write(0);
    }
    writeCommand("*c" + patternID + "G");
    writeCommand("*c" + baout.size() + "W");
    baout.writeTo(this.out);
    writeCommand("*c4Q"); //temporary pattern
}

From source file:mio_de_pso.MainForm.java

private LookupPaintScale createLookupPaintScale(double[] values) {
    double minVal = values[0];
    double maxVal = values[0];
    for (int i = 0; i < values.length; ++i) {
        if (values[i] < minVal)
            minVal = values[i];/*from w  w w . j  a v  a2  s  .c om*/
        if (values[i] > maxVal)
            maxVal = values[i];
    }

    LookupPaintScale ps = new LookupPaintScale(minVal, maxVal + 0.0000001, Color.WHITE);

    Color startColor = Color.BLACK;
    Color secondColor = Color.BLUE;
    Color thirdColor = Color.GREEN;
    Color fourthColor = Color.YELLOW;
    Color endColor = Color.RED;

    int iterations = 80;
    int iterationPerColor = iterations / 4;
    double res = Math.round(((maxVal - minVal) / iterations) * 100.0) / 100.0;
    minVal -= res;

    for (int i = 0; i < iterationPerColor; ++i) {
        ps.add(minVal += res, new Color(
                startColor.getRed() + (((secondColor.getRed() - startColor.getRed()) * i) / iterationPerColor),
                startColor.getGreen()
                        + (((secondColor.getGreen()) - startColor.getGreen()) * i) / iterationPerColor,
                startColor.getBlue()
                        + (((secondColor.getBlue() - startColor.getBlue()) * i) / iterationPerColor)));
    }
    for (int i = 0; i < iterationPerColor; ++i) {
        ps.add(minVal += res, new Color(
                secondColor.getRed() + (((thirdColor.getRed() - secondColor.getRed()) * i) / iterationPerColor),
                secondColor.getGreen()
                        + (((thirdColor.getGreen()) - secondColor.getGreen()) * i) / iterationPerColor,
                secondColor.getBlue()
                        + (((thirdColor.getBlue() - secondColor.getBlue()) * i) / iterationPerColor)));
    }
    for (int i = 0; i < iterationPerColor; ++i) {
        ps.add(minVal += res, new Color(
                thirdColor.getRed() + (((fourthColor.getRed() - thirdColor.getRed()) * i) / iterationPerColor),
                thirdColor.getGreen()
                        + (((fourthColor.getGreen()) - thirdColor.getGreen()) * i) / iterationPerColor,
                thirdColor.getBlue()
                        + (((fourthColor.getBlue() - thirdColor.getBlue()) * i) / iterationPerColor)));
    }
    for (int i = 0; i < iterationPerColor; ++i) {
        ps.add(minVal += res, new Color(
                fourthColor.getRed() + (((endColor.getRed() - fourthColor.getRed()) * i) / iterationPerColor),
                fourthColor.getGreen()
                        + (((endColor.getGreen()) - fourthColor.getGreen()) * i) / iterationPerColor,
                fourthColor.getBlue()
                        + (((endColor.getBlue() - fourthColor.getBlue()) * i) / iterationPerColor)));
    }
    return ps;
}

From source file:monitor.processing.OLD.SoccerField.java

public void drawTree(BaseNode n, RealVector v) {

    Color c = Color.WHITE;

    if (n instanceof TransformNode) {
        v = ((TransformNode) n).getTrasformMatrix().operate(v);

        c = Color.ORANGE;/*from   www .j  av  a  2  s . c  o m*/
    } else if (n instanceof StaticMesh) {
        StaticMesh sm = (StaticMesh) n;

        if (sm.isTransparent()) {
            c = Color.BLUE;
        } else if (sm.isVisible()) {
            //                System.out.println(n.getInfo());
            //                System.out.println(v);
            c = Color.RED;
            if (sm.getModel().contains("naohead") || sm.getModel().contains("naobody")) {
                c = Color.PINK;
            }
        } else {
            c = Color.CYAN;
        }

    } else if (n instanceof StaticMeshNode) {
        StaticMeshNode smn = (StaticMeshNode) n;

        if (smn.isTransparent()) {
            c = Color.GREEN;
            //                cameraSceneX = (float)v.getEntry(0);
            //                cameraSceneY = (float)v.getEntry(1);
            //                cameraSceneZ = (float)v.getEntry(2);
        } else if (smn.isVisible()) {
            c = Color.YELLOW;
        } else {
            c = Color.MAGENTA;
        }

    }

    pushMatrix();
    fill(100);

    //        c = Color.getHSBColor(n.getAddress()*0.05f, 1, 1);
    stroke(c.getRed(), c.getGreen(), c.getBlue());
    translate((float) (scale * v.getEntry(0)), (float) (-scale * v.getEntry(1)),
            (float) (scale * v.getEntry(2)));
    box(5);
    popMatrix();

    for (int a = n.getChildren().size() - 1; a >= 0; a--) {
        drawTree(((ArrayList<BaseNode>) n.getChildren()).get(a), v);
    }

}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Converts the passed color.//from  w ww.  jav a2 s. c o  m
 * 
 * @param c The color to handle.
 * @return See above.
 */
public static int convertColor(Color c) {
    int alpha = c.getAlpha();
    if (alpha == 0)
        alpha = 255;
    return ((alpha & 0xFF) << 24) | ((c.getRed() & 0xFF) << 16) | ((c.getGreen() & 0xFF) << 8)
            | ((c.getBlue() & 0xFF) << 0);
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java

/**
 * Adds a defined set of custom properties to the GLXNode.
 * These properties will be exported to the Visio shapes as custom properties.
 * //from   ww  w .j  a  v  a 2 s.  com
 * @param isRelease An InformationSystemRelease containing the attributes to add to the GLXNode.
 * @param node The corresponding graph node for the isRelease.
 * @param isName The formated name of the isRelease.
 */
private void addShapePropertiesToInsNode(InformationSystemRelease isRelease, GXLNode node, String isName) {

    setTextPropertyToNode(node, PROP_ID, isRelease.getId().toString());
    setTextPropertyToNode(node, PROP_APP_NAME_FULL, isName);
    setTextPropertyToNode(node, PROP_APP_INFORMATION_OBJECTS_FULL,
            GeneralHelper.makeConcatenatedNameStringForBbCollection(isRelease.getBusinessObjects()));
    String urlToEntity = this.retrieveXLinkUrlForIdentityEntity(isRelease,
            this.informationFlowOptions.getServerUrl());
    setTextPropertyToNode(node, PROP_XREF_URL, urlToEntity);

    // create a string containing all INS Domains, separated by a semicolon
    StringBuilder isdAttribute = new StringBuilder();
    // check if the user has the permission to read the INS Domains:
    if (UserContext.getCurrentPerms()
            .userHasFunctionalPermission(TypeOfFunctionalPermission.INFORMATIONSYSTEMDOMAIN)) {
        for (InformationSystemDomain isd : isRelease.getInformationSystemDomains()) {
            isdAttribute.append(isd.getName() + "(" + isd.getId() + ");");
        }
    }
    setTextPropertyToNode(node, PROP_APP_INS_DOMAIN, isdAttribute.toString());

    // create a string containing all assigned attributes, separated by a semicolon
    StringBuilder attributesString = new StringBuilder();
    Set<AttributeValueAssignment> avas = isRelease.getAttributeValueAssignments();
    for (AttributeValueAssignment ava : avas) {
        AttributeValue av = ava.getAttributeValue();
        AttributeType at = av.getAbstractAttributeType();
        AttributeTypeGroup atg = at.getAttributeTypeGroup();
        // check if the user has the permission to read the attributeGroup:
        if (UserContext.getCurrentPerms().userHasAttrTypeGroupPermission(atg,
                AttributeTypeGroupPermissionEnum.READ)) {
            attributesString.append("(" + at.getName() + ")=" + av.getLocalizedValueString(getLocale()) + ";");
        }
    }
    setTextPropertyToNode(node, PROP_ATTRIBUTES, attributesString.toString());

    setTextPropertyToNode(node, PROP_APP_VERSION, isRelease.getVersion());
    setTextPropertyToNode(node, PROP_STATUS, mapTypeOfStatusVisioExport(isRelease.getTypeOfStatus()));
    setTextPropertyToNode(node, PROP_DESCRIPTION, isRelease.getDescription());
    setTextPropertyToNode(node, PROP_START_DATE,
            DateUtils.formatAsStringToDefault(isRelease.runtimeStartsAt(), getLocale()));
    setTextPropertyToNode(node, PROP_END_DATE,
            DateUtils.formatAsStringToDefault(isRelease.runtimeEndsAt(), getLocale()));

    Color color = getColorDimension().getValue(isRelease);
    LOGGER.debug("Color for node: {0}", color);

    setTextPropertyToNode(node, PROP_COLOR_RED, String.valueOf(color.getRed()));
    setTextPropertyToNode(node, PROP_COLOR_GREEN, String.valueOf(color.getGreen()));
    setTextPropertyToNode(node, PROP_COLOR_BLUE, String.valueOf(color.getBlue()));
}

From source file:com.jcraft.weirdx.XColormap.java

@SuppressWarnings("unused")
static void reqLookupColor(Client c) throws IOException {
    int foo, n;/*from  w w  w . j ava2 s.c  om*/
    InputOutput io = c.client;

    n = c.length;
    foo = io.readInt();
    XColormap cmap = (XColormap) XResource.lookupIDByType(foo, XResource.RT_COLORMAP);
    c.length -= 2;
    if (cmap == null) {
        c.errorValue = foo;
        c.errorReason = 12; // Colormap
        return;
    }

    foo = io.readShort();
    io.readPad(2);
    io.readByte(c.bbuffer, 0, foo);
    io.readPad((-foo) & 3);
    c.length = 0;
    foo = chopspace(c.bbuffer, foo);
    if (foo == 0) {
        c.errorReason = 2; // BadValue
        return;
    }
    String s = new String(c.bbuffer, 0, foo);
    Color color = (Color) rgbTable.get(s);
    if (color != null) {
        synchronized (io) {
            io.writeByte(1);
            io.writePad(1);
            io.writeShort(c.seq);
            io.writeInt(0);

            foo = color.getRed();
            io.writeShort(foo | (foo << 8));
            foo = color.getGreen();
            io.writeShort(foo | (foo << 8));
            foo = color.getBlue();
            io.writeShort(foo | (foo << 8));
            foo = color.getRed();
            io.writeShort(foo | (foo << 8));
            foo = color.getGreen();
            io.writeShort(foo | (foo << 8));
            foo = color.getBlue();
            io.writeShort(foo | (foo << 8));
            io.writePad(12);
            io.flush();
            return;
        }
    }

    synchronized (io) {
        io.writeByte((byte) 0);
        io.writeByte((byte) 15);
        io.writeShort(c.seq);
        io.writePad(4);
        io.writeShort(0);
        io.writeByte((byte) 92);
        io.writePad(21);
        io.flush();
    }
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Returns <code>true</code> if the passed colors are the same, 
 * <code>false</code> otherwise.
 * //from   w  ww.j  a  va2  s .  com
 * @param c1 One of the colors to check.
 * @param c2 One of the colors to check.
 * @param alpha Pass <code>true</code> to take into account the 
 *             alpha component, <code>false</code> otherwise.
 * @return See above.
 */
public static boolean isSameColors(Color c1, Color c2, boolean alpha) {
    if (c1 == null || c2 == null)
        return false;
    if (c1.getRed() != c2.getRed())
        return false;
    if (c1.getGreen() != c2.getGreen())
        return false;
    if (c1.getBlue() != c2.getBlue())
        return false;
    if (alpha) {
        if (c1.getAlpha() != c2.getAlpha())
            return false;
    }
    return true;
}

From source file:com.hygenics.imaging.ImageCleanup.java

/**
 * Private method that performs the sharpen
 *///w ww  . j a v a2 s . co m
public byte[] sharpen(byte[] ibytes, int weight, String format) {
    /*
     * Kernel is |-1|-1|-1| |-1|weight|-1||-1|-1|-1|
     */
    try {
        InputStream is = new ByteArrayInputStream(ibytes);
        BufferedImage proxyimage = ImageIO.read(is);
        // a secondary image for storing new outcomes
        BufferedImage image2 = new BufferedImage(proxyimage.getWidth(), proxyimage.getHeight(),
                BufferedImage.TYPE_BYTE_GRAY);

        // image width and height
        int width = proxyimage.getWidth();
        int height = proxyimage.getHeight();
        int r = 0;
        int g = 0;
        int b = 0;
        Color c = null;
        for (int x = 1; x < width - 1; x++) {
            for (int y = 1; y < height - 1; y++) {
                // sharpen the image using the kernel (center is c5)
                Color c00 = new Color(proxyimage.getRGB(x - 1, y - 1));
                Color c01 = new Color(proxyimage.getRGB(x - 1, y));
                Color c02 = new Color(proxyimage.getRGB(x - 1, y + 1));
                Color c10 = new Color(proxyimage.getRGB(x, y - 1));
                Color c11 = new Color(proxyimage.getRGB(x, y));
                Color c12 = new Color(proxyimage.getRGB(x, y + 1));
                Color c20 = new Color(proxyimage.getRGB(x + 1, y - 1));
                Color c21 = new Color(proxyimage.getRGB(x + 1, y));
                Color c22 = new Color(proxyimage.getRGB(x + 1, y + 1));

                // apply the kernel for r
                r = -c00.getRed() - c01.getRed() - c02.getRed() - c10.getRed() + (weight * c11.getRed())
                        - c12.getRed() - c20.getRed() - c21.getRed() - c22.getRed();

                // apply the kernel for g
                g = c00.getGreen() - c01.getGreen() - c02.getGreen() - c10.getGreen()
                        + (weight * c11.getGreen()) - c12.getGreen() - c20.getGreen() - c21.getGreen()
                        - c22.getGreen();

                // apply the transformation for b
                b = c00.getBlue() - c01.getBlue() - c02.getBlue() - c10.getBlue() + (weight * c11.getBlue())
                        - c12.getBlue() - c20.getBlue() - c21.getBlue() - c22.getBlue();

                // set the new rgb values
                r = Math.min(255, Math.max(0, r));
                g = Math.min(255, Math.max(0, g));
                b = Math.min(255, Math.max(0, b));

                c = new Color(r, g, b);

                // set the new mask colors in the new image
                image2.setRGB(x, y, c.getRGB());

            }
        }

        // add the new values back to the original image
        Color cmask = null;
        Color corig = null;
        for (int x = 1; x < width - 1; x++) {
            for (int y = 1; y < height - 1; y++) {
                // get the 2 colors
                cmask = new Color(image2.getRGB(x, y));
                corig = new Color(proxyimage.getRGB(x, y));

                // add the new values
                r = cmask.getRed() + corig.getRed();
                g = cmask.getGreen() + corig.getGreen();
                b = cmask.getBlue() + corig.getBlue();

                // set the new rgb values
                r = Math.min(255, Math.max(0, r));
                g = Math.min(255, Math.max(0, g));
                b = Math.min(255, Math.max(0, b));

                proxyimage.setRGB(x, y, new Color(r, g, b).getRGB());
            }
        }

        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
            ImageIO.write(proxyimage, format, baos);
            ibytes = baos.toByteArray();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return ibytes;
}