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:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java

private void initColorModels() {
    for (int j = 0; j <= 1; j++) {
        final int palSize = 256;
        final byte[] r = new byte[palSize];
        final byte[] g = new byte[palSize];
        final byte[] b = new byte[palSize];
        final byte[] a = new byte[palSize];
        r[0] = (byte) backgroundColor.getRed();
        g[0] = (byte) backgroundColor.getGreen();
        b[0] = (byte) backgroundColor.getBlue();
        a[0] = (byte) backgroundColor.getAlpha();

        final Palette pal = new Palette("Rainbow", new Color[] { Color.black, Color.blue, Color.cyan,
                Color.green, Color.yellow, Color.orange, Color.red });
        for (int i = 1; i < 256; ++i) {
            float value = i / 255f;
            if (j == 0)
                value = (255 - i) / 255f;
            Color c = pal.lookupColor(value);
            r[i] = (byte) c.getRed();
            g[i] = (byte) c.getGreen();
            b[i] = (byte) c.getBlue();
            a[i] = (byte) 255;
        }//from ww  w.j  av  a 2 s. c o  m

        if (j == 0) {
            toggledColorModel = new IndexColorModel(8, palSize, r, g, b, a);
        } else {
            untoggledColorModel = new IndexColorModel(8, palSize, r, g, b, a);
        }
    }
}

From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java

private void configureGradientAreaFill(Graphics2D g2, XYPlot plot, PlotRenderingInfo info, Paint itemPaint,
        GradientLineAreaFill gradientLineAreaFill) {
    final Rectangle2D plotArea = info.getPlotArea();
    double plotWidth = plotArea.getWidth();
    double plotHeight = plotArea.getHeight();
    Double mainColorTransparency = gradientLineAreaFill.getMaxValueTransparency();
    Double bgColorTransparency = gradientLineAreaFill.getMinValueTransparency();

    if (itemPaint instanceof Color) {
        Color itemColor = (Color) itemPaint;
        int red = itemColor.getRed();
        int green = itemColor.getGreen();
        int blue = itemColor.getBlue();
        int mainColorAlpha = (mainColorTransparency >= 0.0 && mainColorTransparency <= 1.0)
                ? Math.round(255 * mainColorTransparency.floatValue())
                : 150;/*from   ww w .j  a va  2 s .c om*/
        int bgColorAlpha = (bgColorTransparency >= 0.0 && bgColorTransparency <= 1.0)
                ? Math.round(255 * bgColorTransparency.floatValue())
                : 128;

        Color mainColor = new Color(red, green, blue, mainColorAlpha);
        Paint bgColor = getBackgroundPaint();
        if (bgColor == null) {
            bgColor = plot.getBackgroundPaint();
        }
        Color secondaryColor = getSecondaryColor(bgColorAlpha, bgColor);

        Paint areaPaint = getAreaFillPaint(plot, plotWidth, plotHeight, mainColor, secondaryColor);
        g2.setPaint(areaPaint);
    } else {
        g2.setPaint(itemPaint);
    }
}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Utility function to create a semi-transparent variant of a given colour.
 * @param color the original colour.//from   w  w  w. j av a  2 s.  c om
 * @param a alpha, as a value from 0 (transparent) to 255 (opaque).
 * @return colour with transparency set.
 */
private static Color transparentColor(final Color color, final int a) {
    return new Color(color.getRed(), color.getGreen(), color.getBlue(), a);
}

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

private static Color interpolatedColor(Color c1, Color c2, int index, int range) {
    if (index == 0) {
        return c1;
    }//from   ww  w  .  jav a2  s .  co  m
    if (index == range) {
        return c2;
    }
    double fraction = (index + 0.0) / range;
    int r1 = c1.getRed();
    int g1 = c1.getGreen();
    int b1 = c1.getBlue();
    int r2 = c2.getRed();
    int g2 = c2.getGreen();
    int b2 = c2.getBlue();
    return new Color((int) (r1 + fraction * (r2 - r1)), (int) (g1 + fraction * (g2 - g1)),
            (int) (b1 + fraction * (b2 - b1)));
}

From source file:org.openstreetmap.josm.tools.Utils.java

/**
 * Returns the complementary color of {@code clr}.
 * @param clr the color to complement/*w  w  w  .  ja v  a2 s  .  com*/
 * @return the complementary color of {@code clr}
 */
