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.kalypso.model.wspm.pdb.wspm.CheckoutRoughnessUpdater.java

private void updateColor() {
    final String colorAsString = m_roughness.getColor();
    if (StringUtils.isEmpty(colorAsString))
        return;/* www  .  java  2 s. co  m*/
    final Color color = Color.decode(colorAsString);
    final RGB oldRGB = m_roughnessClass.getColor();
    final Color oldColor = new Color(oldRGB.red, oldRGB.green, oldRGB.blue);
    if (ObjectUtils.equals(color, oldColor))
        return;

    final RGB newRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue());
    m_roughnessClass.setColor(newRGB);
    m_changed = true;
}

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

private double calcAlpha(Color c) {
    // convert the color to a black-and-white value.  0=black, 1=white
    double gray = (0.30 * c.getRed() + 0.59 * c.getGreen() + 0.11 * c.getBlue()) / 255;
    // the brighter the color, the higher an alpha value we need.
    // (keep bright colors from disappearing into the white background)
    // the darker the color, the lower an alpha value we need.
    // (keep dark colors from hiding the trend line)
    double result = 0.85 * 0.123 / (1 - gray);
    if (result < 0.3)
        return 0.3;
    if (result > 0.8)
        return 0.8;
    return result;
}

From source file:jmemorize.gui.swing.panels.CardCounterPanel.java

private ExtentProgressBar buildExtentProgressBar() {
    ExtentProgressBar bar = new ExtentProgressBar();

    bar.setForeground(Color.BLUE);
    Color grn = Color.GREEN.darker();
    Color transparentGreen = new Color(grn.getRed(), grn.getGreen(), grn.getBlue(), 128);
    bar.setExtentForeground(transparentGreen);
    bar.setExtent(0);/*w w w  . j  av  a  2s  .c om*/

    return bar;
}

From source file:ColorGradient.java

/**
 * Draw a color gradient from the top of the specified component to the
 * bottom. Start with the start color and change smoothly to the end
 *///  w  w w  .  j  a  v a2s . c  o  m
public void fillGradient(Component c, Graphics g, Color start, Color end) {
    Rectangle bounds = this.getBounds(); // How big is the component?
    // Get the red, green, and blue components of the start and end
    // colors as floats between 0.0 and 1.0. Note that the Color class
    // also works with int values between 0 and 255
    float r1 = start.getRed() / 255.0f;
    float g1 = start.getGreen() / 255.0f;
    float b1 = start.getBlue() / 255.0f;
    float r2 = end.getRed() / 255.0f;
    float g2 = end.getGreen() / 255.0f;
    float b2 = end.getBlue() / 255.0f;
    // Figure out how much each component should change at each y value
    float dr = (r2 - r1) / bounds.height;
    float dg = (g2 - g1) / bounds.height;
    float db = (b2 - b1) / bounds.height;

    // Now loop once for each row of pixels in the component
    for (int y = 0; y < bounds.height; y++) {
        g.setColor(new Color(r1, g1, b1)); // Set the color of the row
        g.drawLine(0, y, bounds.width - 1, y); // Draw the row
        r1 += dr;
        g1 += dg;
        b1 += db; // Increment color components
    }
}

From source file:de.brendamour.jpasskit.PKPass.java

protected String convertColorToString(final Color color) {
    if (color != null) {
        return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
    }/*  w ww  .  j a v a  2  s. co m*/
    return null;
}

From source file:org.kalypso.model.wspm.pdb.wspm.CheckoutVegetationUpdater.java

private void updateColor() {

    final String colorAsString = m_vegetation.getColor();
    if (StringUtils.isEmpty(colorAsString))
        return;//w  w  w .  ja va  2 s  . com
    final Color color = Color.decode(colorAsString);
    final RGB oldRGB = m_vegetationClass.getColor();
    final Color oldColor = new Color(oldRGB.red, oldRGB.green, oldRGB.blue);
    if (ObjectUtils.equals(color, oldColor))
        return;

    final RGB newRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue());
    m_vegetationClass.setColor(newRGB);
    m_changed = true;
}

From source file:haven.Utils.java

public static float[] c2fa(Color c) {
    return (new float[] { ((float) c.getRed() / 255.0f), ((float) c.getGreen() / 255.0f),
            ((float) c.getBlue() / 255.0f), ((float) c.getAlpha() / 255.0f) });
}

From source file:Main.java

public Main() {
    for (int i = 0; i < panels.length; i++) {
        final String[] labels = new String[] { "0", "1" };
        final Random rand = new Random();
        int index = rand.nextInt(labels.length);
        String randomTitle = labels[index];
        final JLabel label = new JLabel(randomTitle, JLabel.CENTER);
        Timer lblt = new Timer(00, new ActionListener() {
            @Override/*from  w w w  .  j a  va2  s.c o  m*/
            public void actionPerformed(ActionEvent ae) {
                label.setText(labels[rand.nextInt(labels.length)]);
            }
        });
        lblt.setRepeats(true);
        lblt.start();
        label.setForeground(Color.green);
        label.setVerticalAlignment(JLabel.CENTER);
        panels[i] = new JPanel();
        panels[i].setBackground(Color.BLACK);
        panels[i].add(label);
        frame.getContentPane().add(panels[i]);
    }
    frame.setLayout(new GridLayout(grid, grid));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
    frame.setVisible(true);

    ActionListener action = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < panels.length; i++) {
                Color mix = new Color(255, 255, 255);
                Random random = new Random();
                int r = random.nextInt(255);
                int g = random.nextInt(255);
                int b = random.nextInt(255);

                if (mix != null) {
                    r = (r + mix.getRed()) / 2;
                    g = (g + mix.getGreen()) / 2;
                    b = (b + mix.getBlue()) / 2;
                }
                Color color = new Color(r, g, b);
                panels[i].setBackground(color);
            }
        }
    };

    t = new Timer(00, action);
    t.setRepeats(true);
    t.start();
}

