Example usage for java.awt Color Color

List of usage examples for java.awt Color Color

Introduction

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

Prototype

public Color(int rgb) 

Source Link

Document

Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.

Usage

From source file:ml.hsv.java

public static void HSV2File(hsv hsvImage[][], int width, int height) throws IOException //store img output as hsv2file.png
{
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            int RGB = Color.HSBtoRGB(hsvImage[i][j].h, hsvImage[i][j].s, hsvImage[i][j].v);
            Color c = new Color(RGB);
            int temp[] = { c.getRed(), c.getGreen(), c.getBlue() };
            raster.setPixel(j, i, temp);
        }/*from   w  w  w  .ja  va2s.  co  m*/
    }
    ImageIO.write(image, "PNG",
            new File("/home/shinchan/FinalProject/PaperImplementation/Eclipse/ML/output/hsv2file.png"));
}

From source file:br.prof.salesfilho.oci.image.ImageProcessor.java

public double[] getBlue() {
    int[] colors = new int[this.image.getWidth() * this.image.getHeight()];
    this.image.getRGB(0, 0, this.image.getWidth(), this.image.getHeight(), colors, 0, this.image.getWidth());

    double[] blue = new double[colors.length];

    for (int i = 0; i < colors.length; i++) {
        Color color = new Color(colors[i]);
        int rgb = color.getRGB();
        int b = (rgb & 0xFF);
        blue[i] = (double) b;
    }/*w  ww .j a va  2s .c o m*/
    return blue;
}

From source file:components.ButtonHtmlDemo.java

public ButtonHtmlDemo() {
    ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
    ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
    ImageIcon rightButtonIcon = createImageIcon("images/left.gif");

    b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>",
            leftButtonIcon);/*from   w ww  .  j a  va  2 s  .c o  m*/
    Font font = b1.getFont().deriveFont(Font.PLAIN);
    b1.setFont(font);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for left-to-right locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("middle button", middleButtonIcon);
    b2.setFont(font);
    b2.setForeground(new Color(0xffffdd));
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>",
            rightButtonIcon);
    b3.setFont(font);
    //Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    //Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    //Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
}

From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java

public static Color getColor(String color) {
    // HTML colors (#FFFFFF format)
    if (color.startsWith("#")) {
        return new Color(Integer.parseInt(color.substring(1), 16));
    } else {//from w w w.j a  v a 2 s. co m
        // Colors by name
        if (color.equalsIgnoreCase("black"))
            return Color.black;
        if (color.equalsIgnoreCase("gray"))
            return Color.gray;
        if (color.equalsIgnoreCase("yellow"))
            return Color.yellow;
        if (color.equalsIgnoreCase("green"))
            return Color.green;
        if (color.equalsIgnoreCase("blue"))
            return Color.blue;
        if (color.equalsIgnoreCase("red"))
            return Color.red;
        if (color.equalsIgnoreCase("orange"))
            return Color.orange;
        if (color.equalsIgnoreCase("cyan"))
            return Color.cyan;
        if (color.equalsIgnoreCase("magenta"))
            return Color.magenta;
        if (color.equalsIgnoreCase("darkgray"))
            return Color.darkGray;
        if (color.equalsIgnoreCase("lightgray"))
            return Color.lightGray;
        if (color.equalsIgnoreCase("pink"))
            return Color.pink;
        if (color.equalsIgnoreCase("white"))
            return Color.white;

        throw new RuntimeException("Unsupported chart color:" + color);
    }
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.BulletGraph.java

public void configureChart(SourceBean content) {
    logger.debug("IN");
    super.configureChart(content);

    String target = (String) confParameters.get("target");
    if (target != null)
        this.target = new Double(target);

    SourceBean confSB = (SourceBean) content.getAttribute("INTERVALS");
    if (confSB == null) {
        confSB = (SourceBean) content.getAttribute("CONF.INTERVALS");
    }//from   w w  w . java 2 s.com
    List confAttrsList = confSB.getAttributeAsList(INTERVAL);
    if (!confAttrsList.isEmpty()) {
        Iterator it = confAttrsList.iterator();
        while (it.hasNext()) {
            SourceBean param = (SourceBean) it.next();
            KpiInterval interval = new KpiInterval();
            String min = (String) param.getAttribute(MIN_INTERVAL);
            String max = (String) param.getAttribute(MAX_INTERVAL);
            String col = (String) param.getAttribute(COLOR_INTERVAL);
            interval.setMin(Double.valueOf(min).doubleValue());
            interval.setMax(Double.valueOf(max).doubleValue());
            Color color = new Color(Integer.decode(col).intValue());
            interval.setColor(color);
            this.intervals.add(interval);
        }
    }
    logger.debug("OUT");
}

From source file:de.erdesignerng.model.serializer.xml50.XMLSubjectAreaSerializer.java

@Override
public void deserialize(Model aModel, Document aDocument) {

    NodeList theElements = aDocument.getElementsByTagName(SUBJECTAREA);
    for (int i = 0; i < theElements.getLength(); i++) {
        Element theElement = (Element) theElements.item(i);

        SubjectArea theSubjectArea = new SubjectArea();
        deserializeProperties(theElement, theSubjectArea);

        theSubjectArea.setColor(new Color(Integer.parseInt(theElement.getAttribute(COLOR))));
        if (theElement.hasAttribute(VISIBLE)) {
            theSubjectArea.setVisible(TRUE.equals(theElement.getAttribute(VISIBLE)));
        }//from   w w w  .j  a  va2  s. com

        if (theElement.hasAttribute(EXPANDED)) {
            theSubjectArea.setExpanded(TRUE.equals(theElement.getAttribute(EXPANDED)));
        }

        NodeList theTables = theElement.getElementsByTagName(ITEM);
        for (int j = 0; j < theTables.getLength(); j++) {

            Element theItemElement = (Element) theTables.item(j);
            String theTableId = theItemElement.getAttribute(TABLEREFID);
            String theViewId = theItemElement.getAttribute(VIEWREFID);
            String theCommentId = theItemElement.getAttribute(COMMENTREFID);

            if (!StringUtils.isEmpty(theTableId)) {
                Table theTable = aModel.getTables().findBySystemId(theTableId);
                if (theTable == null) {
                    throw new IllegalArgumentException("Cannot find table with id " + theTableId);
                }

                theSubjectArea.getTables().add(theTable);
            }

            if (!StringUtils.isEmpty(theViewId)) {
                View theView = aModel.getViews().findBySystemId(theViewId);
                if (theView == null) {
                    throw new IllegalArgumentException("Cannot find view with id " + theViewId);
                }

                theSubjectArea.getViews().add(theView);
            }

            if (!StringUtils.isEmpty(theCommentId)) {
                Comment theComment = aModel.getComments().findBySystemId(theCommentId);
                if (theComment == null) {
                    throw new IllegalArgumentException("Cannot find comment with id " + theCommentId);
                }

                theSubjectArea.getComments().add(theComment);
            }
        }

        aModel.getSubjectAreas().add(theSubjectArea);
    }
}

From source file:edu.kit.dama.ui.components.TextImage.java

/**
 * Create a new TextImage instance using the provided ColorGenerator.
 *
 * @param pColorGen The custom ColorGenerator.
 *
 * @return The text image instance.//from w  ww .  java 2s.  co  m
 */
public TextImage withColorGenerator(ColorGenerator pColorGen) {
    colorGen = pColorGen;
    color = new Color(colorGen.getColor(text));
    return this;
}