private String convertColorToString( final BorderEdge borderEdge ) { final Color o = borderEdge.getColor(); if ( o == null ) { return null; } return ColorValueConverter.colorToString( o ); }
/** * Parses a color entry. If the entry is in hexadecimal or octal notation, the color is created using Color.decode(). * If the string denotes a constant name of one of the color constants defined in java.awt.Color, this constant is * used. * <p/> * As fallback the supplied default value is returned if no color can be parsed. * * @param color * the color (as a string). * @param defaultValue * the default value (returned if no color can be parsed). * @return the paint. */ public static Color parseColor( final String color, final Color defaultValue ) { if ( color == null ) { return defaultValue; } try { // get color by hex or octal value return (Color) new ColorValueConverter().toPropertyValue( color ); } catch ( Exception nfe ) { return defaultValue; } }
public ContentStyleReadHandler() { colorValueConverter = new ColorValueConverter(); }
/** * Creates an object based on this description. * * @return The object. */ public Object createObject() { final String value = (String) getParameter( "value" ); if ( value == null ) { return null; } try { return valueConverter.toPropertyValue( value.trim() ); } catch ( BeanException e ) { return null; } }
/** * Sets the parameters of this description object to match the supplied object. * * @param o * the object (should be an instance of <code>Color</code>). * @throws ObjectFactoryException * if there is a problem while reading the properties of the given object. */ public void setParameterFromObject( final Object o ) throws ObjectFactoryException { if ( !( o instanceof Color ) ) { throw new ObjectFactoryException( "Is no instance of java.awt.Color" ); } final Color c = (Color) o; try { setParameter( "value", valueConverter.toAttributeValue( c ) ); } catch ( BeanException e ) { throw new ObjectFactoryException( "Failed to convert color to string", e ); } } }
/** * Creates a new object description. */ public ColorObjectDescription() { super( Color.class ); valueConverter = new ColorValueConverter(); setParameterDefinition( "value", String.class ); }
/** * Converts the attribute to a string. * * @param o * the attribute ({@link Integer} expected). * @return A string representing the {@link Integer} value. */ public String toAttributeValue( final Object o ) throws BeanException { if ( o == null ) { return null; } if ( !( o instanceof Color ) ) { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a Color." ); } final Color c = (Color) o; return colorToString( c ); }
registeredClasses.put( Character.class, new CharacterValueConverter() ); registeredClasses.put( Character.TYPE, new CharacterValueConverter() ); registeredClasses.put( Color.class, new ColorValueConverter() ); registeredClasses.put( Double.class, new DoubleValueConverter() ); registeredClasses.put( Double.TYPE, new DoubleValueConverter() );
bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "color", ColorValueConverter.colorToString( value ) ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "fill-color", ColorValueConverter.colorToString( value ) );
if ( BorderEdge.EMPTY.equals( top ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-top-color", ColorValueConverter.colorToString( top.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-top-width", pointConverter.format( StrictGeomUtility.toExternalValue( top.getWidth() ) ) ); if ( BorderEdge.EMPTY.equals( left ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-left-color", ColorValueConverter.colorToString( left.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-left-width", pointConverter.format( StrictGeomUtility.toExternalValue( left.getWidth() ) ) ); if ( BorderEdge.EMPTY.equals( bottom ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-bottom-color", ColorValueConverter.colorToString( bottom.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-bottom-width", pointConverter.format( StrictGeomUtility.toExternalValue( bottom.getWidth() ) ) ); if ( BorderEdge.EMPTY.equals( right ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-right-color", ColorValueConverter.colorToString( right.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-right-width", pointConverter.format( StrictGeomUtility.toExternalValue( right.getWidth() ) ) ); if ( backgroundColor != null ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "background-color", ColorValueConverter.colorToString( backgroundColor ) );
attList.setAttribute( null, "background-color", ColorValueConverter.colorToString( color ) ); attList.setAttribute( null, "border-top-color", ColorValueConverter.colorToString( top.getColor() ) ); attList.setAttribute( null, "border-top-width", String.valueOf( StrictGeomUtility .toExternalValue( top.getWidth() ) ) ); attList.setAttribute( null, "border-left-color", ColorValueConverter.colorToString( left.getColor() ) ); attList.setAttribute( null, "border-left-width", String.valueOf( StrictGeomUtility.toExternalValue( left .getWidth() ) ) ); attList.setAttribute( null, "border-bottom-color", ColorValueConverter.colorToString( bottom.getColor() ) ); attList.setAttribute( null, "border-bottom-width", String.valueOf( StrictGeomUtility.toExternalValue( bottom .getWidth() ) ) ); attList.setAttribute( null, "border-right-color", ColorValueConverter.colorToString( right.getColor() ) ); attList.setAttribute( null, "border-right-width", String.valueOf( StrictGeomUtility.toExternalValue( right .getWidth() ) ) );
final Color value = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); bandStyleAtts .setAttribute( BundleNamespaces.STYLE, "background-color", ColorValueConverter.colorToString( value ) ); if ( ObjectUtilities.equal( top, left ) && ObjectUtilities.equal( top, right ) && ObjectUtilities.equal( top, bottom ) ) { bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-color", ColorValueConverter.colorToString( top ) ); } else { bandStyleAtts .setAttribute( BundleNamespaces.STYLE, "border-top-color", ColorValueConverter.colorToString( top ) ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-left-color", ColorValueConverter .colorToString( left ) ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-bottom-color", ColorValueConverter .colorToString( bottom ) ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-right-color", ColorValueConverter .colorToString( right ) ); final Color value = (Color) style.getStyleProperty( ElementStyleKeys.BORDER_TOP_COLOR ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-top-color", ColorValueConverter .colorToString( value ) ); .colorToString( value ) ); .colorToString( value ) ); .colorToString( value ) ); final Color value = (Color) style.getStyleProperty( ElementStyleKeys.BORDER_BREAK_COLOR ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "border-break-color", ColorValueConverter
if ( BorderEdge.EMPTY.equals( top ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-top-color", ColorValueConverter.colorToString( top.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-top-width", pointConverter.format( StrictGeomUtility.toExternalValue( sblp.getBorderTop() ) ) ); if ( BorderEdge.EMPTY.equals( left ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-left-color", ColorValueConverter.colorToString( left.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-left-width", pointConverter.format( StrictGeomUtility.toExternalValue( sblp.getBorderLeft() ) ) ); if ( BorderEdge.EMPTY.equals( bottom ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-bottom-color", ColorValueConverter.colorToString( bottom.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-bottom-width", pointConverter.format( StrictGeomUtility.toExternalValue( sblp.getBorderBottom() ) ) ); if ( BorderEdge.EMPTY.equals( right ) == false || ignoreEmptyBorders == false ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-right-color", ColorValueConverter.colorToString( right.getColor() ) ); attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "border-right-width", pointConverter.format( StrictGeomUtility.toExternalValue( sblp.getBorderRight() ) ) ); if ( backgroundColor != null ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "background-color", ColorValueConverter.colorToString( backgroundColor ) ); if ( color != null ) {
if ( backgroundColor != null ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "background-color", ColorValueConverter.colorToString( backgroundColor ) ); if ( color != null ) { attributeList.setAttribute( XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "color", ColorValueConverter.colorToString( color ) );