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:userinterface.graph.SeriesSettings.java

public void save(Element series) throws SettingException {
    series.setAttribute("seriesHeading", getSeriesHeading());
    series.setAttribute("lineWidth", "" + getLineWidth());

    Color seriesColor = getSeriesColour();
    series.setAttribute("seriesColourR", "" + seriesColor.getRed());
    series.setAttribute("seriesColourG", "" + seriesColor.getGreen());
    series.setAttribute("seriesColourB", "" + seriesColor.getBlue());

    series.setAttribute("showPoints", showPoints() ? "true" : "false");
    series.setAttribute("showLines", showLines() ? "true" : "false");

    int lineStyle = getLineStyle();

    switch (lineStyle) {
    case (DASHED):
        series.setAttribute("lineStyle", "dashed");
        break;//  w w w .j a v  a2  s.  c  o m
    case (DOT_DASHED):
        series.setAttribute("lineStyle", "dotDashed");
        break;
    default:
        series.setAttribute("lineStyle", "normal");
    }

    int seriesShape = getSeriesShape();

    switch (seriesShape) {
    case (CIRCLE):
        series.setAttribute("seriesShape", "circle");
        break;
    case (SQUARE):
        series.setAttribute("seriesShape", "square");
        break;
    case (TRIANGLE):
        series.setAttribute("seriesShape", "triangle");
        break;
    case (RECTANGLE_H):
        series.setAttribute("seriesShape", "rectangle_h");
        break;
    case (RECTANGLE_V):
        series.setAttribute("seriesShape", "rectangle_v");
        break;
    default:
        series.setAttribute("seriesShape", "none");
    }
}

From source file:com.kurento.kmf.test.client.BrowserClient.java

public boolean colorSimilarTo(Color expectedColor) {
    String[] realColor = driver.findElement(By.id("color")).getAttribute("value").split(",");
    int red = Integer.parseInt(realColor[0]);
    int green = Integer.parseInt(realColor[1]);
    int blue = Integer.parseInt(realColor[2]);

    double distance = Math.sqrt((red - expectedColor.getRed()) * (red - expectedColor.getRed())
            + (green - expectedColor.getGreen()) * (green - expectedColor.getGreen())
            + (blue - expectedColor.getBlue()) * (blue - expectedColor.getBlue()));

    log.info("Color comparision: real {}, expected {}, distance {}", realColor, expectedColor, distance);

    return distance <= getMaxDistance();
}

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

private void configureSolidAreaFill(Graphics2D g2, Paint itemPaint, SolidLineAreaFill solidLineAreaFill) {
    double transparency = solidLineAreaFill.getTransparency();

    if (itemPaint instanceof Color) {
        Color itemColor = (Color) itemPaint;
        int alpha = transparency >= 0.0 && transparency <= 1.0 ? Math.round(255 * (float) transparency) : 255;
        g2.setPaint(new Color(itemColor.getRed(), itemColor.getGreen(), itemColor.getBlue(), alpha));
    } else {/*from   w  w  w  .j a  va2  s  .  c o  m*/
        g2.setPaint(itemPaint);
    }
}

From source file:bwem.example.MapPrinterExample.java

private Color getZoneColor(Area area, java.util.Map<Integer, Color> mapZoneColor) {
    final int zoneId = mapPrinter.showAreas ? area.getId().intValue() : area.getGroupId().intValue();
    Color color = mapZoneColor.get(zoneId);
    if (color == null) { // zoneId was not find --> insertion did occur --> we have do define the new color:
        int tries = 0;
        do {//  w  ww.j  a v a2  s  .  c  om
            color = new Color(this.randomGenerator.nextInt(256), this.randomGenerator.nextInt(256), 0); // blue unused for Terrain so that Water can be easily distinguished.
            if (++tries > 100)
                break;
        } while (
        // 1) color should not be too dark
        (color.getRed() + color.getGreen() < 150) ||

        // 2) color should differ enough from the colors of the neighboring areas
                (mapPrinter.showAreas
                        && getZoneColorCppAlgorithmAnyOf(area.getChokePointsByArea(), mapZoneColor, color)));
        mapZoneColor.put(zoneId, color);
    }

    return color;
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.AngularHistogramRenderer.java

@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {

    // compute the right color for the paint
    int length = GuiUtils.getAvailableColors().length;
    Color color = GuiUtils.getAvailableColors()[index % length];
    // get all the data points
    int numPoints = dataset.getItemCount(seriesIndex);

    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i); // the angle at the center         
        double radius = dataset.getYValue(seriesIndex, i); // the frequency

        Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea);
        Point p1 = plot.translateToJava2D(theta - binSize, radius, plot.getAxis(), dataArea);
        Point p2 = plot.translateToJava2D(theta + binSize, radius, plot.getAxis(), dataArea);

        Polygon poly = new Polygon(new int[] { p0.x, p1.x, p2.x }, new int[] { p0.y, p1.y, p2.y }, 3);

        g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));
        g2.fill(poly);//w w w.  j  a v  a 2s  . c  o  m
    }
}

