de.enough.polish.preprocess.css
Class BackgroundConverter

java.lang.Object
  extended by de.enough.polish.preprocess.css.Converter
      extended by de.enough.polish.preprocess.css.BackgroundConverter
Direct Known Subclasses:
BackgroundConverter, BallBackgroundConverter, CombinedBackgroundConverter, DoubleGradientVerticalBackgroundConverter, GradientHorizontalBackgroundConverter, GradientVerticalBackgroundConverter, ImageBackgroundConverter, MaskBackgroundConverter, PulsatingBackgroundConverter, RoundRectBackgroundConverter, RoundTabBackgroundConverter, SimpleBackgroundConverter, SmoothColorBackgroundConverter, ThinSimpleBackgroundConverter, TigerStripesBackgroundConverter, Web20RoundRectBackgroundConverter, XmasSnowBackgroundConverter

public abstract class BackgroundConverter
extends Converter

The base class for all backgrounds.

The background creator is responsible for creating backgrounds for styles.

Copyright Enough Software 2004 - 2011

 history
        09-Mar-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
protected static String BACKGROUNDS_PACKAGE
           
protected  String borderColor
           
protected  String borderColorConstructor
           
protected  String borderWidth
           
protected  String color
           
protected  String colorConstructor
           
protected  boolean hasBorder
           
protected  String styleName
           
 
Fields inherited from class de.enough.polish.preprocess.css.Converter
ANCHORS, colorConverter, STANDALONE_MODIFIER, STANDALONE_MODIFIER_NON_FINAL
 
Constructor Summary
BackgroundConverter()
          Creates a new empty background
 
Method Summary
 void addBackground(ArrayList codeList, AttributesGroup background, String backgroundName, Style style, StyleSheet styleSheet, boolean isStandalone)
          Adds the J2ME code for the given background.
protected abstract  String createNewStatement(AttributesGroup background, Style style, StyleSheet styleSheet)
          Creates the statement for a new background based on the given properties.
 String parseAnchor(String attributeName, String anchorValue)
          Parses the given anchor value.
 boolean parseBoolean(String name, String value)
          Parses the given boolean value.
 float parseFloat(String name, String value)
          Parses the given float.
 int parseInt(String name, String value)
          Parses the given integer.
 String parseStroke(String name, String value)
          Parse the given stroke setting
 
Methods inherited from class de.enough.polish.preprocess.css.Converter
getUrl, isAlphaColor, parseAnchor, parseBoolean, parseColor, parseFloat, parseInt, parseInt, parseStroke, print, setColorConverter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BACKGROUNDS_PACKAGE

protected static final String BACKGROUNDS_PACKAGE
See Also:
Constant Field Values

color

protected String color

colorConstructor

protected String colorConstructor

borderWidth

protected String borderWidth

borderColor

protected String borderColor

borderColorConstructor

protected String borderColorConstructor

hasBorder

protected boolean hasBorder

styleName

protected String styleName
Constructor Detail

BackgroundConverter

public BackgroundConverter()
Creates a new empty background

Method Detail

addBackground

public void addBackground(ArrayList codeList,
                          AttributesGroup background,
                          String backgroundName,
                          Style style,
                          StyleSheet styleSheet,
                          boolean isStandalone)
                   throws BuildException
Adds the J2ME code for the given background.

Parameters:
codeList - the list at which the generated could should be appended to
background - the map containing all background settings
backgroundName - the name of this background
style - the parent style if any
styleSheet - the style-sheet into which the style is embedded
isStandalone - true when a new public background-field should be created, otherwise the background will be embedded in a style instantiation.
Throws:
BuildException - when there are invalid CSS declarations in the given background

createNewStatement

protected abstract String createNewStatement(AttributesGroup background,
                                             Style style,
                                             StyleSheet styleSheet)
                                      throws BuildException
Creates the statement for a new background based on the given properties.

Parameters:
background - the map containing all background settings
style - the parent style
styleSheet - the style-sheet into which the style is embedded
Returns:
the new statement, e.g. "new de.enough.polish.ui.backgrounds.SimpleBackground( 0x000000 )" no semicolon or comma must appended.
Throws:
BuildException - when there are invalid CSS declarations in the given background

parseInt

public int parseInt(String name,
                    String value)
Parses the given integer.

Parameters:
name - the name of the field
value - the int value as a String
Returns:
the int value.
Throws:
BuildException - when the value could not be parsed.

parseStroke

public String parseStroke(String name,
                          String value)
Parse the given stroke setting

Parameters:
name - the name of the field
value - the float value as a String.
Returns:
the resulting stroke value, either "Graphics.SOLID" or "Graphics.DOTTED"
Throws:
BuildException - when the value could not be parsed.

parseBoolean

public boolean parseBoolean(String name,
                            String value)
Parses the given boolean value.

Parameters:
name - the name of the field
value - the boolean value as a String
Returns:
the boolean value
Throws:
BuildException - when the value could not be parsed.

parseFloat

public float parseFloat(String name,
                        String value)
Parses the given float.

Parameters:
name - the name of the field
value - the float value as a String
Returns:
the float value.
Throws:
BuildException - when the value could not be parsed.

parseAnchor

public String parseAnchor(String attributeName,
                          String anchorValue)
Parses the given anchor value.

Parameters:
attributeName - the name of the attribute
anchorValue - the actual value, e.g. "top | left"
Returns:
a string containing the correct Java code, e.g. "Graphics.TOP | Graphics.LEFT"