List of usage examples for java.awt Color getRGBColorComponents
public float[] getRGBColorComponents(float[] compArray)
From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java
private void oceanButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_oceanButtonActionPerformed {//GEN-HEADEREND:event_oceanButtonActionPerformed final Color newColour = JColorChooser.showDialog(this, "Choose Ocean Colour", oceanButton.getBackground()); if (newColour != null) { /// then a new colour was chosen final float[] comps = newColour.getRGBColorComponents(null); final TerrainParameters params = this.parent.getParameters().getTerrainParameters(); final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]); params.setColourOcean(newRGB);//from w w w. ja v a2 s .c om oceanButton.setBackground(newColour); } }
From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java
private void sunlightButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_sunlightButtonActionPerformed {//GEN-HEADEREND:event_sunlightButtonActionPerformed Color newColour = JColorChooser.showDialog(this, "Choose Ambient Light Colour", sunlightButton.getBackground()); if (newColour != null) { /// then a new colour was chosen float[] comps = newColour.getRGBColorComponents(null); final RenderParameters params = this.parent.getParameters().getRenderParameters(); final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]); params.setSunColour(newRGB);/* w ww .j a v a 2 s .co m*/ sunlightButton.setBackground(newColour); } }
From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java
private void shorelineButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_shorelineButtonActionPerformed {//GEN-HEADEREND:event_shorelineButtonActionPerformed final Color newColour = JColorChooser.showDialog(this, "Choose Shoreline Colour", shorelineButton.getBackground()); if (newColour != null) { /// then a new colour was chosen final float[] comps = newColour.getRGBColorComponents(null); final TerrainParameters params = this.parent.getParameters().getTerrainParameters(); final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]); params.setColourShoreline(newRGB); shorelineButton.setBackground(newColour); }/*from w w w . j av a2s.com*/ }
From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java
private void lowTerrainButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_lowTerrainButtonActionPerformed {//GEN-HEADEREND:event_lowTerrainButtonActionPerformed final Color newColour = JColorChooser.showDialog(this, "Choose Low Terrain Colour", lowTerrainButton.getBackground()); if (newColour != null) { /// then a new colour was chosen final float[] comps = newColour.getRGBColorComponents(null); final TerrainParameters params = this.parent.getParameters().getTerrainParameters(); final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]); params.setColourLow(newRGB);/*from w w w.j ava2 s.c o m*/ lowTerrainButton.setBackground(newColour); } }
From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java
private void highTerrainButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_highTerrainButtonActionPerformed {//GEN-HEADEREND:event_highTerrainButtonActionPerformed final Color newColour = JColorChooser.showDialog(this, "Choose High Terrain Colour", highTerrainButton.getBackground()); if (newColour != null) { /// then a new colour was chosen final float[] comps = newColour.getRGBColorComponents(null); final TerrainParameters params = this.parent.getParameters().getTerrainParameters(); final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]); params.setColourHigh(newRGB);/*from w ww . j a v a2 s . c o m*/ highTerrainButton.setBackground(newColour); } }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * Converts a JasperReports meter interval to one that JFreeChart understands. * * @param interval the JasperReports definition of an interval * @return the JFreeChart version of the same interval * @throws JRException thrown when the interval contains an invalid range *//*from w w w . ja v a2 s.co m*/ protected MeterInterval convertInterval(JRMeterInterval interval) throws JRException { String label = interval.getLabel(); if (label == null) label = ""; Range range = convertRange(interval.getDataRange()); Color color = interval.getBackgroundColor() != null ? interval.getBackgroundColor() : (Color) ChartThemesConstants.TRANSPARENT_PAINT; float[] components = color.getRGBColorComponents(null); float alpha = (float) (interval.getAlphaDouble() == null ? JRMeterInterval.DEFAULT_TRANSPARENCY : interval.getAlphaDouble()); Color alphaColor = new Color(components[0], components[1], components[2], alpha); return new MeterInterval(label, range, alphaColor, null, alphaColor); }
From source file:org.apache.fop.util.ColorUtil.java
/** * Parse a color specified using the fop-rgb-icc() function. * * @param value the function call/*from w ww . ja v a2 s . c o m*/ * @return a color if possible * @throws PropertyException if the format is wrong. */ private static Color parseAsFopRgbIcc(FOUserAgent foUserAgent, String value) throws PropertyException { Color parsedColor; int poss = value.indexOf("("); int pose = value.indexOf(")"); if (poss != -1 && pose != -1) { String[] args = value.substring(poss + 1, pose).split(","); try { if (args.length < 5) { throw new PropertyException("Too few arguments for rgb-icc() function"); } //Set up fallback sRGB value Color sRGB = parseFallback(args, value); /* Get and verify ICC profile name */ String iccProfileName = args[3].trim(); if (iccProfileName == null || "".equals(iccProfileName)) { throw new PropertyException("ICC profile name missing"); } ColorSpace colorSpace = null; String iccProfileSrc = null; if (isPseudoProfile(iccProfileName)) { if (CMYK_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { colorSpace = ColorSpaces.getDeviceCMYKColorSpace(); } else if (SEPARATION_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { colorSpace = new NamedColorSpace(args[5], sRGB, SEPARATION_PSEUDO_PROFILE, null); } else { assert false : "Incomplete implementation"; } } else { /* Get and verify ICC profile source */ iccProfileSrc = args[4].trim(); if (iccProfileSrc == null || "".equals(iccProfileSrc)) { throw new PropertyException("ICC profile source missing"); } iccProfileSrc = unescapeString(iccProfileSrc); } /* ICC profile arguments */ int componentStart = 4; if (colorSpace instanceof NamedColorSpace) { componentStart++; } float[] iccComponents = new float[args.length - componentStart - 1]; for (int ix = componentStart; ++ix < args.length;) { iccComponents[ix - componentStart - 1] = Float.parseFloat(args[ix].trim()); } if (colorSpace instanceof NamedColorSpace && iccComponents.length == 0) { iccComponents = new float[] { 1.0f }; //full tint if not specified } /* Ask FOP factory to get ColorSpace for the specified ICC profile source */ if (foUserAgent != null && iccProfileSrc != null) { RenderingIntent renderingIntent = RenderingIntent.AUTO; //TODO connect to fo:color-profile/@rendering-intent colorSpace = foUserAgent.getFactory().getColorSpaceCache().get(iccProfileName, foUserAgent.getBaseURL(), iccProfileSrc, renderingIntent); } if (colorSpace != null) { // ColorSpace is available if (ColorSpaces.isDeviceColorSpace(colorSpace)) { //Device-specific colors are handled differently: //sRGB is the primary color with the CMYK as the alternative Color deviceColor = new Color(colorSpace, iccComponents, 1.0f); float[] rgbComps = sRGB.getRGBColorComponents(null); parsedColor = new ColorWithAlternatives(rgbComps[0], rgbComps[1], rgbComps[2], new Color[] { deviceColor }); } else { parsedColor = new ColorWithFallback(colorSpace, iccComponents, 1.0f, null, sRGB); } } else { // ICC profile could not be loaded - use rgb replacement values */ log.warn("Color profile '" + iccProfileSrc + "' not found. Using sRGB replacement values."); parsedColor = sRGB; } } catch (RuntimeException re) { throw new PropertyException(re); } } else { throw new PropertyException( "Unknown color format: " + value + ". Must be fop-rgb-icc(r,g,b,NCNAME,src,....)"); } return parsedColor; }
From source file:org.apache.fop.util.ColorUtil.java
/** * Parse a color given with the cmyk() function. * * @param value//from w w w . j ava 2s . co m * the complete line * @return a color if possible * @throws PropertyException * if the format is wrong. */ private static Color parseAsCMYK(String value) throws PropertyException { Color parsedColor; int poss = value.indexOf("("); int pose = value.indexOf(")"); if (poss != -1 && pose != -1) { value = value.substring(poss + 1, pose); String[] args = value.split(","); try { if (args.length != 4) { throw new PropertyException("Invalid number of arguments: cmyk(" + value + ")"); } float cyan = parseComponent1(args[0], value); float magenta = parseComponent1(args[1], value); float yellow = parseComponent1(args[2], value); float black = parseComponent1(args[3], value); float[] comps = new float[] { cyan, magenta, yellow, black }; Color cmykColor = DeviceCMYKColorSpace.createCMYKColor(comps); float[] rgbComps = cmykColor.getRGBColorComponents(null); parsedColor = new ColorWithAlternatives(rgbComps[0], rgbComps[1], rgbComps[2], new Color[] { cmykColor }); } catch (RuntimeException re) { throw new PropertyException(re); } } else { throw new PropertyException("Unknown color format: " + value + ". Must be cmyk(c,m,y,k)"); } return parsedColor; }
From source file:org.apache.fop.util.ColorUtil.java
private static Color toSRGBColor(Color color) { float[] comps; ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB); comps = color.getRGBColorComponents(null); float[] allComps = color.getComponents(null); float alpha = allComps[allComps.length - 1]; //Alpha is on last component return new Color(sRGB, comps, alpha); }
From source file:org.apache.pdfbox.pdmodel.fdf.FDFAnnotation.java
/** * Set the annotation color.//from w ww . j a v a2 s . c o m * * @param c The annotation color. */ public void setColor(Color c) { COSArray color = null; if (c != null) { float[] colors = c.getRGBColorComponents(null); color = new COSArray(); color.setFloatArray(colors); } annot.setItem(COSName.C, color); }