List of usage examples for java.awt Color getGreen
public int getGreen()
From source file:mio_de_pso.MainForm.java
private LookupPaintScale createLookupPaintScale(double[] values) { double minVal = values[0]; double maxVal = values[0]; for (int i = 0; i < values.length; ++i) { if (values[i] < minVal) minVal = values[i];/*ww w. ja v a 2 s . com*/ if (values[i] > maxVal) maxVal = values[i]; } LookupPaintScale ps = new LookupPaintScale(minVal, maxVal + 0.0000001, Color.WHITE); Color startColor = Color.BLACK; Color secondColor = Color.BLUE; Color thirdColor = Color.GREEN; Color fourthColor = Color.YELLOW; Color endColor = Color.RED; int iterations = 80; int iterationPerColor = iterations / 4; double res = Math.round(((maxVal - minVal) / iterations) * 100.0) / 100.0; minVal -= res; for (int i = 0; i < iterationPerColor; ++i) { ps.add(minVal += res, new Color( startColor.getRed() + (((secondColor.getRed() - startColor.getRed()) * i) / iterationPerColor), startColor.getGreen() + (((secondColor.getGreen()) - startColor.getGreen()) * i) / iterationPerColor, startColor.getBlue() + (((secondColor.getBlue() - startColor.getBlue()) * i) / iterationPerColor))); } for (int i = 0; i < iterationPerColor; ++i) { ps.add(minVal += res, new Color( secondColor.getRed() + (((thirdColor.getRed() - secondColor.getRed()) * i) / iterationPerColor), secondColor.getGreen() + (((thirdColor.getGreen()) - secondColor.getGreen()) * i) / iterationPerColor, secondColor.getBlue() + (((thirdColor.getBlue() - secondColor.getBlue()) * i) / iterationPerColor))); } for (int i = 0; i < iterationPerColor; ++i) { ps.add(minVal += res, new Color( thirdColor.getRed() + (((fourthColor.getRed() - thirdColor.getRed()) * i) / iterationPerColor), thirdColor.getGreen() + (((fourthColor.getGreen()) - thirdColor.getGreen()) * i) / iterationPerColor, thirdColor.getBlue() + (((fourthColor.getBlue() - thirdColor.getBlue()) * i) / iterationPerColor))); } for (int i = 0; i < iterationPerColor; ++i) { ps.add(minVal += res, new Color( fourthColor.getRed() + (((endColor.getRed() - fourthColor.getRed()) * i) / iterationPerColor), fourthColor.getGreen() + (((endColor.getGreen()) - fourthColor.getGreen()) * i) / iterationPerColor, fourthColor.getBlue() + (((endColor.getBlue() - fourthColor.getBlue()) * i) / iterationPerColor))); } return ps; }
From source file:org.apache.pdfbox.pdmodel.edit.PDPageContentStream.java
/** * Set the non stroking color, specified as RGB. * * @param color The color to set.// ww w . j a v a 2s .c om * @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[2], colorComponents[2], colorComponents[3]); } else { throw new IOException("Error: unknown colorspace:" + colorSpace); } }
From source file:ImageOpByRomain.java
/** * <p>/* www .j a v a2 s . co m*/ * Creates a new color mixer filter. The specified color will be used to tint * the source image, with a mixing strength defined by <code>mixValue</code>. * </p> * * @param mixColor * the solid color to mix with the source image * @param mixValue * the strength of the mix, between 0.0 and 1.0; if the specified * value lies outside this range, it is clamped * @throws IllegalArgumentException * if <code>mixColor</code> is null */ public ColorTintFilter(Color mixColor, float mixValue) { if (mixColor == null) { throw new IllegalArgumentException("mixColor cannot be null"); } this.mixColor = mixColor; if (mixValue < 0.0f) { mixValue = 0.0f; } else if (mixValue > 1.0f) { mixValue = 1.0f; } this.mixValue = mixValue; int mix_r = (int) (mixColor.getRed() * mixValue); int mix_g = (int) (mixColor.getGreen() * mixValue); int mix_b = (int) (mixColor.getBlue() * mixValue); // Since we use only lookup tables to apply the filter, this filter // could be implemented as a LookupOp. float factor = 1.0f - mixValue; preMultipliedRed = new int[256]; preMultipliedGreen = new int[256]; preMultipliedBlue = new int[256]; for (int i = 0; i < 256; i++) { int value = (int) (i * factor); preMultipliedRed[i] = value + mix_r; preMultipliedGreen[i] = value + mix_g; preMultipliedBlue[i] = value + mix_b; } }
From source file:net.sf.jabref.JabRefPreferences.java
/** * Stores a color in preferences./* ww w. ja v a2s . c om*/ * * @param key The key for this setting. * @param color The Color to store. */ public void putColor(String key, Color color) { String rgb = String.valueOf(color.getRed()) + ':' + color.getGreen() + ':' + color.getBlue(); put(key, rgb); }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Returns <code>true</code> if the passed color is a dark color, * <code>false</code> otherwise. * // www . jav a 2s . c o m * @param c The color to handle. Mustn't be <code>null</code>. * @return See above. */ public static boolean isDarkColor(Color c) { if (c == null) return false; return (c.getRed() + c.getGreen() + c.getBlue()) / 3 < 128; }
From source file:net.sf.jasperreports.engine.export.JRRtfExporter.java
/** * *///from w w w . ja v a2 s . co m private int getColorRGB(Color color) { return color.getRed() + 256 * color.getGreen() + 65536 * color.getBlue(); }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Returns {@link #RED}, {@link #RED} or {@link #RED} to indicate the * range of the color.//from w ww.ja v a2s. c o m * * @param color The color to handle. * @return See above */ public static int getColorRange(Color color) { if (color == null) return -1; int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); if (g < r / 2 && b < r / 2) return RED_COLOR; if (r < g / 2 && b < g / 2) return GREEN_COLOR; return BLUE_COLOR; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java
/** * Adds a defined set of custom properties to the GLXNode. * These properties will be exported to the Visio shapes as custom properties. * //from w w w. j a va 2 s . c om * @param isRelease An InformationSystemRelease containing the attributes to add to the GLXNode. * @param node The corresponding graph node for the isRelease. * @param isName The formated name of the isRelease. */ private void addShapePropertiesToInsNode(InformationSystemRelease isRelease, GXLNode node, String isName) { setTextPropertyToNode(node, PROP_ID, isRelease.getId().toString()); setTextPropertyToNode(node, PROP_APP_NAME_FULL, isName); setTextPropertyToNode(node, PROP_APP_INFORMATION_OBJECTS_FULL, GeneralHelper.makeConcatenatedNameStringForBbCollection(isRelease.getBusinessObjects())); String urlToEntity = this.retrieveXLinkUrlForIdentityEntity(isRelease, this.informationFlowOptions.getServerUrl()); setTextPropertyToNode(node, PROP_XREF_URL, urlToEntity); // create a string containing all INS Domains, separated by a semicolon StringBuilder isdAttribute = new StringBuilder(); // check if the user has the permission to read the INS Domains: if (UserContext.getCurrentPerms() .userHasFunctionalPermission(TypeOfFunctionalPermission.INFORMATIONSYSTEMDOMAIN)) { for (InformationSystemDomain isd : isRelease.getInformationSystemDomains()) { isdAttribute.append(isd.getName() + "(" + isd.getId() + ");"); } } setTextPropertyToNode(node, PROP_APP_INS_DOMAIN, isdAttribute.toString()); // create a string containing all assigned attributes, separated by a semicolon StringBuilder attributesString = new StringBuilder(); Set<AttributeValueAssignment> avas = isRelease.getAttributeValueAssignments(); for (AttributeValueAssignment ava : avas) { AttributeValue av = ava.getAttributeValue(); AttributeType at = av.getAbstractAttributeType(); AttributeTypeGroup atg = at.getAttributeTypeGroup(); // check if the user has the permission to read the attributeGroup: if (UserContext.getCurrentPerms().userHasAttrTypeGroupPermission(atg, AttributeTypeGroupPermissionEnum.READ)) { attributesString.append("(" + at.getName() + ")=" + av.getLocalizedValueString(getLocale()) + ";"); } } setTextPropertyToNode(node, PROP_ATTRIBUTES, attributesString.toString()); setTextPropertyToNode(node, PROP_APP_VERSION, isRelease.getVersion()); setTextPropertyToNode(node, PROP_STATUS, mapTypeOfStatusVisioExport(isRelease.getTypeOfStatus())); setTextPropertyToNode(node, PROP_DESCRIPTION, isRelease.getDescription()); setTextPropertyToNode(node, PROP_START_DATE, DateUtils.formatAsStringToDefault(isRelease.runtimeStartsAt(), getLocale())); setTextPropertyToNode(node, PROP_END_DATE, DateUtils.formatAsStringToDefault(isRelease.runtimeEndsAt(), getLocale())); Color color = getColorDimension().getValue(isRelease); LOGGER.debug("Color for node: {0}", color); setTextPropertyToNode(node, PROP_COLOR_RED, String.valueOf(color.getRed())); setTextPropertyToNode(node, PROP_COLOR_GREEN, String.valueOf(color.getGreen())); setTextPropertyToNode(node, PROP_COLOR_BLUE, String.valueOf(color.getBlue())); }
From source file:com.jcraft.weirdx.XColormap.java
@SuppressWarnings("unused") static void reqLookupColor(Client c) throws IOException { int foo, n;//from w ww .j ava 2 s . c o m InputOutput io = c.client; n = c.length; foo = io.readInt(); XColormap cmap = (XColormap) XResource.lookupIDByType(foo, XResource.RT_COLORMAP); c.length -= 2; if (cmap == null) { c.errorValue = foo; c.errorReason = 12; // Colormap return; } foo = io.readShort(); io.readPad(2); io.readByte(c.bbuffer, 0, foo); io.readPad((-foo) & 3); c.length = 0; foo = chopspace(c.bbuffer, foo); if (foo == 0) { c.errorReason = 2; // BadValue return; } String s = new String(c.bbuffer, 0, foo); Color color = (Color) rgbTable.get(s); if (color != null) { synchronized (io) { io.writeByte(1); io.writePad(1); io.writeShort(c.seq); io.writeInt(0); foo = color.getRed(); io.writeShort(foo | (foo << 8)); foo = color.getGreen(); io.writeShort(foo | (foo << 8)); foo = color.getBlue(); io.writeShort(foo | (foo << 8)); foo = color.getRed(); io.writeShort(foo | (foo << 8)); foo = color.getGreen(); io.writeShort(foo | (foo << 8)); foo = color.getBlue(); io.writeShort(foo | (foo << 8)); io.writePad(12); io.flush(); return; } } synchronized (io) { io.writeByte((byte) 0); io.writeByte((byte) 15); io.writeShort(c.seq); io.writePad(4); io.writeShort(0); io.writeByte((byte) 92); io.writePad(21); io.flush(); } }
From source file:net.ontopia.topicmaps.viz.VizTopicMapConfigurationManager.java
/** * Sets the color for this association or topic type in the topic map. */// w w w. j a v a 2 s . co m private void setColor(TopicIF type, TopicIF occtype, Color c) { setOccurenceValue(type, occtype, c.getRed() + " " + c.getGreen() + " " + c.getBlue()); }