public static Color complement(Color clr) {
    return new Color(255 - clr.getRed(), 255 - clr.getGreen(), 255 - clr.getBlue(), clr.getAlpha());
}

From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.renderer.HierarchicalBarRenderer.java

/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2//from ww  w . j  a  va2s .  com
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the plot area.
 * @param plot
 *            the plot.
 * @param domainAxis
 *            the domain (category) axis.
 * @param rangeAxis
 *            the range (value) axis.
 * @param data
 *            the data.
 * @param row
 *            the row index (zero-based).
 * @param column
 *            the column index (zero-based).
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset data, int row, int column, int pass) {
    // nothing is drawn for null values...
    Number dataValue = data.getValue(row, column);
    if (dataValue == null) {
        return;
    }

    // BAR X
    double rectX = domainAxis.getCategoryMiddle(column, this.getColumnCount(), dataArea,
            plot.getDomainAxisEdge()) - (state.getBarWidth() / 2.0);

    int seriesCount = this.getRowCount();

    // BAR Y
    double value = dataValue.doubleValue();
    double base = 0.0;
    double lclip = this.getLowerClip();
    double uclip = this.getUpperClip();

    if (uclip <= 0.0) { // cases 1, 2, 3 and 4
        if (value >= uclip) {
            return; // bar is not visible
        }
        base = uclip;
        if (value <= lclip) {
            value = lclip;
        }
    } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8
        if (value >= uclip) {
            value = uclip;
        } else {
            if (value <= lclip) {
                value = lclip;
            }
        }
    } else { // cases 9, 10, 11 and 12
        if (value <= lclip) {
            return; // bar is not visible
        }
        base = this.getLowerClip();
        if (value >= uclip) {
            value = uclip;
        }
    }

    RectangleEdge edge = plot.getRangeAxisEdge();
    double transY1 = rangeAxis.valueToJava2D(base, dataArea, edge);
    double transY2 = rangeAxis.valueToJava2D(value, dataArea, edge);
    double rectY = Math.min(transY2, transY1);

    double rectWidth = state.getBarWidth();
    double rectHeight = Math.abs(transY2 - transY1);

    // draw the bar...
    double shift = 0.0;
    rectWidth = 0.0;
    double widthFactor = 1.0;
    double seriesBarWidth = this.getSeriesBarWidth(row);
    if (!Double.isNaN(seriesBarWidth)) {
        widthFactor = seriesBarWidth;
    }
    rectWidth = widthFactor * state.getBarWidth();
    rectX = rectX + (((1 - widthFactor) * state.getBarWidth()) / 2.0);
    if (seriesCount > 1) {
        // needs to be improved !!!
        shift = (rectWidth * 0.20) / (seriesCount - 1);
    }

    Rectangle2D bar = new Rectangle2D.Double((rectX + ((seriesCount - 1 - row) * shift)), rectY,
            (rectWidth - ((seriesCount - 1 - row) * shift * 2)), rectHeight);

    double rrX;
    double rrY;
    double rrW;
    double rrH;
    if (row == 0) {
        @SuppressWarnings("unchecked")
        Iterator it = this.datasetTree[column].getDescendants();
        int numElement = -1;
        while (it.hasNext()) {
            try {
                Element elt = (Element) it.next();
                numElement++;
                String name = elt.getAttributeValue("name");
                dataValue = Double.valueOf(elt.getAttributeValue("avg"));
                // System.out.println("["+column+"] "+name+" \t-->
                // "+dataValue);
                // BAR X
                rectX = domainAxis.getCategoryMiddle(column, this.getColumnCount(), dataArea,
                        plot.getDomainAxisEdge()) - (state.getBarWidth() / 2.0);

                seriesCount = this.getRowCount();

                // BAR Y
                value = dataValue.doubleValue();
                base = 0.0;
                lclip = this.getLowerClip();
                uclip = this.getUpperClip();

                if (uclip <= 0.0) { // cases 1, 2, 3 and 4
                    if (value >= uclip) {
                        return; // bar is not visible
                    }
                    base = uclip;
                    if (value <= lclip) {
                        value = lclip;
                    }
                } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8
                    if (value >= uclip) {
                        value = uclip;
                    } else {
                        if (value <= lclip) {
                            value = lclip;
                        }
                    }
                } else { // cases 9, 10, 11 and 12
                    if (value <= lclip) {
                        return; // bar is not visible
                    }
                    base = this.getLowerClip();
                    if (value >= uclip) {
                        value = uclip;
                    }
                }

                edge = plot.getRangeAxisEdge();
                transY1 = rangeAxis.valueToJava2D(base, dataArea, edge);
                transY2 = rangeAxis.valueToJava2D(value, dataArea, edge);
                rectY = Math.min(transY2, transY1);

                rectWidth = state.getBarWidth();
                rectHeight = Math.abs(transY2 - transY1);

                // draw the bar...
                shift = 0.0;
                rectWidth = 0.0;
                widthFactor = 1.0;
                seriesBarWidth = this.getSeriesBarWidth(row);
                if (!Double.isNaN(seriesBarWidth)) {
                    widthFactor = seriesBarWidth;
                }
                rectWidth = widthFactor * state.getBarWidth();
                rectX = rectX + (((1 - widthFactor) * state.getBarWidth()) / 2.0);
                if (seriesCount > 1) {
                    // needs to be improved !!!
                    shift = (rectWidth * 0.20) / (seriesCount - 1);
                }
                rrX = (rectX + ((seriesCount - 1 - row) * shift));
                rrY = rectY;
                rrW = (rectWidth - ((seriesCount - 1 - row) * shift * 2));
                rrH = rectHeight;

                // IMPORTANT NOTE :
                // dev attribute is used to save width of the element
                // min attribute is used to save X position of the element
                // max attribute is used to save the number of child already
                // managed
                if (numElement == 0) {
                    elt.setAttribute("dev", "" + rrW);
                    elt.setAttribute("min", "" + rrX);
                    elt.setAttribute("max", "0");
                } else {
                    Element parent = elt.getParentElement();

                    // System.out.println(" Parent
                    // "+parent.getAttributeValue("name")
                    // + " rrX/rrW/child -> "
                    // + parent.getAttributeValue("min")+"/"
                    // + parent.getAttributeValue("dev")+"/"
                    // + parent.getAttributeValue("max") );
                    double pW = Double.valueOf(parent.getAttributeValue("dev"));
                    double pX = Double.valueOf(parent.getAttributeValue("min"));
                    int numChild = Integer.valueOf(parent.getAttributeValue("max"));

                    rrW = pW / parent.getChildren().size();
                    rrX = pX + (rrW * numChild);
                    rrX += HierarchicalBarRenderer.INCLUSION_MARGIN;
                    rrW -= (HierarchicalBarRenderer.INCLUSION_MARGIN * 2);
                    elt.setAttribute("dev", "" + rrW);
                    elt.setAttribute("min", "" + rrX);
                    parent.setAttribute("max", "" + (numChild + 1));
                }

                RoundRectangle2D rbar = new RoundRectangle2D.Double(rrX, rrY, rrW, rrH,
                        HierarchicalBarRenderer.CORNER, HierarchicalBarRenderer.CORNER);

                Rectangle2D childSumLine = null;
                double childSum = Double.valueOf(elt.getAttributeValue("sum"));
                transY1 = rangeAxis.valueToJava2D(base, dataArea, edge);
                transY2 = rangeAxis.valueToJava2D(childSum, dataArea, edge);
                rectY = Math.min(transY2, transY1);

                childSum = (childSum / dataValue.doubleValue()) * rrH;
                if ((childSum < rrH) && (childSum > 0) && ((childSum / rrH) < 0.95)) {
                    childSumLine = new Rectangle2D.Double(rrX, rectY, rrW, 1);
                }
                Paint itemPaint = this.getItemPaintFromName(name, this.series, column);
                GradientPaintTransformer t = this.getGradientPaintTransformer();
                if ((t != null) && itemPaint instanceof GradientPaint) {
                    itemPaint = t.transform((GradientPaint) itemPaint, bar);
                }
                g2.setPaint(itemPaint);

                Color c = g2.getColor();
                g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), this.alpha));
                g2.fill(rbar);
                g2.setColor(Color.DARK_GRAY);
                if (childSumLine != null) {
                    g2.fill(childSumLine);
                }

                // draw the outline...
                if (this.isDrawBarOutline()
                        && (state.getBarWidth() > BarRenderer.BAR_OUTLINE_WIDTH_THRESHOLD)) {
                    Stroke stroke = this.getItemOutlineStroke(row, column);
                    Paint paint = this.getItemOutlinePaint(row, column);
                    if ((stroke != null) && (paint != null)) {
                        g2.setStroke(stroke);
                        g2.setPaint(paint);
                        g2.draw(rbar);
                    }
                }
            } catch (ClassCastException e) {
                continue;
            }
        }
    }

    // ////////////////////////////

    // draw the item labels if there are any...
    double transX1 = rangeAxis.valueToJava2D(base, dataArea, edge);
    double transX2 = rangeAxis.valueToJava2D(value, dataArea, edge);

    CategoryItemLabelGenerator generator = this.getItemLabelGenerator(row, column);
    if ((generator != null) && this.isItemLabelVisible(row, column)) {
        this.drawItemLabel(g2, data, row, column, plot, generator, bar, (transX1 > transX2));
    }

    // collect entity and tool tip information...
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            String tip = null;
            CategoryToolTipGenerator tipster = this.getToolTipGenerator(row, column);
            if (tipster != null) {
                tip = tipster.generateToolTip(data, row, column);
            }
            String url = null;
            if (this.getItemURLGenerator(row, column) != null) {
                url = this.getItemURLGenerator(row, column).generateURL(data, row, column);
            }
            CategoryItemEntity entity = new CategoryItemEntity(bar, tip, url, data, row,
                    data.getColumnKey(column), column);
            entities.add(entity);
        }
    }
}

