Package com.day.image

Examples of com.day.image.Font


        Color[] colors = new Color[]{
                Color.WHITE,
                Color.WHITE};
        Font[] fonts = new Font[]{
                new Font("Myriad Pro", 15 * scale, Font.BOLD),
                new Font("MyriadPro-Light", 18 * scale)};

        // load background image from docroot
        Component c = WCMUtils.getComponent(ctx.resource);
        Layer bg = ImageHelper.createLayer(c.getLocalResource("background.png"));

View Full Code Here


        if (title == null) {
            title = currentPage.getName();
        }
        title = title.toUpperCase();
        Paint titleColor = Color.WHITE;
        Font titleFont = new Font("Myriad Pro", 10 * scale, Font.BOLD);
        int titleBase = 10 * scale;

        String subtitle = currentPage.getProperties().get("subtitle", "");
        Paint subtitleColor = new Color(0xffa9afb1, true);
        Font subTitleFont = new Font("Tahoma", 7);
        int subTitleBase = 20;

        // load background image from docroot
        Component c = WCMUtils.getComponent(ctx.resource);
        Layer bg = ImageHelper.createLayer(c.getLocalResource("navimage_bg.jpg"));

        // draw the title text (4 times bigger)
        Rectangle2D titleExtent = titleFont.getTextExtent(0, 0, 0, 0, title, Font.ALIGN_LEFT, 0, 0);
        Rectangle2D subtitleExtent = subTitleFont.getTextExtent(0, 0, 0, 0, subtitle, Font.ALIGN_LEFT, 0, 0);
        // check if subtitleExtent is too width
        if ( subtitle.length() > 0 ) {
            int titleWidth = (int)titleExtent.getWidth() / scale;
            if ( subtitleExtent.getWidth() > titleWidth && subtitleExtent.getWidth() + 2 * paddingX > bg.getWidth() ) {
                int charWidth = (int)subtitleExtent.getWidth() / subtitle.length();
                int maxWidth = (bg.getWidth() > titleWidth + * paddingX ? bg.getWidth() - 2 * paddingX : titleWidth);
                int len = (maxWidth - ( 2 * charWidth) ) / charWidth;
                subtitle = subtitle.substring(0, len) + "...";
                subtitleExtent = subTitleFont.getTextExtent(0, 0, 0, 0, subtitle, Font.ALIGN_LEFT, 0, 0);
            }
        }
        int width = Math.max((int) titleExtent.getWidth(), (int) subtitleExtent.getWidth());

        Layer text = new Layer(width, (int) titleExtent.getHeight() + 40, new Color(0x01ffffff, true));
View Full Code Here

TOP

Related Classes of com.day.image.Font

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.