Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

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

Prototype

public int getBlue() 

Source Link

Document

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

Usage

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

public Renderer setSunColor(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override// w  w w.ja v  a  2 s .  c  om
        public Void call() throws Exception {
            factory.getDeferredProgram().use();
            factory.getDeferredProgram().getUniform("sunColor").set(color.getRed() / 128f,
                    color.getGreen() / 128f, color.getBlue() / 128f);
            gpu.defaultProgram();
            return null;
        }
    }).get();
    return this;
}

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

public Renderer setAmbientLight(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override/*from   ww  w  . j  a v a  2  s .c om*/
        public Void call() throws Exception {
            factory.getDeferredProgram().use();
            factory.getDeferredProgram().getUniform("ambientLight").set(color.getRed() / 128f,
                    color.getGreen() / 128f, color.getBlue() / 128f);
            gpu.defaultProgram();
            return null;
        }
    }).get();
    return this;
}

From source file:statechum.analysis.learning.Visualiser.java

private static PluggableRenderer labelEdges(Graph graph, PluggableRenderer render,
        final LayoutOptions graphLayoutOptions) {
    final EdgeColour paintChooser = new EdgeColour(graph);
    EdgeStringer stringer = new EdgeStringer() {

        @SuppressWarnings("unchecked")
        @Override/*from   w w  w.  j a va  2s. com*/
        public String getLabel(ArchetypeEdge e) {
            String result = "";

            if (e.containsUserDatumKey(JUConstants.LABEL)) {
                StringBuffer text = new StringBuffer();
                text.append("<html>");
                boolean first = true;
                //final String blowupAttribute = Math.abs(graphLayoutOptions.scaleText - 1)<Configuration.fpAccuracy?" ":
                //   " style=\"font-size:"+Math.round(graphLayoutOptions.scaleText*100.)+"%\"";
                String color = "black";
                if (e.containsUserDatumKey(JUConstants.DIFF)) {
                    Color rgb = (Color) e.getUserDatum(JUConstants.DIFF);
                    color = "rgb(" + rgb.getRed() + "," + rgb.getGreen() + "," + rgb.getBlue() + ")";
                }
                for (Label lbl : abstractLabels((Set<Label>) e.getUserDatum(JUConstants.LABEL),
                        graphLayoutOptions.componentsToPick)) {
                    if (!first) {// choose separator
                        text.append("<br>");// default layout is vertical
                    } else
                        first = false;

                    if (!(lbl instanceof ErlangLabel)) {
                        text.append("<font color=" + color + ">");
                        text.append(lbl.toString());
                    } else {
                        ErlangLabel l = (ErlangLabel) lbl;
                        text.append("<font color=blue>");
                        text.append(l.callName);
                        text.append("</font>,&nbsp;");
                        text.append("<font color=" + color + ">");
                        text.append(l.input);
                        text.append("</font>");
                        if (l.expectedOutput != null) {
                            text.append(",&nbsp;<font color=black>");
                            text.append(l.expectedOutput);
                            text.append("</font>");
                        }
                    }
                }
                text.append("</html>");
                result = text.toString();
            }

            return result;
        }
    };
    render.setEdgeArrowFunction(
            new DirectionalEdgeArrowFunction((int) Math.round(10. * graphLayoutOptions.scaleLines),
                    (int) Math.round(5. * graphLayoutOptions.scaleLines), 4));
    render.setEdgeStringer(stringer);
    render.setEdgeStrokeFunction(new ConstantEdgeStrokeFunction((float) graphLayoutOptions.scaleLines));
    render.setEdgePaintFunction(new AbstractEdgePaintFunction() {

        @Override
        public Paint getDrawPaint(Edge e) {
            Color result = paintChooser.getPickedColour(e, graphLayoutOptions);
            return result != null ? result : Color.BLACK;
        }
    });
    return render;
}

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 a va 2s  .  c o m
 * @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: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);/*from   www  .  j a va2s.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: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;
        }/* w ww .  ja v  a  2 s  .co 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.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

public void store(Preferences p) {
    p.putInt("enabledCount", enabled.size());
    for (int i = 0; i < enabled.size(); i++) {
        Preferences gp = p.node("series" + i);
        gp.put("key", enabled.get(i));
        Color color = (Color) chart.getPlot().getLegendItems().get(i).getLinePaint();
        gp.putInt("color.r", color.getRed());
        gp.putInt("color.g", color.getGreen());
        gp.putInt("color.b", color.getBlue());
    }/*from ww w  .ja va  2  s  . c  o  m*/
}

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   w  w  w  .  j a v a2s  . c o 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.objectweb.proactive.extensions.timitspmd.util.charts.renderer.HierarchicalBarRenderer.java

/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2//from  www .  j  a v  a2  s  . c  o m
 *            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: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;/*  w ww . j a  va  2s.c  o m*/
        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);
    }
}