From source file:net.cloudkit.relaxation.VerifyImage.java

public void clearNoise(BufferedImage image) {
    /*/*from w w  w.j  a v a2s . co m*/
    int w = image.getWidth();
    int h = image.getHeight();
            
    int p1;
    int p2;
    for (p1 = 0; p1 < w; ++p1) {
    for (p2 = 0; p2 < h; ++p2) {
        if (p1 == 0 || p2 == 0 || p1 == w - 1 || p2 == h - 1) {
            image.setRGB(p1, p2, Color.WHITE.getRGB());
        }
    }
    }
            
    for (int x = 0; x < w; ++x) {
    for (int y = 0; y < h; ++y) {
        p1 = x == 0 ? 255 : getRed(image.getRGB(x - 1, y));
        p2 = x == w - 1 ? 255 : getRed(image.getRGB(x + 1, y));
        int p3 = y == 0 ? 255 : getRed(image.getRGB(x, y - 1));
        int p4 = y == h - 1 ? 255 : getRed(image.getRGB(x, y + 1));
        int p5 = x != 0 && y != 0 ? getRed(image.getRGB(x - 1, y - 1)) : 255;
        int p6 = x != w - 1 && y != 0 ? getRed(image.getRGB(x + 1, y - 1)) : 255;
        int p7 = x != 0 && y != h - 1 ? getRed(image.getRGB(x - 1, y + 1)) : 255;
        int p8 = x != w - 1 && y != h - 1 ? getRed(image.getRGB(x + 1, y + 1)) : 255;
        if (p1 == 255 && p1 == p2 && p2 == p3 && p3 == p4 && p4 == p5 && p5 == p6 && p7 == p8) {
            image.setRGB(x, y, Color.WHITE.getRGB());
        }
    }
    }
    */

    final int width = image.getWidth();
    final int height = image.getHeight();

    // int blackThreshold = 300;

    // img.getMinX() img.getMinY()
    for (int x = image.getMinX(); x < width; x++) {
        for (int y = image.getMinY(); y < height; y++) {

            //                Color color = new Color(image.getRGB(x, y));
            //                if((color.getBlue() < 120) || ((color.getRed() + color.getGreen() + color.getBlue()) < 50)) { //
            //                    image.setRGB(x, y, Color.WHITE.getRGB());
            //                } else if((color.getRed() + color.getGreen() + color.getBlue()) < 400) {
            //                    image.setRGB(x, y, Color.BLACK.getRGB());
            //                }

            int nearly = 0;
            int vertical = 0;
            int horizontal = 0;

            if (x > 0) {
                Color leftColor = new Color(image.getRGB(x - 1, y));
                if ((leftColor.getRed() + leftColor.getGreen() + leftColor.getBlue()) < 400) {
                    nearly++;
                    horizontal++;
                }
            }
            if (x < width - 1) {
                Color rightColor = new Color(image.getRGB(x + 1, y));
                if ((rightColor.getRed() + rightColor.getGreen() + rightColor.getBlue()) < 400) {
                    nearly++;
                    horizontal++;
                }
            }
            if (y > 0) {
                Color topColor = new Color(image.getRGB(x, y - 1));
                if ((topColor.getRed() + topColor.getGreen() + topColor.getBlue()) < 400) {
                    nearly++;
                    vertical++;
                }
            }
            if (y < height - 1) {
                Color bottomColor = new Color(image.getRGB(x, y + 1));
                if ((bottomColor.getRed() + bottomColor.getGreen() + bottomColor.getBlue()) < 400) {
                    nearly++;
                    vertical++;
                }
            }

            if (x > 0 && y > 0) {
                Color leftTopColor = new Color(image.getRGB(x - 1, y - 1));
                if ((leftTopColor.getRed() + leftTopColor.getGreen() + leftTopColor.getBlue()) < 400) {
                    nearly++;
                }
            }
            if (x < width - 1 && y < height - 1) {
                Color rightBottomColor = new Color(image.getRGB(x + 1, y + 1));
                if ((rightBottomColor.getRed() + rightBottomColor.getGreen()
                        + rightBottomColor.getBlue()) < 400) {
                    nearly++;
                }
            }
            if (x < width - 1 && y > 0) {
                Color rightTopColor = new Color(image.getRGB(x + 1, y - 1));
                if ((rightTopColor.getRed() + rightTopColor.getGreen() + rightTopColor.getBlue()) < 400) {
                    nearly++;
                }
            }
            if (x > 0 && y < height - 1) {
                Color leftBottomColor = new Color(image.getRGB(x - 1, y + 1));
                if ((leftBottomColor.getRed() + leftBottomColor.getGreen() + leftBottomColor.getBlue()) < 400) {
                    nearly++;
                }
            }

            if (nearly < 2) {
                image.setRGB(x, y, Color.WHITE.getRGB());
            }

        }
    }
}

