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:gov.redhawk.statistics.ui.views.StatisticsView.java

/**
 * This is a callback that will allow us to create the viewer and initialize it.
 *//*from  w w  w .j  ava2 s.  c o  m*/
@Override
public void createPartControl(Composite comp) {

    parent = comp;
    parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create());

    // Custom Action for the View's Menu
    CustomAction customAction = new CustomAction() {

        @Override
        public void run() {
            SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars);
            dialog.create();
            if (dialog.open() == Window.OK) {
                numBars = dialog.getNumBars();
                curIndex = dialog.getSelectedIndex();
                refreshJob.schedule();
            }
        }
    };
    customAction.setText("Settings");
    getViewSite().getActionBars().getMenuManager().add(customAction);

    // creation of chart composite and selection of associated options
    Composite chartComposite = new Composite(parent, SWT.EMBEDDED);
    chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false,
            true, false);

    org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground();
    chart.setBackgroundPaint(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE);

    Frame chartFrame = SWT_AWT.new_Frame(chartComposite);
    chartFrame.setBackground(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chartFrame.setLayout(new GridLayout());

    ChartPanel jFreeChartPanel = new ChartPanel(chart);
    chartFrame.add(jFreeChartPanel);

    ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setMargin(0.05);
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        @Override
        public String generateLabel(XYDataset dataset, int series, int item) {
            return String.valueOf((int) (dataset.getYValue(series, item)));
        }
    });
    renderer.setBasePaint(new Color(139, 0, 0));
    renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() {

        @Override
        public String generateLabel(XYDataset ds, int i) {
            if (ds.getSeriesCount() == 2) {
                if (i == 0) {
                    return "Real";
                } else if (i == 1) {
                    return "Imaginary";
                } else {
                    return "Complex";
                }
            } else if (ds.getSeriesCount() > 1) {
                return "Dimension " + i;
            }

            return null;
        }
    });
    chart.getXYPlot().setRenderer(renderer);

    dataSet.addChangeListener(new DatasetChangeListener() {

        @Override
        public void datasetChanged(DatasetChangeEvent event) {
            chart.getPlot().datasetChanged(event);

        }
    });

    // creation of the statistics composite
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT);
    section.setBackground(parent.getBackground());
    section.setDescription("");
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent

    // Composite for storing the data
    Composite composite = toolkit.createComposite(section, SWT.WRAP);
    composite.setBackground(parent.getBackground());
    composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    for (int j = 0; j < STAT_PROPS.length; j++) {
        Label label = new Label(composite, SWT.None);
        label.setText(STAT_PROPS[j] + ":");
        labels[j] = new Label(composite, SWT.None);
        labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    }

}

