/** * Returns a Color instance representing the specified String value. * * @param colorValue a six (or three) number hexadecimal string representation of the Color * @return return a Color instance representing <code>stringValue</code>. * @throws IllegalArgumentException if the given argument is not a valid Color. */ public static Color valueOf(String colorValue) { return new Color(colorValue); }
/** * Construct Color by the parsing the given string. The string should be observed sRGB color standard * which starts with "#" and following with six numbers or three numbers in Hex format. * For example, "#FFFFFF" is a valid argument and white color will be constructed. * <p> * For further information on sRGB, * see <A href="http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html"> * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * </A>. * * @param color represented using the 3 or 6 HEX sRGB notation. * @throws IllegalArgumentException if the given argument is not a valid Color in sRGB HEX notation. */ public Color(String color) { if(!isValid(color)){ throw new IllegalArgumentException("parameter is invalid for datatype Color"); } if(color.length()==4){ mColorAsSixHexRGB = mapColorFromThreeToSixHex(color); }else{ mColorAsSixHexRGB = color; } }
/** * Sets backgroundColor represented by the OpenDocument format used data * type {@odf.datatype color} See * <a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-color">W3C CSS * specification</a> for further details. * @param bkColor */ public void setBackgroundColor(Color bkColor) { mElement.setFoBackgroundColorAttribute(bkColor.toString()); }
} else if (threeHexRGBPattern.matcher(colorValue).matches()) { return mapColorFromThreeToSixHex(colorValue); } else if (colorValue.startsWith("rgb")) { colorValue = colorValue.substring(3); String[] rgbValues = colorValue.split(","); if (rgbValues.length == 3) { int r = mapColorValueToInteger(rgbValues[0].trim()); int g = mapColorValueToInteger(rgbValues[1].trim()); int b = mapColorValueToInteger(rgbValues[2].trim()); String rs = Integer.toHexString(r); String gs = Integer.toHexString(g);
/** * Set the background color of this cell using string. The string must be a valid argument for * constructing {@link org.odftoolkit.odfdom.type.Color <code>org.odftoolkit.odfdom.type.Color</code>}. * * @param cellBackgroundColor * the background color that need to set. * If cellBackgroundColor is null, default background color #FFFFFF will be set. * @see org.odftoolkit.odfdom.type.Color */ public void setCellBackgroundColor(String cellBackgroundColor) { if (!Color.isValid(cellBackgroundColor)) { Logger.getLogger(OdfTableCell.class.getName()).log(Level.WARNING, "Parameter is invalid for datatype Color, default background color #FFFFFF will be set."); cellBackgroundColor = DEFAULT_BACKGROUND_COLOR; } splitRepeatedCells(); OdfStyleBase styleElement = getCellStyleElementForWrite(); if (styleElement != null) { OdfStyleProperty bkColorProperty = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties, OdfName.newName(OdfDocumentNamespace.FO, "background-color")); styleElement.setProperty(bkColorProperty, cellBackgroundColor); } }
/** * Return the background color. * <p> * Null will be returned if there is no the background color definition or * the background color definition is not valid. * * @return the background color */ public Color getBackgroundColor() { String property = mElement.getFoBackgroundColorAttribute(); Color color = null; try { color = Color.valueOf(property); } catch (Exception e) { Logger.getLogger(TableCellProperties.class.getName()).log(Level.WARNING, e.getMessage()); } return color; }
/** * Construct Color using the specified red, green and blue values in the range (0 - 255). * * @param red the red component. * @param green the green component. * @param blue the blue component. * @throws IllegalArgumentException if <code>red</code>, <code>green</code> or <code>blue</code> * are outside of the range 0 to 255, inclusive. */ public Color(int red, int green, int blue) { this(mapColorIntegerToString(red, green, blue)); }
/** * Return the corresponding {@link java.awt.Color <code>java.awt.Color</code>} instance of the Color data type. * * @return the converted {@link java.awt.Color <code>java.awt.Color</code>} instance.. */ public java.awt.Color getAWTColor(){ return mapColorToAWTColor(this); }
/** * Set the background color of this cell using string. The string must be a valid argument for * constructing {@link org.odftoolkit.odfdom.type.Color <code>org.odftoolkit.odfdom.type.Color</code>}. * * @param cellBackgroundColor * the background color that need to set. * If cellBackgroundColor is null, default background color #FFFFFF will be set. * @see org.odftoolkit.odfdom.type.Color */ public void setCellBackgroundColor(String cellBackgroundColor) { if (!Color.isValid(cellBackgroundColor)) { Logger.getLogger(OdfTableCell.class.getName()).log(Level.WARNING, "Parameter is invalid for datatype Color, default background color #FFFFFF will be set."); cellBackgroundColor = DEFAULT_BACKGROUND_COLOR; } splitRepeatedCells(); OdfStyleBase styleElement = getCellStyleElementForWrite(); if (styleElement != null) { OdfStyleProperty bkColorProperty = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties, OdfName.newName(OdfDocumentNamespace.FO, "background-color")); styleElement.setProperty(bkColorProperty, cellBackgroundColor); } }
} else if (threeHexRGBPattern.matcher(colorValue).matches()) { return mapColorFromThreeToSixHex(colorValue); } else if (colorValue.startsWith("rgb")) { colorValue = colorValue.substring(3); String[] rgbValues = colorValue.split(","); if (rgbValues.length == 3) { int r = mapColorValueToInteger(rgbValues[0].trim()); int g = mapColorValueToInteger(rgbValues[1].trim()); int b = mapColorValueToInteger(rgbValues[2].trim()); String rs = Integer.toHexString(r); String gs = Integer.toHexString(g);
/** * Return the background color. * <p> * Null will be returned if there is no the background color definition or * the background color definition is not valid. * * @return the background color */ public Color getBackgroundColor() { String property = mElement.getFoBackgroundColorAttribute(); Color color = null; try { color = Color.valueOf(property); } catch (Exception e) { Logger.getLogger(TableCellProperties.class.getName()).log(Level.WARNING, e.getMessage()); } return color; }
/** * Construct Color using the specified red, green and blue values in the range (0 - 255). * * @param red the red component. * @param green the green component. * @param blue the blue component. * @throws IllegalArgumentException if <code>red</code>, <code>green</code> or <code>blue</code> * are outside of the range 0 to 255, inclusive. */ public Color(int red, int green, int blue) { this(mapColorIntegerToString(red, green, blue)); }
/** * Return the corresponding {@link java.awt.Color <code>java.awt.Color</code>} instance of the Color data type. * * @return the converted {@link java.awt.Color <code>java.awt.Color</code>} instance.. */ public java.awt.Color getAWTColor(){ return mapColorToAWTColor(this); }
/** * Sets backgroundColor represented by the OpenDocument format used data * type {@odf.datatype color} See * <a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-color">W3C CSS * specification</a> for further details. * @param bkColor */ public void setBackgroundColor(Color bkColor) { mElement.setFoBackgroundColorAttribute(bkColor.toString()); }
/** * Set the background color of this cell using string. The string must be a valid argument for * constructing {@link org.odftoolkit.odfdom.type.Color <code>org.odftoolkit.odfdom.type.Color</code>}. * * @param cellBackgroundColor * the background color that need to set. * If cellBackgroundColor is null, default background color #FFFFFF will be set. * @see org.odftoolkit.odfdom.type.Color */ public void setCellBackgroundColor(String cellBackgroundColor) { if (!Color.isValid(cellBackgroundColor)) { Logger.getLogger(OdfTableCell.class.getName()).log(Level.WARNING, "Parameter is invalid for datatype Color, default background color #FFFFFF will be set."); cellBackgroundColor = DEFAULT_BACKGROUND_COLOR; } splitRepeatedCells(); OdfStyleBase styleElement = getCellStyleElementForWrite(); if (styleElement != null) { OdfStyleProperty bkColorProperty = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties, OdfName.newName(OdfDocumentNamespace.FO, "background-color")); styleElement.setProperty(bkColorProperty, cellBackgroundColor); } }
/** * Returns a Color instance representing the specified String value. * * @param colorValue a six (or three) number hexadecimal string representation of the Color * @return return a Color instance representing <code>stringValue</code>. * @throws IllegalArgumentException if the given argument is not a valid Color. */ public static Color valueOf(String colorValue) { return new Color(colorValue); }
/** * Construct Color by the parsing the given string. The string should be observed sRGB color standard * which starts with "#" and following with six numbers or three numbers in Hex format. * For example, "#FFFFFF" is a valid argument and white color will be constructed. * <p> * For further information on sRGB, * see <A href="http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html"> * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * </A>. * * @param color represented using the 3 or 6 HEX sRGB notation. * @throws IllegalArgumentException if the given argument is not a valid Color in sRGB HEX notation. */ public Color(String color) { if(!isValid(color)){ throw new IllegalArgumentException("parameter is invalid for datatype Color"); } if(color.length()==4){ mColorAsSixHexRGB = mapColorFromThreeToSixHex(color); }else{ mColorAsSixHexRGB = color; } }
} else if (threeHexRGBPattern.matcher(colorValue).matches()) { return mapColorFromThreeToSixHex(colorValue); } else if (colorValue.startsWith("rgb")) { colorValue = colorValue.substring(3); String[] rgbValues = colorValue.split(","); if (rgbValues.length == 3) { int r = mapColorValueToInteger(rgbValues[0].trim()); int g = mapColorValueToInteger(rgbValues[1].trim()); int b = mapColorValueToInteger(rgbValues[2].trim()); String rs = Integer.toHexString(r); String gs = Integer.toHexString(g);
/** * Return the background color. * <p> * Null will be returned if there is no the background color definition or * the background color definition is not valid. * * @return the background color */ public Color getBackgroundColor() { String property = mElement.getFoBackgroundColorAttribute(); Color color = null; try { color = Color.valueOf(property); } catch (Exception e) { Logger.getLogger(TableCellProperties.class.getName()).log(Level.WARNING, e.getMessage()); } return color; }
/** * Construct Color using the specified red, green and blue values in the range (0 - 255). * * @param red the red component. * @param green the green component. * @param blue the blue component. * @throws IllegalArgumentException if <code>red</code>, <code>green</code> or <code>blue</code> * are outside of the range 0 to 255, inclusive. */ public Color(int red, int green, int blue) { this(mapColorIntegerToString(red, green, blue)); }