de.enough.polish.preprocess.css
Class CssConverter

java.lang.Object
  extended by de.enough.polish.preprocess.css.Converter
      extended by de.enough.polish.preprocess.css.CssConverter

public class CssConverter
extends Converter

Converts CSS files to Java-Code.

Author:
Robert Virkus, robert@enough.de
 history
        04-Jan-2004 - rob creation
 

Field Summary
protected  AbbreviationsGenerator abbreviationGenerator
           
protected  CssAttributesManager attributesManager
           
protected  ArrayList referencedStyles
           
 
Fields inherited from class de.enough.polish.preprocess.css.Converter
ANCHORS, colorConverter, STANDALONE_MODIFIER, STANDALONE_MODIFIER_NON_FINAL
 
Constructor Summary
CssConverter()
          Creates a new CSS converter
 
Method Summary
 void convertStyleSheet(StringList sourceCode, StyleSheet styleSheet, Device device, Preprocessor preprocessor, Environment env)
          Converts a stylesheet to Java source code.
protected  CssAnimationSetting[] extractAnimationSettings(Style style)
           
protected  String getAttributeValue(String groupName, String attributeName, Map group)
          Retrieves a attribute value.
protected  String getColor(String value)
          Retrieves the color value as a decimal integer value.
protected  String getStyleReference(String value, Style parent, StyleSheet styleSheet)
          Gets a reference to another style.
protected  void processBackground(String backgroundName, AttributesGroup group, Style style, ArrayList codeList, boolean defineStylesOutside, StyleSheet styleSheet, boolean isStandalone, Environment env)
          Creates the background-definition.
protected  void processBorder(String borderName, AttributesGroup group, Style style, ArrayList codeList, boolean defineStylesOutside, StyleSheet styleSheet, boolean isStandalone, Environment env)
          Creates the border-definition.
protected  void processDefaultStyle(boolean defaultFontDefined, boolean defaultBackgroundDefined, boolean defaultBorderDefined, ArrayList codeList, ArrayList staticCodeList, boolean defineStylesOutside, StyleSheet styleSheet, Device device, Environment environment)
          Processes the default style:
protected  void processFields(int defaultValue, boolean includeVerticalHorizontal, HashMap fields, String groupName, Style style, ArrayList codeList, StyleSheet styleSheet, Device device)
          Processes the given fields - currently either "margins" or "paddings".
protected  void processFont(HashMap group, String groupName, Style style, ArrayList codeList, StyleSheet styleSheet, boolean isStandalone, Environment environment)
          Adds a font definition.
protected  void processLayout(AttributesGroup group, Style style, ArrayList codeList, StyleSheet styleSheet, Environment env)
          Creates the layout-declaration for the style.
protected  void processStyle(boolean declareVariable, Style style, ArrayList codeList, ArrayList staticCodeList, boolean defineStylesOutside, StyleSheet styleSheet, Device device, Environment environment)
          Processes the give style and includes the generated code to the codeList.
protected  void processStyle(Style style, ArrayList codeList, ArrayList staticCodeList, boolean defineStylesOutside, StyleSheet styleSheet, Device device, Environment environment)
          Processes the give style and includes the generated code to the codeList.
 void setAttributesManager(CssAttributesManager attributesManager)
          Sets the manager of CSS attributes.
 
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

referencedStyles

protected ArrayList referencedStyles

abbreviationGenerator

protected AbbreviationsGenerator abbreviationGenerator

attributesManager

protected CssAttributesManager attributesManager
Constructor Detail

CssConverter

public CssConverter()
Creates a new CSS converter

Method Detail

setAttributesManager

public void setAttributesManager(CssAttributesManager attributesManager)
Sets the manager of CSS attributes.

Parameters:
attributesManager - the manager for CSS attributes

convertStyleSheet

public void convertStyleSheet(StringList sourceCode,
                              StyleSheet styleSheet,
                              Device device,
                              Preprocessor preprocessor,
                              Environment env)
Converts a stylesheet to Java source code.

Parameters:
sourceCode - the source code to which the generated code is appended
styleSheet - the style sheet
device - the current device
preprocessor - a preprocessor
env - the environment

processDefaultStyle

protected void processDefaultStyle(boolean defaultFontDefined,
                                   boolean defaultBackgroundDefined,
                                   boolean defaultBorderDefined,
                                   ArrayList codeList,
                                   ArrayList staticCodeList,
                                   boolean defineStylesOutside,
                                   StyleSheet styleSheet,
                                   Device device,
                                   Environment environment)
