Skip to main content

Hyper Beans 1: Hyper Style

Posted by evanx on December 19, 2006 at 3:21 AM PST

We wanna style our documents and reports using neutral Java objects, to generate output artifacts e.g. HTML with CSS, and/or other formats, e.g. PDF and Excel (for reports). We model our style objects after CSS, e.g. font-family, font-weight, text-decoration, et al.

Hyper Style: A part of the "Hyper Beans" part of a trilogy in 42 parts"

We implement style objects for generating this series of articles, using quitehyper.

public class GooeyBeansStyleManager extends QStyleManager {
    QStyle javaStyle = createStyle("javaStyle");
    QStyle paragraphStyle = createStyle("paragraphStyle");
    QStyle sectionStyle = createStyle("sectionStyle");
    QStyle subsectionStyle = createStyle("subsectionStyle");
    ...
    List courier = Arrays.asList(newCourierFontFamily,
            courierFontFamily, monospacedFontFamily);

    List verdana = Arrays.asList(verdanaFontFamily,
            helveticaFontFamily, arialFontFamily, sansserifFontFamily);
   
    public GooeyArticleStyleManager() {
        javaStyle.setFontFamily(courier);
        javaStyle.setFontSize(11);
        javaStyle.setBorder(dashedLine, 1);
        javaStyle.setBorderColor(lightgrayColor);
        javaStyle.setPadding(4, leftLocation);
        javaStyle.setWidth(800);
        javaStyle.setBackgroundColor(0xf4f4f4);
        paragraphStyle.setFontFamily(verdana);
        paragraphStyle.setFontSize(10);
        sectionStyle.setFontFamily(verdana);
        sectionStyle.setFontWeight(boldFontWeight);
        sectionStyle.setFontStyle(italicFontStyle);
        ...
    }
    ...
}

where we statically import style enums and constants, e.g. lightgrayColor, dashedLine, boldFontWeight, et al.

Resources

https://code.google.com/p/vellum/ - where i will collate these articles and their code.

Related Topics >>