List of usage examples for java.awt Color getBlue
public int getBlue()
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
protected static final LookupPaintScale createLUT(final int ncol, final float vmin, final float vmax, final Color start, final Color med, final Color end) { final float[][] colors = new float[][] { { start.getRed() / 255f, start.getGreen() / 255f, start.getBlue() / 255f, start.getAlpha() / 255f }, { med.getRed() / 255f, med.getGreen() / 255f, med.getBlue() / 255f, med.getAlpha() / 255f }, { end.getRed() / 255f, end.getGreen() / 255f, end.getBlue() / 255f, end.getAlpha() / 255f } }; final float[] limits = new float[] { 0, 0.5f, 1 }; final LookupPaintScale lut = new LookupPaintScale(vmin, vmax, med); float val; float r, g, b, a; for (int j = 0; j < ncol; j++) { val = j / (ncol - 0.99f); int i = 0; for (i = 0; i < limits.length; i++) { if (val < limits[i]) { break; }//from w w w.j a v a 2 s .c o m } i = i - 1; r = colors[i][0] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][0] - colors[i][0]); g = colors[i][1] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][1] - colors[i][1]); b = colors[i][2] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][2] - colors[i][2]); a = colors[i][3] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][3] - colors[i][3]); lut.add(val * (vmax - vmin) + vmin, new Color(r, g, b, a)); } return lut; }
From source file:org.polymap.rhei.batik.engine.svg.Svg2Png.java
private static float[] replaceColors(ImageConfiguration imageConfiguration, Color color, final float[] currentHsb) { float[] hsb;//from www . j a va 2s.c o m Optional<ReplaceConfiguration> config = imageConfiguration.getReplaceConfigurations().stream() .filter(rc -> rc.getFrom() != null && rc.getTo() != null && rc.getFrom().red == color.getRed() && rc.getFrom().green == color.getGreen() && rc.getFrom().blue == color.getBlue()) .findFirst(); if (config.isPresent()) { hsb = config.get().getTo().getHSB(); hsb[0] = degreeToPercent(hsb[0]); } else { hsb = currentHsb; } return hsb; }
From source file:net.sf.jabref.gui.maintable.MainTable.java
private static Color mixColors(Color one, Color two) { return new Color((one.getRed() + two.getRed()) / 2, (one.getGreen() + two.getGreen()) / 2, (one.getBlue() + two.getBlue()) / 2); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithHeatMap.java
protected static void addValuesToPaintScale(LookupPaintScale paintScale, double lowerBound, double upperBound, Color lowColor, Color highColor) { int distinctValues = DISTINCT_PALETTE_VALUES; if (upperBound <= lowerBound) upperBound = lowerBound + .0001; double increment = (upperBound - lowerBound) / distinctValues; int redDiff = highColor.getRed() - lowColor.getRed(); int greenDiff = highColor.getGreen() - lowColor.getGreen(); int blueDiff = highColor.getBlue() - lowColor.getBlue(); double redIncrement = (redDiff / distinctValues); double greenIncrement = (greenDiff / distinctValues); double blueIncrement = (blueDiff / distinctValues); _log.debug("Palette: "); for (int i = 0; i < distinctValues; i++) { int r = (int) (lowColor.getRed() + (i * redIncrement)); int g = (int) (lowColor.getGreen() + (i * greenIncrement)); int b = (int) (lowColor.getBlue() + (i * blueIncrement)); Color incrementColor = new Color(r, g, b); double incrementStart = lowerBound + (i * increment); paintScale.add(incrementStart, incrementColor); _log.debug("\t" + incrementStart + "-" + (incrementStart + increment) + ": " + incrementColor); }/* ww w .j av a2 s. c o m*/ }
From source file:ala.soils2sat.DrawingUtils.java
public static Color generateRandomColor(Color mix) { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); // mix the color if (mix != null) { red = (red + mix.getRed()) / 2;//from w w w .j a v a 2s . c om green = (green + mix.getGreen()) / 2; blue = (blue + mix.getBlue()) / 2; } Color color = new Color(red, green, blue); return color; }
From source file:com.t_oster.visicut.misc.Helper.java
public static String toHtmlRGB(Color col) { String r = Integer.toHexString(col.getRed()); String g = Integer.toHexString(col.getGreen()); String b = Integer.toHexString(col.getBlue()); return "#" + (r.length() == 1 ? "0" + r : r) + (g.length() == 1 ? "0" + g : g) + (b.length() == 1 ? "0" + b : b); }
From source file:net.sf.firemox.tools.Picture.java
/** * Return the border color of this card. If the picture of this card is not * <code>null</code> the returned color corresponds to the pixel placed on * the topmost leftmost pixel./*from w ww . j ava2s . co m*/ * * @return the border color of this card. */ private static Color getBorderColor(BufferedImage image) { Color borderColor; // The border color is not yet cached if (CardFactory.borderColor != null) { // manual border borderColor = CardFactory.borderColor; } else { // auto border if (image != null) { borderColor = new Color(image.getRGB(0, 0)); if (borderColor.getRed() > 175 && borderColor.getGreen() > 175 && borderColor.getBlue() > 175) { borderColor = Color.WHITE.darker(); } else { borderColor = Color.BLACK.brighter(); } } else { borderColor = CardFactory.borderColor; } } return borderColor; }
From source file:org.kalypso.kalypsosimulationmodel.utils.SLDHelper.java
/** * if lightestColor is null, than WHITE (0, 0, 0) is used instead *///from ww w .j a v a 2s .c o m private static StyledLayerDescriptor createRasterSLD(final double minValue, final double maxValue, final int numberOfIntervals, final Color lightestColor, final Color darkestColor, final String styleName, final String styleTitle, final IProgressMonitor monitor) throws CoreException { final TreeMap<Double, ColorMapEntry> colorMap = new TreeMap<>(); final FeatureTypeStyle style = StyleFactory.createFeatureTypeStyle(); final int rd = darkestColor.getRed(); final int gd = darkestColor.getGreen(); final int bd = darkestColor.getBlue(); final int rl = lightestColor == null ? 0 : lightestColor.getRed(); final int gl = lightestColor == null ? 0 : lightestColor.getGreen(); final int bl = lightestColor == null ? 0 : lightestColor.getBlue(); for (int i = 0; i <= numberOfIntervals; i++) { final double ratio = (double) i / (double) numberOfIntervals; final double quantity = Math.rint(1000.0 * (minValue + (maxValue - minValue) * ratio)) / 1000.0; // making lighter color (color.brighter() is not so good...) final int r = (int) (rd * ratio + rl * (1 - ratio)); final int g = (int) (gd * ratio + gl * (1 - ratio)); final int b = (int) (bd * ratio + bl * (1 - ratio)); final ColorMapEntry colorMapEntry = new ColorMapEntry_Impl(new Color(r, g, b), DEFAULT_RASTER_FILLOPACITY, quantity, ""); //$NON-NLS-1$ colorMap.put(quantity, colorMapEntry); if (monitor.isCanceled()) throw new CoreException(Status.CANCEL_STATUS); } final RasterSymbolizer rasterSymbolizer = new RasterSymbolizer_Impl(null, colorMap, null, null); final Rule rule = StyleFactory.createRule(rasterSymbolizer); style.addRule(rule); final FeatureTypeStyle[] featureTypeStyles = new FeatureTypeStyle[] { style }; final Style[] styles = new Style[] { StyleFactory.createUserStyle(styleName, styleTitle, null, false, featureTypeStyles) }; final org.kalypsodeegree.graphics.sld.Layer[] layers = new org.kalypsodeegree.graphics.sld.Layer[] { SLDFactory.createNamedLayer(LAYER_NAME, null, styles) }; return SLDFactory.createStyledLayerDescriptor(layers); }
From source file:de.bund.bfr.knime.gis.views.canvas.CanvasUtils.java
public static Paint mixColors(Color backgroundColor, List<Color> colors, List<Double> alphas, boolean checkedInsteadOfStriped) { double rb = backgroundColor.getRed() / 255.0; double gb = backgroundColor.getGreen() / 255.0; double bb = backgroundColor.getBlue() / 255.0; double ab = backgroundColor.getAlpha() / 255.0; List<Color> cs = new ArrayList<>(); for (int i = 0; i < colors.size(); i++) { double alpha = alphas.get(i); if (alpha > 0.0) { double r = colors.get(i).getRed() / 255.0 * alpha + rb * (1 - alpha); double g = colors.get(i).getGreen() / 255.0 * alpha + gb * (1 - alpha); double b = colors.get(i).getBlue() / 255.0 * alpha + bb * (1 - alpha); double a = colors.get(i).getAlpha() / 255.0 * alpha + ab * (1 - alpha); cs.add(new Color((float) r, (float) g, (float) b, (float) a)); }/*from w w w . j a va 2s .com*/ } if (cs.isEmpty()) { return backgroundColor; } else if (cs.size() == 1) { return cs.get(0); } BufferedImage img; int size = cs.size() * (checkedInsteadOfStriped ? EDGE_TEXTURE_SIZE : NODE_TEXTURE_SIZE); if (checkedInsteadOfStriped) { img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { img.setRGB(x, y, cs.get((x / EDGE_TEXTURE_SIZE + y / EDGE_TEXTURE_SIZE) % cs.size()).getRGB()); } } } else { img = new BufferedImage(size, 1, BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < size; x++) { img.setRGB(x, 0, cs.get(x / NODE_TEXTURE_SIZE).getRGB()); } } return new TexturePaint(img, new Rectangle(img.getWidth(), img.getHeight())); }
From source file:main.java.whiteSocket.Bloop.java
public static boolean isMarker(Color x) { int brightness = (int) (0.2126 * x.getRed() + 0.7152 * x.getGreen() + 0.0722 * x.getBlue()); if (brightness < brightThreshold) return true; else/*from w ww . jav a 2 s . com*/ return false; }