From source file:com.db.comserv.main.utilities.HttpCaller.java

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "DM_DEFAULT_ENCODING")
public HttpResult runRequest(String type, String methodType, URL url, List<Map<String, String>> headers,
        String requestBody, String sslByPassOption, int connTimeOut, int readTimeout, HttpServletRequest req)
        throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException,
        UnsupportedEncodingException, IOException, UnknownHostException, URISyntaxException {

    StringBuffer response = new StringBuffer();
    HttpResult httpResult = new HttpResult();
    boolean gzip = false;
    final long startNano = System.nanoTime();
    try {//from ww  w.ja v  a  2  s  . c  om
        URL encodedUrl = new URL(Utility.encodeUrl(url.toString()));
        HttpURLConnection con = (HttpURLConnection) encodedUrl.openConnection();
        TrustModifier.relaxHostChecking(con, sslByPassOption);

        // connection timeout 5s
        con.setConnectTimeout(connTimeOut);

        // read timeout 10s
        con.setReadTimeout(readTimeout * getQueryCost(req));

        methodType = methodType.toUpperCase();
        con.setRequestMethod(methodType);

        sLog.debug("Performing '{}' to '{}'", methodType, ServletUtil.filterUrl(url.toString()));

        // Get headers & set request property
        for (int i = 0; i < headers.size(); i++) {
            Map<String, String> header = headers.get(i);
            con.setRequestProperty(header.get("headerKey").toString(), header.get("headerValue").toString());
            sLog.debug("Setting Header '{}' with value '{}'", header.get("headerKey").toString(),
                    ServletUtil.filterHeaderValue(header.get("headerKey").toString(),
                            header.get("headerValue").toString()));
        }

        if (con.getRequestProperty("Accept-Encoding") == null) {
            con.setRequestProperty("Accept-Encoding", "gzip");
        }

        if (requestBody != null && !requestBody.equals("")) {
            con.setDoOutput(true);
            DataOutputStream wr = new DataOutputStream(con.getOutputStream());
            wr.write(Utility.toUtf8Bytes(requestBody));
            wr.flush();
            wr.close();

        }

        // push response
        BufferedReader in = null;
        String inputLine;

        List<String> contentEncoding = con.getHeaderFields().get("Content-Encoding");
        if (contentEncoding != null) {
            for (String val : contentEncoding) {
                if ("gzip".equalsIgnoreCase(val)) {
                    sLog.debug("Gzip enabled response");
                    gzip = true;
                    break;
                }
            }
        }

        sLog.debug("Response: '{} {}' with headers '{}'", con.getResponseCode(), con.getResponseMessage(),
                ServletUtil.buildHeadersForLog(con.getHeaderFields()));

        if (con.getResponseCode() != 200 && con.getResponseCode() != 201) {
            if (con.getErrorStream() != null) {
                if (gzip) {
                    in = new BufferedReader(
                            new InputStreamReader(new GZIPInputStream(con.getErrorStream()), "UTF-8"));
                } else {
                    in = new BufferedReader(new InputStreamReader(con.getErrorStream(), "UTF-8"));
                }
            }
        } else {
            String[] urlParts = url.toString().split("\\.");
            if (urlParts.length > 1) {
                String ext = urlParts[urlParts.length - 1];
                if (ext.equalsIgnoreCase("png") || ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")
                        || ext.equalsIgnoreCase("gif")) {
                    BufferedImage imBuff;
                    if (gzip) {
                        imBuff = ImageIO.read(new GZIPInputStream(con.getInputStream()));
                    } else {
                        BufferedInputStream bfs = new BufferedInputStream(con.getInputStream());
                        imBuff = ImageIO.read(bfs);
                    }
                    BufferedImage newImage = new BufferedImage(imBuff.getWidth(), imBuff.getHeight(),
                            BufferedImage.TYPE_3BYTE_BGR);

                    // converting image to greyScale
                    int width = imBuff.getWidth();
                    int height = imBuff.getHeight();
                    for (int i = 0; i < height; i++) {
                        for (int j = 0; j < width; j++) {
                            Color c = new Color(imBuff.getRGB(j, i));
                            int red = (int) (c.getRed() * 0.21);
                            int green = (int) (c.getGreen() * 0.72);
                            int blue = (int) (c.getBlue() * 0.07);
                            int sum = red + green + blue;
                            Color newColor = new Color(sum, sum, sum);
                            newImage.setRGB(j, i, newColor.getRGB());
                        }
                    }

                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    ImageIO.write(newImage, "jpg", out);
                    byte[] bytes = out.toByteArray();

                    byte[] encodedBytes = Base64.encodeBase64(bytes);
                    String base64Src = new String(encodedBytes);
                    int imageSize = ((base64Src.length() * 3) / 4) / 1024;
                    int initialImageSize = imageSize;
                    int maxImageSize = Integer.parseInt(properties.getValue("Reduced_Image_Size"));
                    float quality = 0.9f;
                    if (!(imageSize <= maxImageSize)) {
                        //This means that image size is greater and needs to be reduced.
                        sLog.debug("Image size is greater than " + maxImageSize + " , compressing image.");
                        while (!(imageSize < maxImageSize)) {
                            base64Src = compress(base64Src, quality);
                            imageSize = ((base64Src.length() * 3) / 4) / 1024;
                            quality = quality - 0.1f;
                            DecimalFormat df = new DecimalFormat("#.0");
                            quality = Float.parseFloat(df.format(quality));
                            if (quality <= 0.1) {
                                break;
                            }
                        }
                    }
                    sLog.debug("Initial image size was : " + initialImageSize + " Final Image size is : "
                            + imageSize + "Url is : " + url + "quality is :" + quality);
                    String src = "data:image/" + urlParts[urlParts.length - 1] + ";base64,"
                            + new String(base64Src);
                    JSONObject joResult = new JSONObject();
                    joResult.put("Image", src);
                    out.close();
                    httpResult.setResponseCode(con.getResponseCode());
                    httpResult.setResponseHeader(con.getHeaderFields());
                    httpResult.setResponseBody(joResult.toString());
                    httpResult.setResponseMsg(con.getResponseMessage());
                    return httpResult;
                }
            }

            if (gzip) {
                in = new BufferedReader(
                        new InputStreamReader(new GZIPInputStream(con.getInputStream()), "UTF-8"));
            } else {
                in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
            }
        }
        if (in != null) {
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();
        }

        httpResult.setResponseCode(con.getResponseCode());
        httpResult.setResponseHeader(con.getHeaderFields());
        httpResult.setResponseBody(response.toString());
        httpResult.setResponseMsg(con.getResponseMessage());

    } catch (Exception e) {
        sLog.error("Failed to received HTTP response after timeout", e);

        httpResult.setTimeout(true);
        httpResult.setResponseCode(500);
        httpResult.setResponseMsg("Internal Server Error Timeout");
        return httpResult;
    }

    return httpResult;
}