Processes the default style:

Parameters:
defaultFontDefined - true when the default font has been defined already
defaultBackgroundDefined - true when the default background has been defined already
defaultBorderDefined - true when the default border has been defined already
codeList - the list to which the declarations should be added
styleSheet - the parent style sheet
device - the device for which the style should be processed
environment - the environment

processStyle

protected void processStyle(Style style,
                            ArrayList codeList,
                            ArrayList staticCodeList,
                            boolean defineStylesOutside,
                            StyleSheet styleSheet,
                            Device device,
                            Environment environment)
Processes the give style and includes the generated code to the codeList.

Parameters:
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
device - the device for which the style should be processed
environment - the environment

processStyle

protected void processStyle(boolean declareVariable,
                            Style style,
                            ArrayList codeList,
                            ArrayList staticCodeList,
                            boolean defineStylesOutside,
                            StyleSheet styleSheet,
                            Device device,
                            Environment environment)
Processes the give style and includes the generated code to the codeList.

Parameters:
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
device - the device for which the style should be processed
environment - the environment

extractAnimationSettings

protected CssAnimationSetting[] extractAnimationSettings(Style style)
Parameters:
style -
Returns:
an array of animation settings

getColor

protected String getColor(String value)
Retrieves the color value as a decimal integer value.

Parameters:
value - the color
Returns:
the color as a decimal integer value

getStyleReference

protected String getStyleReference(String value,
                                   Style parent,
                                   StyleSheet styleSheet)
Gets a reference to another style.

Parameters:
value - the reference
parent - the parent style
styleSheet - the sheet in which the style is embedded
Returns:
the name of the reference style

processLayout

protected void processLayout(AttributesGroup group,
                             Style style,
                             ArrayList codeList,
                             StyleSheet styleSheet,
                             Environment env)
Creates the layout-declaration for the style.

Parameters:
group - the layout directive
style - the parent style
codeList - the source code
styleSheet - the parent style sheet

processBorder

protected void processBorder(String borderName,
                             AttributesGroup group,
                             Style style,
                             ArrayList codeList,
                             boolean defineStylesOutside,
                             StyleSheet styleSheet,
                             boolean isStandalone,
                             Environment env)
Creates the border-definition.

Parameters:
borderName - the name of the border
group - the map containing the border information
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
isStandalone - true when a new public border-field should be created, otherwise the border will be embedded in a style instantiation.

processBackground

protected void processBackground(String backgroundName,
                                 AttributesGroup group,
                                 Style style,
                                 ArrayList codeList,
                                 boolean defineStylesOutside,
                                 StyleSheet styleSheet,
                                 boolean isStandalone,
                                 Environment env)
Creates the background-definition.

Parameters:
backgroundName - the name of the background
group - the map containing the background information
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
isStandalone - true when a new public background-field should be created, otherwise the background will be embedded in a style instantiation.

processFont

protected void processFont(HashMap group,
                           String groupName,
                           Style style,
                           ArrayList codeList,
                           StyleSheet styleSheet,
                           boolean isStandalone,
                           Environment environment)
Adds a font definition.

Parameters:
group - the font definition
groupName - the name of this font - usually "font" or "labelFont"
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
isStandalone - true when a new public font-field should be created, otherwise the font will be embedded in a style instantiation.

getAttributeValue

protected String getAttributeValue(String groupName,
                                   String attributeName,
                                   Map group)
Retrieves a attribute value.

Parameters:
groupName - the name of the attribute-group, e.g. "font" or "background"
attributeName - the name of the attribute, e.g. "color"
group - the attribute group
Returns:
the value or null when not defined

processFields

protected void processFields(int defaultValue,
                             boolean includeVerticalHorizontal,
                             HashMap fields,
                             String groupName,
                             Style style,
                             ArrayList codeList,
                             StyleSheet styleSheet,
                             Device device)
Processes the given fields - currently either "margins" or "paddings".

Parameters:
defaultValue - the default value for unset fields
includeVerticalHorizontal - true when vertical and horizontal fields should also be processed (this is the case for paddings).
fields - the definition of the fields
groupName - the name of the group
style - the style
codeList - the array list into which generated code is written
styleSheet - the parent style sheet
device - the device for which the fields should be processed