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.helioviewer.jhv.plugins.hekplugin.HEKPlugin.java

public void drawPolygon(GL2 gl, HEKEvent evt, Date now) {
    if (evt == null || !evt.isVisible(now))
        return;//from w  w w .ja v a  2 s .co  m

    List<HEKEvent.GenericTriangle<Vector3d>> triangles = evt.getTriangulation3D(now);
    List<SphericalCoord> outerBound = evt.getStonyBound(now);
    if (outerBound == null && triangles == null)
        return;

    String type = evt.getString("event_type");
    Color eventColor = HEKConstants.getSingletonInstance().acronymToColor(type, 128);

    HeliographicCoordinate heliographicCoordinate = evt.getHeliographicCoordinate(now);
    if (heliographicCoordinate == null)
        return;

    gl.glPushMatrix();
    gl.glRotated(DifferentialRotation.calculateRotationInDegrees(heliographicCoordinate.latitude,
            (now.getTime() - evt.getStart().getTime()) / 1000d), 0, 1, 0);

    if (triangles != null) {
        gl.glColor4ub((byte) eventColor.getRed(), (byte) eventColor.getGreen(), (byte) eventColor.getBlue(),
                (byte) eventColor.getAlpha());

        gl.glEnable(GL2.GL_CULL_FACE);
        gl.glDisable(GL2.GL_DEPTH_TEST);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

        gl.glBegin(GL2.GL_TRIANGLES);
        for (GenericTriangle<Vector3d> triangle : triangles) {
            gl.glVertex3d(triangle.A.x, triangle.A.y, triangle.A.z);
            gl.glVertex3d(triangle.B.x, triangle.B.y, triangle.B.z);
            gl.glVertex3d(triangle.C.x, triangle.C.y, triangle.C.z);
        }
        gl.glEnd();
    }

    // draw bounds
    gl.glColor4f(1, 1, 1, 1);
    if (outerBound != null) {
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnable(GL2.GL_DEPTH_TEST);

        gl.glBegin(GL.GL_LINE_LOOP);
        for (SphericalCoord boundaryPoint : outerBound) {
            Vector3d boundaryPoint3d = HEKEvent.convertToSceneCoordinates(boundaryPoint, now).scaled(1.005);
            gl.glVertex3d(boundaryPoint3d.x, boundaryPoint3d.y, boundaryPoint3d.z);
        }
        gl.glEnd();
    }

    gl.glPopMatrix();
}

From source file:Trabalho.HistogramaHSB.java

public ChartPanel criaHistograma() throws IOException {

    //pega a imagem
    BufferedImage img = pegaImagem();
    //w pega a largura da imagem - h pega a altura da imagem
    int w = img.getWidth();
    int h = img.getHeight();
    //d calcula o tamanho da imagem
    int d = (w * h);
    //red, green e blue iro receber os tons de cor antigo da imagem - u vai receber o RGB da cor 
    int red, green, blue, u;
    //retorna rgb no mtodo
    float[] hsb;/*from   ww  w.  j  a  v  a2 s. c  om*/
    int[] vetH = new int[256];
    int[] vetS = new int[256];
    int[] vetB = new int[256];
    float hue, sat, bri;
    //cAux e oldColor pegam os tons originais da imagem - newColor pega os tons aps o clculo
    Color oldColor;
    Color newColor;

    //for responsvel por substituir os tons antigos pelos novos; percorrem a imagem por largura e altura
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            u = img.getRGB(i, j); //u vai receber o RGB da posio i, j
            oldColor = new Color(u); //oldColor  instanciado e recebe o valor de u
            //cada cor recebe o valor do tom original
            red = oldColor.getRed();
            green = oldColor.getGreen();
            blue = oldColor.getBlue();
            hsb = Color.RGBtoHSB(red, green, blue, null);
            hue = hsb[0];
            sat = hsb[1];
            bri = hsb[2];
            //                System.out.println("RGB [" + red + "," + green + "," + blue + "] converted to HSB [" + hue + "," + sat + "," + bri + "]");

            //                hue = hue * 360;
            //                int convH = Integer.valueOf(new Float(hue).intValue());
            //                vetH[convH]++;
            //
            //                sat = sat * 100;
            //                int convS = Integer.valueOf(new Float(sat).intValue());
            //                vetS[convS]++;
            //
            //                bri = bri * 100;
            //                int convB = Integer.valueOf(new Float(bri).intValue());
            //                vetB[convB]++;

            newColor = new Color(hue, sat, bri);
            //seta o RGB da imagem nas posies i, j pegando os valores da newColor
            img.setRGB(i, j, newColor.getRGB());
        }
    }

    File ouptut = new File("D:\\ProjetosNetBeans\\PDI\\src\\imagens\\5.jpeg");
    ImageIO.write(img, "png", ouptut);

    dataset = new HistogramDataset();
    //pega o RGB

    r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 360);
    r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", r, 101);
    r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", r, 101);

    JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Plota as cores
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    //vermelho, verde, azul
    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };
    //desenhando o grfico
    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java