From source file:bwem.example.MapPrinterExample.java

/**
 * Draws the specified map data to the internal map printer and generates an image file.
 *
 * @param theMap the specified BWEM map data to print
 * @param filename the specified file without a file extension
 *///w w  w.j  ava 2  s .c o  m
public void printMap(Map theMap, String filename) {
    java.util.Map<Integer, Color> mapZoneColor = new HashMap<>();

    for (int y = 0; y < theMap.getData().getMapData().getWalkSize().getY(); ++y)
        for (int x = 0; x < theMap.getData().getMapData().getWalkSize().getX(); ++x) {
            WalkPosition p = new WalkPosition(x, y);
            MiniTile miniTile = theMap.getData().getMiniTile(p, CheckMode.NO_CHECK);

            Color col;
            if (miniTile.isSea()) {
                if (mapPrinter.showSeaSide && theMap.getData().isSeaWithNonSeaNeighbors(p))
                    col = MapPrinter.CustomColor.SEA_SIDE.color();
                else
                    col = MapPrinter.CustomColor.SEA.color();
            } else {
                if (mapPrinter.showLakes && miniTile.isLake()) {
                    col = MapPrinter.CustomColor.LAKE.color();
                } else {
                    if (mapPrinter.showAltitude) {
                        int c = 255 - ((miniTile.getAltitude().intValue() * 255)
                                / theMap.getHighestAltitude().intValue());
                        col = new Color(c, c, c);
                    } else {
                        col = MapPrinter.CustomColor.TERRAIN.color();
                    }

                    if (mapPrinter.showAreas || mapPrinter.showContinents)
                        if (miniTile.getAreaId().intValue() > 0) {
                            Area area = theMap.getArea(miniTile.getAreaId());
                            Color zoneColor = getZoneColor(area, mapZoneColor);
                            int red = zoneColor.getRed() * col.getRed() / 255;
                            int green = zoneColor.getGreen() * col.getGreen() / 255;
                            col = new Color(red, green, 0);
                        } else {
                            col = MapPrinter.CustomColor.TINY_AREA.color();
                        }
                }
            }

            mapPrinter.point(p, col);
        }

    if (mapPrinter.showData)
        for (int y = 0; y < theMap.getData().getMapData().getTileSize().getY(); ++y)
            for (int x = 0; x < theMap.getData().getMapData().getTileSize().getX(); ++x) {
                int data = ((TileImpl) theMap.getData().getTile(new TilePosition(x, y))).getInternalData();
                int c = (((data / 1) * 1) % 256);
                Color col = new Color(c, c, c);
                WalkPosition origin = (new TilePosition(x, y)).toWalkPosition();
                mapPrinter.rectangle(origin, origin.add(new WalkPosition(3, 3)), col, MapPrinter.fill_t.fill);
            }

    if (mapPrinter.showUnbuildable)
        for (int y = 0; y < theMap.getData().getMapData().getTileSize().getY(); ++y)
            for (int x = 0; x < theMap.getData().getMapData().getTileSize().getX(); ++x)
                if (!theMap.getData().getTile(new TilePosition(x, y)).isBuildable()) {
                    WalkPosition origin = (new TilePosition(x, y)).toWalkPosition();
                    mapPrinter.rectangle(origin.add(new WalkPosition(1, 1)), origin.add(new WalkPosition(2, 2)),
                            MapPrinter.CustomColor.UNBUILDABLE.color());
                }

    if (mapPrinter.showGroundHeight)
        for (int y = 0; y < theMap.getData().getMapData().getTileSize().getY(); ++y)
            for (int x = 0; x < theMap.getData().getMapData().getTileSize().getX(); ++x) {
                Tile.GroundHeight groundHeight = theMap.getData().getTile(new TilePosition(x, y))
                        .getGroundHeight();
                if (groundHeight.intValue() >= Tile.GroundHeight.HIGH_GROUND.intValue())
                    for (int dy = 0; dy < 4; ++dy)
                        for (int dx = 0; dx < 4; ++dx) {
                            WalkPosition p = (new TilePosition(x, y).toWalkPosition())
                                    .add(new WalkPosition(dx, dy));
                            if (theMap.getData().getMiniTile(p, CheckMode.NO_CHECK).isWalkable()) // groundHeight is usefull only for walkable miniTiles
                                if (((dx + dy) & (groundHeight == Tile.GroundHeight.HIGH_GROUND ? 1 : 3)) != 0)
                                    mapPrinter.point(p, MapPrinter.CustomColor.HIGHER_GROUND.color());
                        }
            }

    if (mapPrinter.showAssignedResources)
        for (Area area : theMap.getAreas())
            for (Base base : area.getBases()) {
                for (Mineral m : base.getMinerals())
                    mapPrinter.line(base.getCenter().toWalkPosition(), m.getCenter().toWalkPosition(),
                            MapPrinter.CustomColor.BASES.color());
                for (Geyser g : base.getGeysers())
                    mapPrinter.line(base.getCenter().toWalkPosition(), g.getCenter().toWalkPosition(),
                            MapPrinter.CustomColor.BASES.color());
            }

    if (mapPrinter.showGeysers)
        for (Geyser g : theMap.getNeutralData().getGeysers())
            printNeutral(theMap, g, MapPrinter.CustomColor.GEYSERS.color());

    if (mapPrinter.showMinerals)
        for (Mineral m : theMap.getNeutralData().getMinerals())
            printNeutral(theMap, m, MapPrinter.CustomColor.MINERALS.color());

    if (mapPrinter.showStaticBuildings)
        for (StaticBuilding s : theMap.getNeutralData().getStaticBuildings())
            printNeutral(theMap, s, MapPrinter.CustomColor.STATIC_BUILDINGS.color());

    if (mapPrinter.showStartingLocations)
        for (TilePosition t : theMap.getData().getMapData().getStartingLocations()) {
            WalkPosition origin = t.toWalkPosition();
            WalkPosition size = UnitType.Terran_Command_Center.tileSize().toWalkPosition(); // same size for other races
            mapPrinter.rectangle(origin, origin.add(size).subtract(new WalkPosition(1, 1)),
                    MapPrinter.CustomColor.STARTING_LOCATIONS.color(), MapPrinter.fill_t.fill);
        }

    if (mapPrinter.showBases)
        for (Area area : theMap.getAreas()) {
            for (Base base : area.getBases()) {
                WalkPosition origin = base.getLocation().toWalkPosition();
                WalkPosition size = UnitType.Terran_Command_Center.tileSize().toWalkPosition(); // same size for other races
                MapPrinter.dashed_t dashMode = base.getBlockingMinerals().isEmpty()
                        ? MapPrinter.dashed_t.not_dashed
                        : MapPrinter.dashed_t.dashed;
                mapPrinter.rectangle(origin, origin.add(size).subtract(new WalkPosition(1, 1)),
                        MapPrinter.CustomColor.BASES.color(), MapPrinter.fill_t.do_not_fill, dashMode);
            }
        }

    if (mapPrinter.showChokePoints) {
        for (MutablePair<MutablePair<AreaId, AreaId>, WalkPosition> f : theMap.getRawFrontier())
            mapPrinter.point(f.getRight(),
                    mapPrinter.showAreas ? MapPrinter.CustomColor.CHOKE_POINTS_SHOW_AREAS.color()
                            : MapPrinter.CustomColor.CHOKE_POINTS_SHOW_CONTINENTS.color());

        for (Area area : theMap.getAreas())
            for (ChokePoint cp : area.getChokePoints()) {
                ChokePoint.Node[] nodes = { ChokePoint.Node.END1, ChokePoint.Node.END2 };
                for (ChokePoint.Node n : nodes)
                    mapPrinter.square(cp.getNodePosition(n), 1, new Color(255, 0, 255), MapPrinter.fill_t.fill);
                mapPrinter.square(cp.getCenter(), 1, new Color(0, 0, 255), MapPrinter.fill_t.fill);
            }
    }

    //TODO: Handle exception.
    try {
        mapPrinter.writeImageToFile(Paths.get(filename + ".png"), "png");
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:org.jls.toolbox.math.chart.XYBlockChart.java

/**
 * Permet de modifier l'chelle de couleur utilise par le graphique. Cela
 * va crer un gradient de couleur entre les deux couleurs spcifies, la
 * premire couleur correspondant aux valeurs les plus fortes de l'chelle
 * des donnes  reprsenter. Les bornes infrieure et suprieure permettent
 * de prciser l'tendue des donnes reprsentes par cette chelle de
 * couleur.//from  w ww  . j  a  v  a 2s.  c om
 * 
 * @param colorMin
 *            Couleur d'arrive du gradient reprsentant les plus faibles
 *            valeurs de l'chelle.
 * @param colorMax
 *            Couleur de dpart du gradient reprsentant les plus fortes
 *            valeurs de l'chelle.
 * @param lowerBound
 *            Borne infrieure de l'chelle des donnes reprsentes.
 * @param upperBound
 *            Bornes suprieure de l'chelle des donnes reprsentes.
 */
public void setColorGradient(Color colorMin, Color colorMax, double lowerBound, double upperBound) {
    LookupPaintScale scale = new LookupPaintScale(lowerBound, upperBound, Color.lightGray);
    double r1, r2, dr, g1, g2, dg, b1, b2, db;
    int nbVal = (int) (upperBound - lowerBound + 0.5);

    // Acquisition des composantes
    r1 = colorMax.getRed();
    g1 = colorMax.getGreen();
    b1 = colorMax.getBlue();
    r2 = colorMin.getRed();
    g2 = colorMin.getGreen();
    b2 = colorMin.getBlue();

    // Calcul du delta entre les composantes
    dr = (r2 - r1) / nbVal;
    dg = (g2 - g1) / nbVal;
    db = (b2 - b1) / nbVal;

    // Cration du gradient
    for (int i = 0; i < nbVal; i++) {
        scale.add(lowerBound + i, new Color((int) r2, (int) g2, (int) b2));
        r2 = r2 - dr;
        g2 = g2 - dg;
        b2 = b2 - db;
    }

    // Mise  jour du graphique
    this.renderer.setPaintScale(scale);
    this.scaleLegend.setScale(scale);

    // Du fait que la lgende n'est pas lie aux modifications de la courbe,
    // il faut rcrer la lgende  la main.
    this.chart.removeSubtitle(this.scaleLegend);
    createPaintScaleLegend(scale);
}

From source file:bwem.example.MapPrinterExample.java

private boolean getZoneColorCppAlgorithmAnyOf(java.util.Map<Area, List<ChokePoint>> chokePointsByArea,
        java.util.Map<Integer, Color> mapZoneColor, Color color) {
    for (Area neighbor : chokePointsByArea.keySet()) {
        int neighborId = neighbor.getId().intValue();
        Color neighboringColor = mapZoneColor.get(neighborId);
        if (neighboringColor != null && (Math.abs(color.getRed() - neighboringColor.getRed())
                + Math.abs(color.getGreen() - neighboringColor.getGreen()) < 150)) {
            return true;
        }//from www .  j  av  a2s  .  c o m
    }
    return false;
}

From source file:org.tros.logo.swing.LogoMenuBar.java

/**
 * Set up the tools menu.// ww w .  ja  v  a  2 s  .  co m
 *
 * @return
 */
private JMenu setupToolsMenu() {
    JMenu toolsMenu = new JMenu(Localization.getLocalizedString("ToolsMenu"));

    toolsPenColorChooser = new JMenuItem(Localization.getLocalizedString("ToolsPenColorChooser"));
    toolsCanvasColorChooser = new JMenuItem(Localization.getLocalizedString("ToolsCanvasColorChooser"));

    toolsPenColorChooser.setMnemonic('P');
    toolsCanvasColorChooser.setMnemonic('C');

    toolsPenColorChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Color selected = JColorChooser.showDialog(parent, Localization.getLocalizedString("ColorChooser"),
                    null);
            if (selected != null) {
                int red = selected.getRed();
                int green = selected.getGreen();
                int blue = selected.getBlue();
                String hex = String.format("#%02x%02x%02x", red, green, blue);
                controller.insertCommand("pencolor" + " " + hex);
            }
        }
    });
    toolsCanvasColorChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Color selected = JColorChooser.showDialog(parent, Localization.getLocalizedString("ColorChooser"),
                    null);
            if (selected != null) {
                int red = selected.getRed();
                int green = selected.getGreen();
                int blue = selected.getBlue();
                String hex = String.format("#%02x%02x%02x", red, green, blue);
                controller.insertCommand("canvascolor" + " " + hex);
            }
        }
    });

    toolsMenu.add(toolsPenColorChooser);
    toolsMenu.add(toolsCanvasColorChooser);

    toolsMenu.setMnemonic('T');

    return (toolsMenu);
}

