List of usage examples for java.awt Color getRed
public int getRed()
From source file:guineu.modules.visualization.intensityboxplot.IntensityBoxPlotDrawingSupplier.java
public Paint getNextPaint() { // get new color from the default supplier Color baseColor = (Color) super.getNextPaint(); // ban colors that are too bright int colorSum = baseColor.getRed() + baseColor.getGreen() + baseColor.getBlue(); if (colorSum > 520) baseColor = baseColor.darker();/*from w w w . j a v a 2 s . co m*/ return baseColor; }
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 ww. j av a2 s .c om*/ 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:pdi.HistogramaRGB.java
public int[] pegaPixels(File file) { BufferedImage img = pegaImagem(); int[] rgb = new int[w * h]; for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) { rgb[i * j] = img.getRGB(i, j); }//from w w w . ja v a2s .co m for (int i = 0; i < rgb.length; i++) { Color c = new Color(rgb[i]); System.out.println("Vermelho: " + c.getRed()); } for (int i = 0; i < rgb.length; i++) { Color c = new Color(rgb[i]); System.out.println("Vermelho: " + c.getGreen()); } for (int i = 0; i < rgb.length; i++) { Color c = new Color(rgb[i]); System.out.println("Vermelho: " + c.getBlue()); } return rgb; }
From source file:lisong_mechlab.view.graphs.WeaponColouredDrawingSupplier.java
private Color colorShift(Color aColour, int aMax, int aCurr) { float hsb[] = new float[3]; Color.RGBtoHSB(aColour.getRed(), aColour.getGreen(), aColour.getBlue(), hsb); float blend = aMax == 1 ? 1.0f : (float) aCurr / (aMax - 1); float range_min = 0.55f; float range_max = 1.0f; float saturation = (range_max - range_min) * blend + range_min; hsb[1] *= saturation;/* www. jav a2 s . c o m*/ hsb[2] *= saturation; return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); }
From source file:org.xwiki.properties.internal.converter.ColorConverter.java
@Override protected String convertToString(Color value) { Color colorValue = value; return MessageFormat.format("{0}, {1}, {2}", colorValue.getRed(), colorValue.getGreen(), colorValue.getBlue());/*w ww . j a v a 2 s .c om*/ }
From source file:org.pentaho.ui.xul.swt.tags.SwtBox.java
public void setBgcolor(String bgcolor) { this.bgcolor = bgcolor; Color c = Color.decode(bgcolor); box.setBackground(//from w w w. j a v a2s . co m new org.eclipse.swt.graphics.Color(box.getDisplay(), c.getRed(), c.getGreen(), c.getBlue())); box.setBackgroundMode(SWT.INHERIT_DEFAULT); }
From source file:net.sourceforge.entrainer.socket.FlashColour.java
/** * Sets the color./* w ww. j a v a 2 s .c om*/ * * @param c * the new color */ @JsonIgnore public void setColor(Color c) { if (c == null) return; setRed(c.getRed()); setGreen(c.getGreen()); setBlue(c.getBlue()); setAlpha(c.getAlpha()); }
From source file:ColorBlocks.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension d = getSize();//from w ww . j a v a 2s . com g2.translate(d.width / 2, d.height / 2); Color[] colors = { Color.white, Color.lightGray, Color.gray, Color.darkGray, Color.black, Color.red, Color.pink, Color.orange, Color.yellow, Color.green, Color.magenta, Color.cyan, Color.blue }; float size = 25; float x = -size * colors.length / 2; float y = -size * 3 / 2; // Show all the predefined colors. for (int i = 0; i < colors.length; i++) { Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(colors[i]); g2.fill(r); } //a linear gradient. y += size; Color c1 = Color.yellow; Color c2 = Color.blue; for (int i = 0; i < colors.length; i++) { float ratio = (float) i / (float) colors.length; 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 c = new Color(red, green, blue); Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(c); g2.fill(r); } // Show an alpha gradient. y += size; c1 = Color.red; for (int i = 0; i < colors.length; i++) { int alpha = (int) (255 * (float) i / (float) colors.length); Color c = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), alpha); Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(c); g2.fill(r); } // Draw a frame around the whole thing. y -= size * 2; Rectangle2D frame = new Rectangle2D.Float(x, y, size * colors.length, size * 3); g2.setPaint(Color.black); g2.draw(frame); }
From source file:savant.settings.PersistentSettings.java
public void setColour(String key, Color value) { setProperty(key, String.format("%02X%02X%02X%02X", value.getRed(), value.getGreen(), value.getBlue(), value.getAlpha()));/*from w w w .j a va 2s . com*/ }
From source file:com.gargoylesoftware.htmlunit.javascript.host.canvas.rendering.AwtRenderingBackend.java
/** * {@inheritDoc}// ww w . j a va 2 s . c o m */ public byte[] getBytes(final int width, final int height, final int sx, final int sy) { final byte[] array = new byte[width * height * 4]; int index = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { final Color c = new Color(image_.getRGB(sx + x, sy + y), true); array[index++] = (byte) c.getRed(); array[index++] = (byte) c.getGreen(); array[index++] = (byte) c.getBlue(); array[index++] = (byte) c.getAlpha(); } } return array; }