private Color repairColor(Color color) {
    int red = Math.min(color.getRed() + 10, 255);
    int green = Math.min(color.getGreen() + 10, 255);
    int blue = Math.min(color.getBlue() + 10, 255);
    return new Color(red, green, blue, color.getAlpha());
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java

private Component createGraphicPanel() {
    depthSerie = new XYSeries(DiveProfileChartFactory.SERIE_DEPTH);
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    chart = ChartFactory.createXYAreaChart(null, getDomainLegend(), getRangeLegend(), depthCollection,
            PlotOrientation.VERTICAL, false, true, false);
    xyp = chart.getXYPlot();//from  www.j  a va  2  s.co m

    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    xyp.setBackgroundPaint(p);
    xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid());

    xyp.setDomainCrosshairVisible(true);
    xyp.setRangeCrosshairVisible(true);
    xyp.setRangeCrosshairPaint(UIAgent.getInstance().getColorWaterCrossHair());
    xyp.setDomainCrosshairPaint(UIAgent.getInstance().getColorWaterCrossHair());
    xyp.setRangeCrosshairLockedOnData(true);
    xyp.setDomainCrosshairLockedOnData(true);
    ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    xyp.setRenderer(0, renderer0);

    createDecoWarningCollection();
    createAscentTooFastCollection();
    createRemainBottomTimeCollection();
    createDecoEntriesCollection();

    createGazMixCollection();

    chartPanel = new ChartPanel(chart);
    chart.setBackgroundPaint(null);
    chartPanel.setOpaque(false);

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent arg0) {
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent evt) {

            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    double x = xyp.getDomainCrosshairValue();
                    double y = xyp.getRangeCrosshairValue();
                    Calendar cal = new GregorianCalendar(0, 0, 0, 0, 0, (int) x);
                    instantTimeTf.setText(new SimpleDateFormat("HH:mm:ss").format(cal.getTime()));
                    instantDepthTf.setText(StringManipulator.formatFixedDecimalNumber(y,
                            UIAgent.PRECISION_DEPTH, UIAgent.NUMBER_DECIMAL_CHAR));
                }
            });
        }
    });
    return chartPanel;
}

From source file:edu.ku.brc.af.prefs.AppPreferences.java

/**
 * @param name//from  w w  w .j av a2 s.c  o  m
 * @param color
 */
public void putColor(final String name, final Color color) {
    put(name, String.format("%d, %d, %d", color.getRed(), color.getGreen(), color.getBlue())); //$NON-NLS-1$
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method creating the chart// w  w w  .j  a va  2s  . c om
 *
 * @param dataset dataset containing the data for the chart
 * @return a chart
 */
private JFreeChart createChart(XYZDataset dataset) {
    DateAxis xAxis = new DateAxis("Date");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setDateFormatOverride(new SimpleDateFormat(durationsFormatterArray[this.visualizationDuration]));
    xAxis.setRange(Calendar.getInstance().getTime(),
            new Date(System.currentTimeMillis() + HistoryUtil.durationsTimesArray[visualizationDuration]
                    - HistoryUtil.blockWidthsArray[visualizationDuration]));
    NumberAxis yAxis = new NumberAxis("Nodes");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setInverted(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setRange(1, numberOfNodes);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer renderer = new XYBlockRenderer();
    LookupPaintScale paintScale = new LookupPaintScale();
    for (int i = 0; i < jobsList.get(visualizationDuration).size(); i++) {
        // String jobId = jobsList.get(visualizationDuration).get(i).getId().substring(0,jobsList.get(visualizationDuration).get(i).getId().indexOf("."));
        String jobId = jobsList.get(visualizationDuration).get(i).getParameterValue(GridJob.KEY_GRID_JOB_ID);
        int seed = Integer.parseInt(jobId);
        Random rng = new Random(seed);
        Color tempColor = Color.red;
        int red = tempColor.getRed();
        int green = tempColor.getGreen();
        int blue = tempColor.getBlue();
        int redRNG = rng.nextInt(255);
        int greenRNG = rng.nextInt(255);
        int blueRNG = rng.nextInt(255);
        if (red == redRNG && green == greenRNG && blue == blueRNG) {
            tempColor = new Color(rng.nextInt(255), rng.nextInt(255), rng.nextInt(255));
        } else {
            tempColor = new Color(redRNG, greenRNG, blueRNG);
        }
        if (seed == 0)
            tempColor = Color.red;
        paintScale.add(new Double(i), tempColor);
    }
    renderer.setBlockWidth(HistoryUtil.blockWidthsArray[visualizationDuration]);
    renderer.setBlockAnchor(RectangleAnchor.TOP_LEFT);
    renderer.setPaintScale(paintScale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    JFreeChart chart = new JFreeChart("Gantt Chart activity for cluster " + siteName, plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "createChart",
            "Chart created");
    return chart;
}

From source file:umontreal.iro.lecuyer.charts.HistogramSeriesCollection.java

public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax,
        double ymin, double ymax) {

    // Calcule les bornes reelles du graphique, en prenant en compte la position des axes
    xmin = Math.min(XShift, xmin);
    xmax = Math.max(XShift, xmax);
    ymin = Math.min(YShift, ymin);
    ymax = Math.max(YShift, ymax);

    CustomHistogramDataset tempSeriesCollection = (CustomHistogramDataset) seriesCollection;
    Formatter formatter = new Formatter(Locale.US);
    double var;
    double margin = ((XYBarRenderer) renderer).getMargin();

    for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) {
        List temp = tempSeriesCollection.getBins(i);
        ListIterator iter = temp.listIterator();

        Color color = (Color) renderer.getSeriesPaint(i);
        String colorString = detectXColorClassic(color);
        if (colorString == null) {
            colorString = "color" + i;
            formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0,
                    color.getGreen() / 255.0, color.getBlue() / 255.0);
        }/*from   w w  w  . j ava  2s  .c  om*/

        HistogramBin currentBin = null;
        while (iter.hasNext()) {
            double currentMargin;
            currentBin = (HistogramBin) iter.next();
            currentMargin = ((margin * (currentBin.getEndBoundary() - currentBin.getStartBoundary()))) * XScale;
            if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax)
                    && (currentBin.getCount() >= ymin && currentBin.getCount() <= ymax)) {
                var = Math.min(currentBin.getEndBoundary(), xmax);
                if (filled[i]) {
                    formatter.format(
                            "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin,
                            (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale);
                } else {
                    formatter.format(
                            "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin,
                            (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale);
                }
            } else if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax)
                    && (currentBin.getCount() >= ymin && currentBin.getCount() > ymax)) { // Cas ou notre rectangle ne peut pas etre affiche en entier (trop haut)
                var = Math.min(currentBin.getEndBoundary(), xmax);
                if (filled[i]) {
                    formatter.format(
                            "\\filldraw [line width=%.2fpt,  opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin,
                            (var - XShift) * XScale, (ymax - YShift) * YScale);
                    formatter.format(
                            "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale,
                            currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale);
                } else {
                    formatter.format(
                            "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin,
                            (var - XShift) * XScale, (ymax - YShift) * YScale);

                    formatter.format(
                            "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n",
                            lineWidth[i], colorString, currentMargin,
                            (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale,
                            currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale);
                }
            }
        }
    }
    return formatter.toString();
}

