Example usage for java.awt Color getRed

List of usage examples for java.awt Color getRed

Introduction

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

Prototype

public int getRed() 

Source Link

Document

Returns the red 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 {//from w  w w.  j ava  2 s. 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  ww  .jav  a2 s . c  om

    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/*from w ww . ja  v 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:net.groupbuy.util.ImageUtils.java

/**
 * ????//www.j  ava 2 s.  c om
 * 
 * @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.commons.java.util.StringUtilities.java

/**
 * Converts a Color into a String.//w ww .jav a  2s  .  c  o  m
 * <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:com.el.ecom.utils.ImageUtils.java

/**
 * ????//from  w  w  w. j ava 2  s .c  o  m
 * 
 * @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.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  va 2s  .c  om
 * @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: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
 *//*from  w  w w .  j  av  a2  s . com*/
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();
}

From source file:canreg.client.analysis.Tools.java

public static Color darken(Color color) {
    return new Color((int) Math.floor(color.getRed() * .9), (int) Math.floor(color.getGreen() * .9),
            (int) Math.floor(color.getBlue() * .9));
}