From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.panel.Chromatogram2DViewerPanel.java

@Override
public void setPaintScale(PaintScale ps) {
    Logger.getLogger(getClass().getName()).info("Set paint scale called on HeatmapPanel");
    GradientPaintScale sps = (GradientPaintScale) ps;
    if (this.ps != null) {
        double lb = this.ps.getLowerBound();
        double ub = this.ps.getUpperBound();
        sps.setLowerBound(lb);// ww w  . ja  v a 2 s .  c  o  m
        sps.setUpperBound(ub);
        //this.jSlider1.setValue(0);
    }
    this.alpha = (int) sps.getAlpha();
    this.beta = (int) sps.getBeta();
    this.ps = sps;
    Color c = (Color) sps.getPaint(this.ps.getUpperBound());
    selectionFill = new Color(c.getRed(), c.getBlue(), c.getGreen(), 192);
    selectionOutline = new Color(c.getRed(), c.getBlue(), c.getGreen()).darker();
    this.jSlider1.setMaximum(100);
    this.jSlider1.setMinimum(0);
    handleSliderChange();
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.blockcharts.TimeBlockChart.java

@Override
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    super.createChart(datasets);
    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    DateAxis xAxis = new DateAxis(yLabel);
    xAxis.setLowerMargin(0.0);/*from w  ww .  j a  va  2 s . c o m*/
    xAxis.setUpperMargin(0.0);
    xAxis.setInverted(false);
    xAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy"));
    if (dateAutoRange) {
        xAxis.setAutoRange(true);
    } else {
        DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1, formatter);
        xAxis.setTickUnit(unit);
    }

    if (dateMin != null && dateMax != null) {
        xAxis.setRange(dateMin, addDay(dateMax));
    } else {
        xAxis.setRange(minDateFound, addDay(maxDateFound));
    }

    //      Calendar c=new GregorianCalendar();
    //      c.set(9 + 2000, Calendar.JANUARY, 1);
    //      java.util.Date minima=c.getTime();
    //      Calendar c1=new GregorianCalendar();
    //      c1.set(9 + 2000, Calendar.FEBRUARY, 1);
    //      java.util.Date massima=c1.getTime();

    NumberAxis yAxis = new NumberAxis(xLabel);
    yAxis.setUpperMargin(0.0);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setRange(hourMin, hourMax);

    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth(BLOCK_HEIGHT);
    // one block for each minute!
    renderer.setBlockHeight(0.017);
    //renderer.setBlockWidth(1);
    renderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT);

    //      MyXYItemLabelGenerator my=new MyXYItemLabelGenerator();
    //      renderer.setItemLabelsVisible(null);
    //      renderer.setSeriesItemLabelGenerator(0, my);
    //      renderer.setSeriesItemLabelsVisible(0, true);

    //      XYTextAnnotation annotation1 = new XYTextAnnotation(
    //      "P_",1.2309372E12, 14.3);
    //      XYTextAnnotation annotation2 = new XYTextAnnotation(
    //      "P_",1.2308508E12, 16.3);

    for (Iterator iterator = annotations.keySet().iterator(); iterator.hasNext();) {
        String annotationCode = (String) iterator.next();
        AnnotationBlock annotationBlock = annotations.get(annotationCode);
        XYTextAnnotation xyAnnotation = new XYTextAnnotation(annotationBlock.getAnnotation(),
                annotationBlock.getXPosition() + ANNOTATION_HEIGHT, annotationBlock.getYPosition());
        if (styleAnnotation != null) {
            xyAnnotation.setFont(new Font(styleAnnotation.getFontName(), Font.BOLD, styleAnnotation.getSize()));
            xyAnnotation.setPaint(styleAnnotation.getColor());
        } else {
            xyAnnotation.setFont(new Font("Nome", Font.BOLD, 8));
            xyAnnotation.setPaint(Color.BLACK);
        }

        xyAnnotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
        renderer.addAnnotation(xyAnnotation);
    }

    logger.debug("Annotation set");

    LookupPaintScale paintScale = new LookupPaintScale(0.5, ranges.size() + 0.5, color);
    String[] labels = new String[ranges.size() + 1];
    labels[0] = "";

    // ******************** SCALE ****************************
    for (Iterator iterator = ranges.iterator(); iterator.hasNext();) {
        RangeBlocks range = (RangeBlocks) iterator.next();
        Integer index = patternRangeIndex.get(range.getPattern());
        Color color = range.getColor();
        if (color != null) {
            //Paint colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);         
            Paint colorTransparent = null;
            if (addTransparency == true) {
                colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);
            } else {
                colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue());
            }
            paintScale.add(index + 0.5, colorTransparent);
        }
        //String insertLabel="            "+range.getLabel();
        String insertLabel = range.getLabel();
        labels[index + 1] = insertLabel;
    }
    renderer.setPaintScale(paintScale);

    SymbolAxis scaleAxis = new SymbolAxis(null, labels);
    scaleAxis.setRange(0.5, ranges.size() + 0.5);
    scaleAxis.setPlot(new PiePlot());
    scaleAxis.setGridBandsVisible(false);

    org.jfree.chart.title.PaintScaleLegend psl = new PaintScaleLegend(paintScale, scaleAxis);
    psl.setMargin(new RectangleInsets(3, 10, 3, 10));
    psl.setPosition(RectangleEdge.BOTTOM);
    psl.setAxisOffset(5.0);
    // ******************** END SCALE ****************************

    logger.debug("Scale Painted");

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    logger.debug("Plot set");

    JFreeChart chart = new JFreeChart(name, plot);
    if (styleTitle != null) {
        TextTitle title = setStyleTitle(name, styleTitle);
        chart.setTitle(title);
    }
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    chart.addSubtitle(psl);

    logger.debug("OUT");

    return chart;

}

