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:playground.sergioo.workplaceCapacities2012.gui.ClustersPanel.java

public ClustersPanel(ClustersWindow window, List<CentroidCluster<PointPerson>> clusters) {
    super();/*  www . java  2s. c  o  m*/
    this.window = window;
    addLayer(new Layer(new AxisPainter(24 * 3600, 18 * 3600, 0, 6 * 3600, 3600, 3600, Color.DARK_GRAY)));
    PointsPainter pointsPainter = new PointsPainter();
    float i = 0;
    for (org.apache.commons.math3.ml.clustering.Cluster<PointPerson> cluster : clusters) {
        //Color color = new Color((float)(Math.random()*0.5), (float)(Math.random()*0.5), (float)(Math.random()*0.5), 0.3f);
        float p = (i + 0.5f) / clusters.size();
        Color color = JetColor.getJetColor(p);
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);
        PointsPersonPainter ppPainter = new PointsPersonPainter(color);
        ppPainter.setWeightedPoints(cluster.getPoints());
        addLayer(new Layer(ppPainter));
        PointPerson center = cluster.getPoints().get(0).centroidOf(cluster.getPoints());
        pointsPainter.addPoint(new CoordImpl(center.getElement(0), center.getElement(1)));
        i++;
    }
    addLayer(new Layer(pointsPainter));
    this.setBackground(Color.WHITE);
    calculateBoundaries();
    super.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize().width,
            Toolkit.getDefaultToolkit().getScreenSize().height);
    addMouseListener(this);
    addMouseMotionListener(this);
    addMouseWheelListener(this);
    addKeyListener(this);
    setFocusable(true);
}

From source file:util.program.ProgramTextCreator.java

private static String addSearchLink(String topic, String displayText) {
    Color foreground = Color.black;//Settings.propProgramPanelForegroundColor.getColor();

    String style = " style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + ","
            + foreground.getBlue() + "); border-bottom: 1px dashed;\"";
    StringBuilder buffer = new StringBuilder(32);
    buffer.append("<a href=\"");
    buffer.append(TVBROWSER_URL_PROTOCOL);
    buffer.append(StringUtils.remove(StringUtils.remove(topic, '"'), '\''));

    buffer.append("\" ");
    buffer.append(style);/*from ww w  .  j av a2s  .  c  om*/
    buffer.append('>');
    buffer.append(displayText);
    buffer.append("</a>");
    return buffer.toString();
}

From source file:org.emonocot.portal.view.Functions.java

private static Map<String, String> getColorMap(Set<String> categories) {
    int numberOfCategories = categories.size();
    float increment = 0.5f / (numberOfCategories / 5);
    Map<String, String> colorMap = new HashMap<String, String>();

    int i = 0;/*from w  w  w.  j  a  v  a 2  s.c o  m*/
    for (String category : categories) {
        Color baseColor = baseColors[i % 5];
        int offset = i / 5;
        if (offset > 0) {
            float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(),
                    null);
            Color highlight = Color.getHSBColor(hsbVals[0], hsbVals[1], offset * increment * (1f + hsbVals[2]));
            colorMap.put(category, String.format("#%06X", (0xFFFFFF & highlight.getRGB())));
        } else {
            colorMap.put(category, String.format("#%06X", (0xFFFFFF & baseColor.getRGB())));
        }
        i++;
    }

    return colorMap;
}

From source file:de.tor.tribes.ui.renderer.ColoredCoutdownCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    try {/*from  w  w w  .  ja  v  a  2  s  .co m*/
        JLabel renderComponent = ((JLabel) c);
        Long d = (Long) value;

        // renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true));

        long diff = d;
        long five_minutes = 5 * MINUTE;
        long ten_minutes = 10 * MINUTE;
        Color color = null;
        if (row % 2 == 0) {
            color = Constants.DS_ROW_A;
        } else {
            color = Constants.DS_ROW_B;
        }

        if (diff <= 0) {
            //value is expired, stroke result
            //renderComponent.setText(specialFormat.format(d));
            //renderComponent.setForeground(Color.RED);
        } else if (diff <= ten_minutes && diff > five_minutes) {
            float ratio = (float) (diff - five_minutes) / (float) five_minutes;
            Color c1 = Color.YELLOW;
            Color c2 = Color.GREEN;
            int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
            int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
            int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
            color = new Color(red, green, blue);
        } else if (diff <= five_minutes) {
            float ratio = (float) diff / (float) five_minutes;
            Color c1 = Color.RED;
            Color c2 = Color.YELLOW;
            int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
            int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
            int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
            color = new Color(red, green, blue);
        }
        renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true));
        if (isSelected) {
            color = c.getBackground();
        }
        renderComponent.setOpaque(true);
        renderComponent.setBackground(color);
        return renderComponent;
    } catch (Exception e) {
        return c;
    }
}

From source file:main.java.whiteSocket.Bloop.java