From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

private Object colorToHTML(Color color) {
    return "#" + String.format("%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
}

From source file:org.openhab.binding.diyonxbee.internal.DiyOnXBeeBinding.java

private String makeRGB(Color color) {
    final StringBuilder sb = new StringBuilder(12);
    sb.append("RGB");
    appendColor(sb, color.getRed());/*from  w ww  . ja va 2  s  .c  o  m*/
    appendColor(sb, color.getGreen());
    appendColor(sb, color.getBlue());
    return sb.toString();
}

From source file:org.jfree.eastwood.ChartEngine.java

private static void applyColorsToPiePlot(PiePlot plot, Color[] colors) {
    if (colors.length == 1) {
        Color c = colors[0];
        colors = new Color[2];
        colors[0] = c;//from w  w  w. j a  v a  2  s.  c  om
        colors[1] = new Color(255 - ((255 - c.getRed()) / 5), 255 - ((255 - c.getGreen()) / 5),
                255 - ((255 - c.getBlue()) / 5));
    }
    PieDataset dataset = plot.getDataset();
    int sectionCount = dataset.getItemCount();
    if (colors.length < sectionCount) { // we need to interpolate some
                                        // colors
        for (int i = 0; i < colors.length - 1; i++) {
            Color c1 = colors[i];
            Color c2 = colors[i + 1];
            int s1 = sectionIndexForColor(i, colors.length, sectionCount);
            int s2 = sectionIndexForColor(i + 1, colors.length, sectionCount);
            for (int s = s1; s <= s2; s++) {
                Color c = interpolatedColor(c1, c2, s - s1, s2 - s1);
                plot.setSectionPaint(dataset.getKey(s), c);
            }
        }
    } else {
        for (int i = 0; i < sectionCount; i++) {
            plot.setSectionPaint(dataset.getKey(i), colors[i]);
        }
    }
}

From source file:org.jtrfp.trcl.core.Texture.java

Texture(Color c, TR tr) {
    this(new PalettedVectorList(colorZeroRasterVL(), colorVL(c)), null,
            "SolidColor r=" + c.getRed() + " g=" + c.getGreen() + " b=" + c.getBlue(), tr, false);
}