From source file:de.tor.tribes.ui.windows.ClockFrame.java

protected void updateTime(String time, int millis) {
    if (isVisible()) {
        jLabel1.setText(time);//from   w w w.j  a  v a  2  s  . c  o m
        double markerMin = 0;
        double markerMax = 1000;
        double diff = markerMax - markerMin;
        float ratio = 0;
        if (diff > 0) {
            ratio = (float) ((millis - markerMin) / (markerMax - markerMin));
        }

        Color c1 = Color.GREEN;
        if (millis >= 500) {
            c1 = Color.YELLOW;
        }
        Color c2 = Color.RED;
        if (millis < 500) {
            c2 = Color.YELLOW;
            ratio += .5f;
        } else {
            ratio -= .5f;
        }
        int red = (int) Math.rint(c2.getRed() * ratio + c1.getRed() * (1f - ratio));
        int green = (int) Math.rint(c2.getGreen() * ratio + c1.getGreen() * (1f - ratio));
        int blue = (int) Math.rint(c2.getBlue() * ratio + c1.getBlue() * (1f - ratio));

        red = (red < 0) ? 0 : red;
        green = (green < 0) ? 0 : green;
        blue = (blue < 0) ? 0 : blue;
        red = (red > 255) ? 255 : red;
        green = (green > 255) ? 255 : green;
        blue = (blue > 255) ? 255 : blue;
        cp.setForeground(new Color(red, green, blue));
        cp.setValue(millis);
    }

    for (final TimerPanel p : timers.toArray(new TimerPanel[timers.size()])) {
        if (p.isExpired()) {
            SystrayHelper.showInfoMessage("Timer  '" + p.getName() + "' ist abgelaufen");
            //moved playing the sound to a new Thread because of graphic problems
            new Thread(new Runnable() {
                @Override
                public void run() {
                    playSound(p.getSound());
                }
            }).start();
            removeTimer(p);
        } else {
            p.update();
        }
    }
}

From source file:com.jaspersoft.studio.utils.ModelUtils.java

public static org.eclipse.swt.graphics.Color getSWTColorFromAWT(java.awt.Color awtColor) {
    return new org.eclipse.swt.graphics.Color(null, awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
}

From source file:org.eclipse.birt.report.engine.emitter.ppt.PPTWriter.java

private String getColorString(Color color) {
    StringBuffer buffer = new StringBuffer();
    appendComponent(buffer, color.getRed());
    appendComponent(buffer, color.getGreen());
    appendComponent(buffer, color.getBlue());
    return buffer.toString();
}