From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java

/**
 * Returns the paint used to fill data items as they are drawn.
 * <p/>//w ww .  ja  v  a2s .co m
 * The default implementation passes control to the
 * <code>lookupSeriesPaint()</code> method. You can override this method
 * if you require different behaviour.
 *
 * @param row    the row (or series) index (zero-based).
 * @param column the column (or category) index (zero-based).
 * @return The paint (never <code>null</code>).
 */
@Override
public Paint getItemPaint(int row, int column) {
    Color paint = dataset.getColor(row, column);

    if (paint == null) {
        paint = DEFAULT_COLOR;
    }

    if (shouldHighlight(row, column)) {
        return new Color(paint.getRed(), paint.getGreen(), paint.getBlue(), 255);
    }

    return new Color(paint.getRed(), paint.getGreen(), paint.getBlue(), 127);
}

From source file:com.jaspersoft.studio.property.color.chooser.AdvancedColorWidget.java

/**
 * Read the color under the mouse position and set it as the current color. This 
 * is done only if JSS or one of its components are focused. It is necessary to control
 * this dialog and its content because it modal, so every other component of JSS can not be focused
 *///  ww w  .j a v  a 2s .co  m
private void checkColorPicker() {
    if (!isDisposed() && (getShell().isFocusControl() || checkControlFocused(getShell().getChildren()))) {
        Robot robot;
        try {
            robot = new Robot();
            Point pos = Display.getCurrent().getCursorLocation();
            java.awt.Color color = robot.getPixelColor(pos.x, pos.y);
            RGB rgbColor = new RGB(color.getRed(), color.getGreen(), color.getBlue());
            colorsSelector.setSelectedColor(rgbColor, false);
            updateText(rgbColor, rgbColor.getHSB(), null);
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.mrgeo.colorscale.ColorScale.java

/**
 * Interpolate the color value for the given scalar value. The result is placed in color.
 *
 * @param v/*from  w  ww.j a  v  a  2  s.co m*/
 * @param color
 * @return
 */
final private void interpolateValue(final double v, final int[] color) {
    final double search;
    switch (scaling) {
    case Absolute:
        search = v;
        break;
    case MinMax:
        search = (v - min) / (max - min);
        break;
    case Modulo:
        search = (v - min) % (max - min);
        break;
    default:
        search = 0;
        break;
    }

    final Map.Entry<Double, Color> lower = floorEntry(search);
    final Map.Entry<Double, Color> upper = higherEntry(search);

    assert (upper != null || lower != null);

    if (upper == null) {
        final Color c = lower.getValue();
        color[R] = c.getRed();
        color[G] = c.getGreen();
        color[B] = c.getBlue();
        color[A] = c.getAlpha();
    } else if (lower == null) {
        final Color c = upper.getValue();
        color[R] = c.getRed();
        color[G] = c.getGreen();
        color[B] = c.getBlue();
        color[A] = c.getAlpha();
    } else {
        final double diff = upper.getKey().doubleValue() - lower.getKey().doubleValue();
        final double lw = 1.0 - ((search - lower.getKey().doubleValue()) / diff);
        final double uw = 1.0 - lw;

        final Color lc = lower.getValue();
        final Color uc = upper.getValue();
        color[R] = (int) Math.round(lc.getRed() * lw + uc.getRed() * uw);
        color[G] = (int) Math.round(lc.getGreen() * lw + uc.getGreen() * uw);
        color[B] = (int) Math.round(lc.getBlue() * lw + uc.getBlue() * uw);
        color[A] = (int) Math.round(lc.getAlpha() * lw + uc.getAlpha() * uw);
    }
}

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

protected void updateTime(String time, int millis) {
    if (isVisible()) {
        jLabel1.setText(time);//  w  w w .ja  v a 2  s  .c om
        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:TableDialogEditDemo.java

public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Color newColor = (Color) color;
    setBackground(newColor);/*from w w w.  j  a va 2s  .c  om*/
    if (isBordered) {
        if (isSelected) {
            if (selectedBorder == null) {
                selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
            }
            setBorder(selectedBorder);
        } else {
            if (unselectedBorder == null) {
                unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
            }
            setBorder(unselectedBorder);
        }
    }

    setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
    return this;
}