From source file:org.n52.server.io.render.DiagramRenderer.java

/**
 * Builds up a DesignDescriptionList which stores the information
 * about the style of each timeseries./*from  www .j ava  2  s.  co  m*/
 *
 * @param options
 *            the options
 * @return the design description list
 */
private DesignDescriptionList buildUpDesignDescriptionList(DesignOptions options) {

    String domainAxisLabel;
    if (options.getLanguage() != null && options.getLanguage().equals("de")) {
        domainAxisLabel = "Zeit";
    } else { // default => "en"
        domainAxisLabel = "Time";
    }
    if (this.isOverview) {
        domainAxisLabel = null;
    }

    DesignDescriptionList designDescriptions = new DesignDescriptionList(domainAxisLabel);
    String observedPropertyWithGrid = options.getProperties().get(0).getPhenomenon();

    for (TimeseriesProperties tsProperties : options.getProperties()) {
        Color c = JavaHelper.transformToColor(tsProperties.getHexColor());
        String phenomenonId = tsProperties.getPhenomenon();
        boolean drawGrid = observedPropertyWithGrid.equals(phenomenonId);

        designDescriptions.add(tsProperties,
                new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) tsProperties.getOpacity() * 255 / 100),
                tsProperties.getLineStyle(), tsProperties.getLineWidth(), drawGrid);
    }
    return designDescriptions;
}