The Source for Java Technology Collaboration
User: Password:



Evan Summers

Evan Summers's Blog

Hyper Beans 1: Hyper Style

Posted by evanx on December 19, 2006 at 03:21 AM | Comments (1)

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


Code Snippet

We implement style objects for generating this series of articles, and also Gooey Beans, using quitehyper.

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

    List<QFontFamily> 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, eg. lightgrayColor, dashedLine, boldFontWeight, et al.



Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Looks interesting. Looked into Apache Fop some time ago but that doesn't look good to use for generateing documentation in different formats and it doesn't support html (or xhtml).

    This looks for usefull, after I quickly looked at it. What would also be very nice to have line numbers auto generated if you include java code in your documentation.

    Thanks for point out to this stuff Evan!

    Posted by: carmello on December 21, 2006 at 01:19 PM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds