List of usage examples for java.awt Color getRed
public int getRed()
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java
/** * Method contributed by Alexej Suchov/* w w w. j a va 2 s . c om*/ * * @see Graphics2D#setPaint(Paint) */ @Override public void setPaint(final Paint paint) { if (paint == null) { return; } this.paint = paint; realPaint = paint; if ((composite instanceof AlphaComposite) && (paint instanceof Color)) { final AlphaComposite co = (AlphaComposite) composite; if (co.getRule() == 3) { final Color c = (Color) paint; this.paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (c.getAlpha() * alpha)); realPaint = paint; } } }
From source file:net.sf.jasperreports.engine.export.JRRtfExporter.java
/** * Return color index from header of the .rtf file. If a color is not * found is automatically added to the header of the rtf file. The * method is called first when the header of the .rtf file is constructed * and when a component needs a color for foreground or background * @param color Color for which the index is required. * @return index of the color from .rtf file header *//* w w w .j a v a2 s . co m*/ private int getColorIndex(Color color) throws IOException { int colorNdx = colors.indexOf(color); if (colorNdx < 0) { colorNdx = colors.size(); colors.add(color); colorWriter.write( "\\red" + color.getRed() + "\\green" + color.getGreen() + "\\blue" + color.getBlue() + ";"); } return colorNdx; }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java
/** * Method contributed by Alexej Suchov// w ww . jav a2 s .c om * * @see Graphics2D#setComposite(Composite) */ @Override public void setComposite(final Composite comp) { if (comp instanceof AlphaComposite) { final AlphaComposite composite = (AlphaComposite) comp; if (composite.getRule() == 3) { alpha = composite.getAlpha(); this.composite = composite; if (realPaint != null && (realPaint instanceof Color)) { final Color c = (Color) realPaint; paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (c.getAlpha() * alpha)); } return; } } this.composite = comp; alpha = 1.0F; }
From source file:fi.nls.oskari.printout.printing.PDPageContentStream.java
/** * Set the stroking color, specified as RGB. * // w ww .java2s .c o m * @param color * The color to set. * @throws IOException * If an IO error occurs while writing to the stream. */ public void setStrokingColor(Color color) throws IOException { ColorSpace colorSpace = color.getColorSpace(); if (colorSpace.getType() == ColorSpace.TYPE_RGB) { setStrokingColor(color.getRed(), color.getGreen(), color.getBlue()); } else if (colorSpace.getType() == ColorSpace.TYPE_GRAY) { color.getColorComponents(colorComponents); setStrokingColor(colorComponents[0]); } else if (colorSpace.getType() == ColorSpace.TYPE_CMYK) { color.getColorComponents(colorComponents); setStrokingColor(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]); } else { throw new IOException("Error: unknown colorspace:" + colorSpace); } }
From source file:fi.nls.oskari.printout.printing.PDPageContentStream.java
/** * Set the non stroking color, specified as RGB. * /*w ww . j ava2s . co m*/ * @param color * The color to set. * @throws IOException * If an IO error occurs while writing to the stream. */ public void setNonStrokingColor(Color color) throws IOException { ColorSpace colorSpace = color.getColorSpace(); if (colorSpace.getType() == ColorSpace.TYPE_RGB) { setNonStrokingColor(color.getRed(), color.getGreen(), color.getBlue()); } else if (colorSpace.getType() == ColorSpace.TYPE_GRAY) { color.getColorComponents(colorComponents); setNonStrokingColor(colorComponents[0]); } else if (colorSpace.getType() == ColorSpace.TYPE_CMYK) { color.getColorComponents(colorComponents); setNonStrokingColor(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]); } else { throw new IOException("Error: unknown colorspace:" + colorSpace); } }
From source file:uk.bl.dpt.qa.gui.DissimilarGUIThread.java
/** * overlay heatmap on image/*w ww. j ava2 s . co m*/ */ private void internalOverlayHeatmap() { gRightImageSave = imageRight.getImage(); if (!gHeatmapGenerated) { internalBeforeGUIThread(); //threaded load so GUI doesn't hang Task<Integer> task = new Task<Integer>() { @Override protected Integer call() throws Exception { BufferedImage image = SwingFXUtils.fromFXImage(imageRight.getImage(), null); if (gHeatmap == null) { //re-generate heatmap (must be on a re-load) try { gHeatmap = Imaging.getBufferedImage(gResults.get(gCurrentRecord).getHeatmapTemp()); } catch (IOException | ImageReadException e) { // TODO Auto-generated catch block e.printStackTrace(); } } for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { int rgb = image.getRGB(x, y); Color heatmapColor = new Color(gHeatmap.getRGB((x / DissimilarV2.SSIMWINDOWSIZE), (y / DissimilarV2.SSIMWINDOWSIZE))); int heatmapPixel = heatmapColor.getGreen();//&maxPixelValue; if (heatmapColor.getGreen() != heatmapColor.getBlue() && heatmapColor.getBlue() != heatmapColor.getRed()) { gLogger.error("Heatmap error (should not happen)"); } double factor = 1 - (((double) heatmapPixel / 255)); Color col = new Color(rgb); int red = (int) (factor * col.getRed()); int green = (int) (factor * col.getGreen()); int blue = (int) (factor * col.getBlue()); if (red < 0) red = 0; if (green < 0) green = 0; if (blue < 0) blue = 0; col = new Color(red, green, blue); image.setRGB(x, y, col.getRGB()); } } gHeatmapImage = SwingFXUtils.toFXImage(image, null); gHeatmapGenerated = true; Platform.runLater(new Runnable() { //@Override public void run() { imageRight.setImage(gHeatmapImage); } }); internalAfterGUIThread(); return 1; } }; progressIndicator.progressProperty().bind(task.progressProperty()); Thread loader = new Thread(task); loader.setDaemon(true); loader.start(); } else { imageRight.setImage(gHeatmapImage); } }
From source file:org.eclipse.birt.chart.device.svg.SVGGraphics2D.java
/** * @returns the color definition in a string with the format: #RRGGBBAA: * RRGGBB are the color components in hexa in the range 00..FF AA * is the transparency value in hexa in the range 00..FF ex: Solid * light gray : #777777/*from ww w . j av a2s. c o m*/ */ protected String serializeToString(Color color) { String r = Integer.toHexString(color.getRed()); if (color.getRed() <= 0xF) r = "0" + r; //$NON-NLS-1$ String g = Integer.toHexString(color.getGreen()); if (color.getGreen() <= 0xF) g = "0" + g; //$NON-NLS-1$ String b = Integer.toHexString(color.getBlue()); if (color.getBlue() <= 0xF) b = "0" + b; //$NON-NLS-1$ String ret = "#" + r + g + b; //$NON-NLS-1$ return ret; }
From source file:org.eclipse.birt.chart.device.svg.SVGGraphics2D.java
private String serializeHighlightToString(Color cd) { if (cd != null) { int red = (cd.getRed() + 255) / 2; int green = (cd.getGreen() + 255) / 2; int blue = (cd.getBlue() + 255) / 2; String r = Integer.toHexString(red); if (red <= 0xF) r = "0" + r; //$NON-NLS-1$ String g = Integer.toHexString(green); if (green <= 0xF) g = "0" + g; //$NON-NLS-1$ String b = Integer.toHexString(blue); if (blue <= 0xF) b = "0" + b; //$NON-NLS-1$ return "#" + r + g + b; //$NON-NLS-1$ }//ww w .j a va 2s. c o m return ""; //$NON-NLS-1$ }
From source file:lcmc.common.ui.ResourceGraph.java
/** Draws text on the vertex. */ private void drawVertexText(final Graphics2D g2d, final TextLayout textLayout, final double x, final double y, final Color color, final int alpha) { if (color != null) { g2d.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha)); }// www . j a v a 2s .c o m textLayout.draw(g2d, (float) x, (float) y); }
From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java
/** * Utility function to update a scatterplot line's data series. * @param data the datagraph data./*from www . j a v a2 s . c o m*/ * @param sheet the Excel sheet which contains corresponding data from the scatterplot data series. * @param seriesIdx the index of the data in the dategraph data. * @param series the XML object representing the series in the chart. */ private static void updateCTScatterSer(final DategraphData data, final XSSFSheet sheet, final int seriesIdx, final CTScatterSer series) { final String sheetName = sheet.getSheetName(); // the series idx starts from 0 final DategraphData.Row row = data.getRows().get(seriesIdx); final String title = row.getLabel(); final Color color = Color.decode(row.getColor()); series.getOrder().setVal(seriesIdx); series.getIdx().setVal(seriesIdx); final CTSolidColorFillProperties fill = series.getSpPr().getLn().getSolidFill(); // We have to set any possible colour type, PowerPoint throws an error if there's multiple fills, and we don't // know what colour type the user may have used in their template slide. if (fill.getSchemeClr() != null) { fill.unsetSchemeClr(); } if (fill.getSrgbClr() != null) { fill.unsetSrgbClr(); } if (fill.getHslClr() != null) { fill.unsetHslClr(); } if (fill.getPrstClr() != null) { fill.unsetPrstClr(); } if (fill.getScrgbClr() != null) { fill.unsetScrgbClr(); } if (fill.getSysClr() != null) { fill.unsetSysClr(); } final CTSRgbColor fillClr = fill.addNewSrgbClr(); final byte[] colorBytes = { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() }; fillClr.setVal(colorBytes); final CTMarker marker = series.getMarker(); if (marker != null) { final CTShapeProperties markerSpPr = marker.getSpPr(); unsetSpPrFills(markerSpPr); markerSpPr.addNewSolidFill().addNewSrgbClr().setVal(colorBytes); final CTLineProperties markerLn = markerSpPr.getLn(); if (markerLn != null) { unsetLineFills(markerLn); markerLn.addNewSolidFill().addNewSrgbClr().setVal(colorBytes); } } final CTStrRef strRef = series.getTx().getStrRef(); strRef.getStrCache().getPtArray()[0].setV(title); strRef.setF(new CellReference(sheetName, 0, seriesIdx + 1, true, true).formatAsString()); final long[] timestamps = data.getTimestamps(); { final CTNumRef timestampCatNumRef = series.getXVal().getNumRef(); timestampCatNumRef.setF(new AreaReference(new CellReference(sheetName, 1, 0, true, true), new CellReference(sheetName, 1 + timestamps.length, 0, true, true)).formatAsString()); final CTNumData timeStampCatNumCache = timestampCatNumRef.getNumCache(); timeStampCatNumCache.getPtCount().setVal(timestamps.length); timeStampCatNumCache.setPtArray(null); for (int ii = 0; ii < timestamps.length; ++ii) { final CTNumVal pt = timeStampCatNumCache.addNewPt(); pt.setIdx(ii); pt.setV(sheet.getRow(1 + ii).getCell(0).getRawValue()); } } { final double[] seriesData = row.getValues(); final CTNumRef valuesNumRef = series.getYVal().getNumRef(); valuesNumRef.setF(new AreaReference(new CellReference(sheetName, 1, seriesIdx + 1, true, true), new CellReference(sheetName, 1 + timestamps.length, seriesIdx + 1, true, true)) .formatAsString()); final CTNumData valuesNumCache = valuesNumRef.getNumCache(); valuesNumCache.getPtCount().setVal(timestamps.length); valuesNumCache.setPtArray(null); for (int ii = 0; ii < timestamps.length; ++ii) { final CTNumVal pt = valuesNumCache.addNewPt(); pt.setIdx(ii); pt.setV(Double.toString(seriesData[ii])); } } }