private static int getBrightnessThreshold() {
    /**//  w ww . j  av  a2 s  .com
     * get average pixel brightness of white pixels whiteboard input image
     * NOTE: lower brightness value = darker the pixel
     * using relative luminance
     * https://en.wikipedia.org/wiki/Relative_luminance
     * 
     * rough threshold value = 30% less than average of darkest corner
     * assumes average corner spans 60% brightness (+/-30%)
     */

    Color color = null;
    float brightness = 0;
    int r, g, b;
    int count = 0;
    int avg_UL, avg_UR, avg_LL, avg_LR;
    float totalBrightness = 0;

    for (int row = 0; row < 10; row++) { //   UL
        for (int col = 0; col < 10; col++) {
            count++;
            color = new Color(sketch.getRGB(col, row));
            r = color.getRed();
            g = color.getGreen();
            b = color.getBlue();
            brightness = (float) (0.2126 * r + 0.7152 * g + 0.0722 * b);
            totalBrightness += brightness;
        }
    }
    avg_UL = (int) (totalBrightness / count);

    totalBrightness = 0;
    count = 0;
    for (int row = 0; row < 10; row++) { //  UR
        for (int col = sketch.getWidth() - 10; col < sketch.getWidth(); col++) {
            count++;
            color = new Color(sketch.getRGB(col, row));
            r = color.getRed();
            g = color.getGreen();
            b = color.getBlue();
            brightness = (float) (0.2126 * r + 0.7152 * g + 0.0722 * b);
            totalBrightness += brightness;
        }
    }
    avg_UR = (int) (totalBrightness / count);

    totalBrightness = 0;
    count = 0;
    for (int row = sketch.getHeight() - 10; row < sketch.getHeight(); row++) { //   LL
        for (int col = 0; col < 10; col++) {
            count++;
            color = new Color(sketch.getRGB(col, row));
            r = color.getRed();
            g = color.getGreen();
            b = color.getBlue();
            brightness = (float) (0.2126 * r + 0.7152 * g + 0.0722 * b);
            totalBrightness += brightness;
        }
    }
    avg_LL = (int) (totalBrightness / count);

    totalBrightness = 0;
    count = 0;
    for (int row = sketch.getHeight() - 10; row < sketch.getHeight(); row++) { //   LR
        for (int col = sketch.getWidth() - 10; col < sketch.getWidth(); col++) {
            count++;
            color = new Color(sketch.getRGB(col, row));
            r = color.getRed();
            g = color.getGreen();
            b = color.getBlue();
            brightness = (float) (0.2126 * r + 0.7152 * g + 0.0722 * b);
            totalBrightness += brightness;
        }
    }
    avg_LR = (int) (totalBrightness / count);

    int threshold = (int) (0.7 * Math.min(Math.min(avg_LL, avg_LR), Math.min(avg_UL, avg_UR)));

    //      System.out.println("\nthreshold = "+threshold);

    return threshold;
}

From source file:net.wastl.rdfdot.base.GraphvizSerializerBase.java

protected String graphvizColor(Color c) {
    return String.format("\"#%02x%02x%02x\"", c.getRed(), c.getGreen(), c.getBlue());
}

From source file:net.sourceforge.processdash.ev.ui.chart.RangeXYItemRenderer.java

private Color transp(Color c, double alpha) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255 * alpha));
}

From source file:com.mebigfatguy.polycasso.JavaSaver.java

private String getColorData(PolygonData[] data) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    String comma = "";
    for (PolygonData pd : data) {

        pw.println(comma);/*from ww  w  .  j av  a2 s  .co  m*/
        pw.print(TABS);
        pw.print("{");

        Color color = pd.getColor();
        pw.print(color.getRed());
        pw.print(",");
        pw.print(color.getGreen());
        pw.print(",");
        pw.print(color.getBlue());
        pw.print("}");
        comma = ",";
    }

    pw.flush();
    return sw.toString();
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotPanel.java

public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
        ParameterSet parameters) {//from   ww  w  . j  av a2 s.co m
    super(null);

    boolean createLegend = false;
    if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20))
        createLegend = true;

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, createLegend, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new ProjectionPlotRenderer(plot, dataset);
    itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
    plot.setRenderer(spotRenderer);

    // Setup legend
    if (createLegend) {
        LegendItemCollection legendItemsCollection = new LegendItemCollection();
        for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
            Object paramValue = dataset.getGroupParameterValue(groupNumber);
            if (paramValue == null) {
                // No parameter value available: search for raw data files
                // within this group, and use their names as group's name
                String fileNames = new String();
                for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
                    String rawDataFile = dataset.getRawDataFile(itemNumber);
                    if (dataset.getGroupNumber(itemNumber) == groupNumber)
                        fileNames = fileNames.concat(rawDataFile);
                }
                if (fileNames.length() == 0)
                    fileNames = "Empty group";

                paramValue = fileNames;
            }
            Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
            Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
                    (int) Math.round(255 * dataPointAlpha));
            legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
                    spotRenderer.getDataPointsShape(), groupColor));
        }
        plot.setFixedLegendItems(legendItemsCollection);
    }

}

From source file:edu.ku.brc.ui.GradiantButton.java

/**
 * Sests the text Color/*from   w  w w .  j a  va  2 s.  c  om*/
 * @param textColor text color
 */
public void setTextColor(Color textColor) {
    this.textColor = textColor;
    textColorShadow = new Color(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), 70);
}