List of usage examples for java.awt Color getBlue
public int getBlue()
From source file:com.jcraft.weirdx.XColormap.java
private void alloc(int i, Color color) { colors[i] = color;/*from www.j ava 2 s . co m*/ r[i] = (byte) color.getRed(); g[i] = (byte) color.getGreen(); b[i] = (byte) color.getBlue(); }
From source file:net.sf.jasperreports.engine.export.JExcelApiMetadataExporter.java
protected void setColourUsed(Colour colour, Color reportColour) { if (log.isDebugEnabled()) { log.debug("Modifying palette colour " + colour.getValue() + " to " + reportColour); }//from ww w.j a v a 2s .c o m int red = reportColour.getRed(); int green = reportColour.getGreen(); int blue = reportColour.getBlue(); workbook.setColourRGB(colour, red, green, blue); RGB customRGB = new RGB(red, green, blue); usedColours.put(colour, customRGB); }
From source file:org.apache.fop.afp.ptoca.PtocaBuilder.java
/** * The Set Extended Text Color control sequence specifies a color value and * defines the color space and encoding for that value. The specified color * value is applied to foreground areas of the text presentation space. * <p>//w w w . j a va2 s . c o m * This is a modal control sequence. * * @param col The color to be set. * @throws IOException if an I/O error occurs */ public void setExtendedTextColor(Color col) throws IOException { if (ColorUtil.isSameColor(col, currentColor)) { return; } if (col instanceof ColorWithAlternatives) { ColorWithAlternatives cwa = (ColorWithAlternatives) col; Color alt = cwa.getFirstAlternativeOfType(ColorSpace.TYPE_CMYK); if (alt != null) { col = alt; } } ColorSpace cs = col.getColorSpace(); newControlSequence(); if (col.getColorSpace().getType() == ColorSpace.TYPE_CMYK) { // Color space - 0x04 = CMYK, all else are reserved and must be zero writeBytes(0x00, 0x04, 0x00, 0x00, 0x00, 0x00); writeBytes(8, 8, 8, 8); // Number of bits in component 1, 2, 3 & 4 respectively float[] comps = col.getColorComponents(null); assert comps.length == 4; for (int i = 0; i < 4; i++) { int component = Math.round(comps[i] * 255); writeBytes(component); } } else if (cs instanceof CIELabColorSpace) { // Color space - 0x08 = CIELAB, all else are reserved and must be zero writeBytes(0x00, 0x08, 0x00, 0x00, 0x00, 0x00); writeBytes(8, 8, 8, 0); // Number of bits in component 1,2,3 & 4 //Sadly, 16 bit components don't seem to work float[] colorComponents = col.getColorComponents(null); int l = Math.round(colorComponents[0] * 255f); int a = Math.round(colorComponents[1] * 255f) - 128; int b = Math.round(colorComponents[2] * 255f) - 128; writeBytes(l, a, b); // l*, a* and b* } else { // Color space - 0x01 = RGB, all else are reserved and must be zero writeBytes(0x00, 0x01, 0x00, 0x00, 0x00, 0x00); writeBytes(8, 8, 8, 0); // Number of bits in component 1, 2, 3 & 4 respectively writeBytes(col.getRed(), col.getGreen(), col.getBlue()); // RGB intensity } commit(chained(SEC)); this.currentColor = col; }
From source file:net.sf.jasperreports.engine.export.JExcelApiExporter.java
protected void setColourUsed(Colour colour, Color reportColour) { if (log.isDebugEnabled()) { log.debug("Modifying palette colour " + colour.getValue() + " to " + reportColour); }/*from w w w . ja v a2s .c om*/ int red = reportColour.getRed(); int green = reportColour.getGreen(); int blue = reportColour.getBlue(); workbook.setColourRGB(colour, red, green, blue); RGB customRGB = new RGB(red, green, blue); usedColours.put(colour, customRGB); }
From source file:net.sf.jasperreports.engine.export.JRXlsMetadataExporter.java
/** * *///from www. ja va2 s. com protected HSSFColor getWorkbookColor(Color awtColor) { HSSFColor color = null; if (awtColor != null) { byte red = (byte) awtColor.getRed(); byte green = (byte) awtColor.getGreen(); byte blue = (byte) awtColor.getBlue(); XlsExporterConfiguration configuration = getCurrentConfiguration(); if (configuration.isCreateCustomPalette()) { try { color = palette.findColor(red, green, blue) != null ? palette.findColor(red, green, blue) : palette.addColor(red, green, blue); } catch (Exception e) { if (customColorIndex < MAX_COLOR_INDEX) { palette.setColorAtIndex(customColorIndex, red, green, blue); color = palette.getColor(customColorIndex++); } else { color = palette.findSimilarColor(red, green, blue); } } } } return color == null ? getNearestColor(awtColor) : color; }
From source file:net.sf.jasperreports.engine.export.JRXlsExporter.java
/** * *//*www. j a va 2s . c o m*/ protected HSSFColor getNearestColor(Color awtColor) { HSSFColor color = hssfColorsCache.get(awtColor); if (color == null) { int minDiff = Integer.MAX_VALUE; for (Map.Entry<HSSFColor, short[]> hssfColorEntry : hssfColorsRgbs.entrySet()) { HSSFColor crtColor = hssfColorEntry.getKey(); short[] rgb = hssfColorEntry.getValue(); int diff = Math.abs(rgb[0] - awtColor.getRed()) + Math.abs(rgb[1] - awtColor.getGreen()) + Math.abs(rgb[2] - awtColor.getBlue()); if (diff < minDiff) { minDiff = diff; color = crtColor; } } hssfColorsCache.put(awtColor, color); } return color; }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void setBackgroundGradient(Color c0, Color c1, Color c2) { bgColor = new Color3f(c0.getColorComponents(null)); myFog.setColor(bgColor);/* w w w .j a va 2s . co m*/ fireBgrColorChanged(); int r0 = c0.getRed(), r1 = c1.getRed(), r2 = c2.getRed(); int g0 = c0.getGreen(), g1 = c1.getGreen(), g2 = c2.getGreen(); int b0 = c0.getBlue(), b1 = c1.getBlue(), b2 = c2.getBlue(); int[] bgrData = new int[256 * 256]; int k = 0; for (int i = 0; i < 128; i++) { float t = i / 127.f; int r = (int) (t * r1 + (1 - t) * r0); int g = (int) (t * g1 + (1 - t) * g0); int b = (int) (t * b1 + (1 - t) * b0); int c = ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); for (int j = 0; j < 256; j++, k++) { bgrData[k] = c; } } for (int i = 0; i < 128; i++) { float t = i / 127.f; int r = (int) (t * r2 + (1 - t) * r1); int g = (int) (t * g2 + (1 - t) * g1); int b = (int) (t * b2 + (1 - t) * b1); int c = ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); for (int j = 0; j < 256; j++, k++) { bgrData[k] = c; } } BufferedImage bgrImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); bgrImage.setRGB(0, 0, 256, 256, bgrData, 0, 256); ImageComponent2D bgrImageComponent = new ImageComponent2D(ImageComponent2D.FORMAT_RGBA, bgrImage); bg.setImage(bgrImageComponent); }
From source file:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java
/** * Method for converting {@link Color} to LayoutML XML. * * @param color/* ww w.j av a 2s . c om*/ * @return {@link StringBuffer} with the LayoutML */ private synchronized StringBuffer getLayoutMLColorAttributes(Color color) { StringBuffer sb = new StringBuffer(); sb.append(" " + ATTRIBUTE_RED + "=\""); sb.append(color.getRed()); sb.append("\" " + ATTRIBUTE_GREEN + "=\""); sb.append(color.getGreen()); sb.append("\" " + ATTRIBUTE_BLUE + "=\""); sb.append(color.getBlue()); sb.append("\""); return sb; }
From source file:com.manydesigns.portofino.actions.admin.appwizard.ApplicationWizard.java
protected void setupCalendar(List<ChildPage> childPages) throws Exception { List<List<String>> calendarDefinitions = new ArrayList<List<String>>(); Color[] colors = { Color.RED, new Color(64, 128, 255), Color.CYAN.darker(), Color.GRAY, Color.GREEN.darker(), Color.ORANGE, Color.YELLOW.darker(), Color.MAGENTA.darker(), Color.PINK }; int colorIndex = 0; for (Table table : allTables) { List<Column> dateColumns = new ArrayList<Column>(); for (Column column : table.getColumns()) { if (column.getActualJavaType() != null && Date.class.isAssignableFrom(column.getActualJavaType())) { dateColumns.add(column); }//from w w w . ja va 2s . c om } if (!dateColumns.isEmpty()) { // ["Cal 1", "db1.schema1.table1", ["column1", "column2"], Color.RED] Color color = colors[colorIndex++ % colors.length]; List<String> calDef = new ArrayList<String>(); calDef.add('"' + Util.guessToWords(table.getActualEntityName()) + '"'); calDef.add('"' + table.getQualifiedName() + '"'); String cols = "["; boolean first = true; for (Column column : dateColumns) { if (first) { first = false; } else { cols += ", "; } cols += '"' + column.getActualPropertyName() + '"'; } cols += "]"; calDef.add(cols); calDef.add("new java.awt.Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")"); calendarDefinitions.add(calDef); } } if (!calendarDefinitions.isEmpty()) { String calendarDefinitionsStr = "["; calendarDefinitionsStr += StringUtils.join(calendarDefinitions, ", "); calendarDefinitionsStr += "]"; String baseName = "calendar-" + connectionProvider.getDatabase().getDatabaseName(); File dir = new File(pagesDir, baseName); int retries = 1; while (dir.exists()) { retries++; dir = new File(pagesDir, baseName + "-" + retries); } if (dir.mkdirs()) { CalendarConfiguration configuration = new CalendarConfiguration(); DispatcherLogic.saveConfiguration(dir, configuration); Page page = new Page(); page.setId(RandomUtil.createRandomId()); String calendarTitle = "Calendar (" + connectionProvider.getDatabase().getDatabaseName() + ")"; if (retries > 1) { calendarTitle += " - " + retries; } page.setTitle(calendarTitle); page.setDescription(calendarTitle); DispatcherLogic.savePage(dir, page); File actionFile = new File(dir, "action.groovy"); try { TemplateEngine engine = new SimpleTemplateEngine(); Template template = engine .createTemplate(ApplicationWizard.class.getResource("CalendarPage.groovy")); Map<String, Object> bindings = new HashMap<String, Object>(); bindings.put("calendarDefinitions", calendarDefinitionsStr); FileWriter fw = new FileWriter(actionFile); template.make(bindings).writeTo(fw); IOUtils.closeQuietly(fw); } catch (Exception e) { logger.warn("Couldn't create calendar", e); SessionMessages.addWarningMessage("Couldn't create calendar: " + e); return; } ChildPage childPage = new ChildPage(); childPage.setName(dir.getName()); childPage.setShowInNavigation(true); childPages.add(childPage); } else { logger.warn("Couldn't create directory {}", dir.getAbsolutePath()); SessionMessages.addWarningMessage( ElementsThreadLocals.getText("couldnt.create.directory", dir.getAbsolutePath())); } } }
From source file:edu.ku.brc.ui.UIHelper.java
/** * @param color//from w ww .ja v a2 s.c o m * @return */ public static String getBGRHexFromColor(final Color color) { return getHexStr(color.getBlue()) + getHexStr(color.getGreen()) + getHexStr(color.getRed()); }