Example usage for java.awt Color getGreen

List of usage examples for java.awt Color getGreen

Introduction

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

Prototype

public int getGreen() 

Source Link

Document

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

Usage

From source file:fxts.stations.util.UserPreferences.java

public static String getStringValue(Color aValue) {
    return aValue.getRed() + "," + aValue.getGreen() + "," + aValue.getBlue();
}

From source file:org.polymap.rhei.batik.engine.svg.Svg2Png.java

private static float[] getHsb(ImageConfiguration imageConfiguration, Color color) {
    float[] hsb = new float[3];
    if (imageConfiguration.isInvert()) {
        Color.RGBtoHSB(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue(), hsb);
    } else {/*ww w  . j  a v  a2s.  c  o  m*/
        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
    }
    return hsb;
}

From source file:ala.soils2sat.DrawingUtils.java

public static List<Color> generatePalette(int size, Color baseColor) {
    float[] hsb = { 0, 0, 0 };
    Color.RGBtoHSB(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), hsb);
    double baseHue = hsb[0];

    List<Color> colors = new ArrayList<Color>();
    colors.add(baseColor);//from   w w w . j  a  va  2  s. c o m

    double step = (240.0 / (double) size);

    for (int i = 1; i < size; ++i) {
        float hue = (float) ((baseHue + step * ((double) i)) % 240.0); // this gives a number out of 240. need to scale that to percent
        hue = hue / 240;
        Color nextColor = Color.getHSBColor(hue, hsb[1], hsb[2]);
        colors.add(nextColor);
    }
    return colors;
}

From source file:org.polymap.rhei.batik.engine.svg.Svg2Png.java

/**
 * @param imageConfiguration/*  w  ww.  jav  a 2  s . c  o  m*/
 * @param color
 * @param newRGB
 * @return
 */
private static BufferedImage makeColorsTransparent(BufferedImage finalThresholdImage,
        ImageConfiguration imageConfiguration, Color color) {
    boolean found = imageConfiguration.getTransparenceConfigurations().stream().anyMatch(
            tc -> tc.red == color.getRed() && tc.green == color.getGreen() && tc.blue == color.getBlue());
    if (found) {
        finalThresholdImage = makeColorTransparent(finalThresholdImage, color);
    }
    return finalThresholdImage;
}

From source file:org.kalypso.commons.java.util.StringUtilities.java

/**
 * Converts a Color into a String.//  w ww.  j a  va2s.c om
 * <p>
 * String will have same format as specified in {@link StringUtilities#stringToColor(String)}
 * 
 * @param c
 * @throws IllegalArgumentException
 *           if color is null
 */
public static String colorToString(final Color c) {
    if (c == null)
        throw new IllegalArgumentException(
                Messages.getString("org.kalypso.commons.java.util.StringUtilities.1")); //$NON-NLS-1$

    final StringBuffer buf = new StringBuffer();

    buf.append(c.getRed()).append(";").append(c.getGreen()).append(";").append(c.getBlue()); //$NON-NLS-1$ //$NON-NLS-2$

    // alpha component is optional
    if (c.getAlpha() != 255)
        buf.append(";").append(c.getAlpha()); //$NON-NLS-1$

    return buf.toString();
}

From source file:net.groupbuy.util.ImageUtils.java

/**
 * ????//from   ww  w . ja  v a 2s  .co  m
 * 
 * @param color
 *            
 * @return ???
 */
private static String toHexEncoding(Color color) {
    String R, G, B;
    StringBuffer stringBuffer = new StringBuffer();
    R = Integer.toHexString(color.getRed());
    G = Integer.toHexString(color.getGreen());
    B = Integer.toHexString(color.getBlue());
    R = R.length() == 1 ? "0" + R : R;
    G = G.length() == 1 ? "0" + G : G;
    B = B.length() == 1 ? "0" + B : B;
    stringBuffer.append("#");
    stringBuffer.append(R);
    stringBuffer.append(G);
    stringBuffer.append(B);
    return stringBuffer.toString();
}

From source file:org.kalypso.ui.wizards.results.ResultSldHelper.java