From source file:com.peadargrant.filecheck.web.controllers.CheckController.java

@RequestMapping(method = RequestMethod.POST)
public String performCheck(@RequestParam(value = "assignment", required = true) String assignmentCode,
        @RequestParam("file") MultipartFile file, ModelMap model) throws Exception {

    String assignmentsUrl = serverEnvironment.getPropertyAsString("assignmentsUrl");
    model.addAttribute("assignmentsUrl", assignmentsUrl);

    // bail out if the file is empty
    if (file.isEmpty()) {
        model.addAttribute("message", "file.was.empty");
        return "error";
    }//  w w  w. ja v  a2s. c  o m

    // input stream from file 
    byte[] bytes = file.getBytes();
    String name = file.getOriginalFilename();

    // write to temp dir
    String filePath = System.getProperty("java.io.tmpdir") + "/" + name;
    BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
    stream.write(bytes);
    stream.close();

    // load file
    File inputFile = new File(filePath);

    // get assignment
    Assignment assignment = this.getAssignmentForCode(assignmentCode);
    if (assignment == null) {
        return "assignmentNotFound";
    }
    model.addAttribute(assignment);

    // GUI report table model
    SummaryTableModel summaryTableModel = new SummaryTableModel();
    ReportTableModel reportTableModel = new ReportTableModel(summaryTableModel);

    // checker
    Checker checker = new Checker();
    checker.setReport(reportTableModel);
    checker.runChecks(inputFile, assignment);

    // details for output
    model.addAttribute("fileName", name);
    model.addAttribute("startTime", new java.util.Date());
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }
    model.addAttribute("remoteIP", ipAddress);

    // final outcome
    model.addAttribute("outcome", summaryTableModel.getFinalOutcome());
    Color finalOutcomeColor = summaryTableModel.getFinalOutcome().getSaturatedColor();
    model.addAttribute("colourr", finalOutcomeColor.getRed());
    model.addAttribute("colourg", finalOutcomeColor.getGreen());
    model.addAttribute("colourb", finalOutcomeColor.getBlue());

    // transformer for parsing tables
    FileCheckWebTableTransformer transformer = new FileCheckWebTableTransformer();

    // summary table headings
    List<String> summaryColumns = transformer.getColumnHeaders(summaryTableModel);
    model.addAttribute("summaryColumns", summaryColumns);

    // summary table
    List summaryContents = transformer.getTableContents(summaryTableModel);
    model.addAttribute("summary", summaryContents);

    // detail table headings
    List<String> detailColumns = transformer.getColumnHeaders(reportTableModel);
    model.addAttribute("detailColumns", detailColumns);

    // detail report table
    List detailContents = transformer.getTableContents(reportTableModel);
    model.addAttribute("detail", detailContents);

    // delete the uploaded file
    inputFile.delete();

    // Return results display
    return "check";
}

From source file:org.polymap.core.mapeditor.tooling.edit.VectorLayerStyler.java

/**
 * Calculates styles for {@link #hover} and {@link #select} intent based on the
 * {@link #standard} style. Override in order to change the standard behaviour.
 *///from w  w w  .j a v a  2s  .c o m
protected void calculateHoverSelectStyle() {
    hover = Maps.newHashMap(standard);
    RGB rgb = (RGB) standard.get("strokeColor");

    // just brighter
    //        Color c = new Color( rgb.red, rgb.green, rgb.blue ).brighter().brighter().brighter();

    // gray
    //        int gray = (int)((0.299 * rgb.red) + (0.587 * rgb.green) + (0.114 * rgb.blue));
    //        Color c = new Color( gray, gray, gray ).brighter();

    HSLColor hsl = new HSLColor(new Color(rgb.red, rgb.green, rgb.blue));
    Color c = hsl.adjustShade(40).adjustSaturation(100).toRGB();

    // hover
    hover.put("strokeColor", new RGB(c.getRed(), c.getGreen(), c.getBlue()));
    hover.put("strokeDashstyle", "solid");
    Number strokeWidth = (Number) hover.get("strokeWidth");
    hover.put("strokeWidth", strokeWidth);
    hover.put("fillOpacity", 0.25);

    //        hsl = new HSLColor( new Color( rgb.red, rgb.green, rgb.blue ) );
    //        c = hsl.adjustHue( 180 ).adjustShade( 10 ).toRGB();

    // select
    select = Maps.newHashMap(standard);
    select.put("strokeColor", new RGB(c.getRed(), c.getGreen(), c.getBlue()));
    select.put("strokeDashstyle", "solid");
    strokeWidth = (Number) select.get("strokeWidth");
    select.put("strokeWidth", strokeWidth);
    select.put("fillOpacity", 0.20);
}