/**
 * returns the interpolated color of a color map defined by start and end color.
 * //from w w  w .ja  v  a2 s  . co  m
 * @param currentClass
 *          current class
 * @param numOfClasses
 *          number of all classes in which the colormap is divided.
 */
public static Color interpolateColor(final Color minColor, final Color maxColor, final int currentClass,
        final int numOfClasses) {
    // interpolate color
    final float[] minhsb = Color.RGBtoHSB(minColor.getRed(), minColor.getGreen(), minColor.getBlue(), null);
    final float[] maxhsb = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null);

    final float minHue = minhsb[0];
    final float maxHue = maxhsb[0];

    final float minSat = minhsb[1];
    final float maxSat = maxhsb[1];

    final float minBri = minhsb[2];
    final float maxBri = maxhsb[2];

    final double Hue = minHue + (currentClass * (maxHue - minHue) / (numOfClasses - 1));
    final double Sat = minSat + (currentClass * (maxSat - minSat) / (numOfClasses - 1));
    final double Bri = minBri + (currentClass * (maxBri - minBri) / (numOfClasses - 1));

    final Color hsbColor = Color.getHSBColor((float) Hue, (float) Sat, (float) Bri);
    final Color rgbColor = new Color(hsbColor.getRed(), hsbColor.getGreen(), hsbColor.getBlue());

    return rgbColor;
}

From source file:com.el.ecom.utils.ImageUtils.java

/**
 * ????/*ww w. j  a va2s.c om*/
 * 
 * @param color 
 * @return ???
 */
private static String toHexEncoding(Color color) {
    Assert.notNull(color);

    String R, G, B;
    StringBuilder result = new StringBuilder();
    R = Integer.toHexString(color.getRed());
    G = Integer.toHexString(color.getGreen());
    B = Integer.toHexString(color.getBlue());
    R = R.length() == 1 ? "0" + R : R;
    G = G.length() == 1 ? "0" + G : G;
    B = B.length() == 1 ? "0" + B : B;
    result.append("#").append(R).append(G).append(B);
    return result.toString();
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.xls.helper.StaticExcelColorSupport.java

public static short getNearestColor(final Color awtColor, final Map triplets) {
    if (awtColor == null) {
        throw new NullPointerException();
    }//from  w w  w  .  ja  v a 2s  .  c  om

    if (triplets == null || triplets.isEmpty()) {
        logger.warn("Unable to get triplet hashtable");
        return HSSFColor.BLACK.index;
    }

    short color = HSSFColor.BLACK.index;
    double minDiff = Double.MAX_VALUE;

    // get the color without the alpha chanel
    final float[] hsb = Color.RGBtoHSB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(), null);

    float[] excelHsb = null;
    final Iterator elements = triplets.values().iterator();
    while (elements.hasNext()) {
        final HSSFColor crtColor = (HSSFColor) elements.next();
        final short[] rgb = crtColor.getTriplet();
        excelHsb = Color.RGBtoHSB(rgb[0], rgb[1], rgb[2], excelHsb);

        final double weight = 3.0
                * (Math.min(Math.abs(excelHsb[0] - hsb[0]), Math.abs(excelHsb[0] - hsb[0] + 1)))
                + Math.abs(excelHsb[1] - hsb[1]) + Math.abs(excelHsb[2] - hsb[2]);

        if (weight < minDiff) {
            minDiff = weight;
            if (minDiff == 0) {
                // we found the color ...
                return crtColor.getIndex();
            }
            color = crtColor.getIndex();
        }
    }
    return color;
}

From source file:org.apache.fop.render.rtf.TextAttributesConverter.java

/**
 * Converts a FOP ColorType to the integer pointing into the RTF color table
 * @param fopColor the ColorType object to be converted
 * @return integer pointing into the RTF color table
 *//*  ww  w .  j  ava2 s. c  om*/
public static int convertFOPColorToRTF(Color fopColor) {
    // TODO: This code is duplicated in FOPRtfAttributesConverter
    int redComponent = fopColor.getRed();
    int greenComponent = fopColor.getGreen();
    int blueComponent = fopColor.getBlue();
    return RtfColorTable.getInstance().getColorNumber(redComponent, greenComponent, blueComponent).intValue();
}