Package org.apache.isis.viewer.dnd.drawing

Examples of org.apache.isis.viewer.dnd.drawing.Text


public class TextUtilsTest extends TestCase {

    public void testDrawingTextTruncated() {
        /* Word boundaries at 4, 11, 16, 21, 24 & 34 */
        final String title = "test string that will be truncated";
        final Text style = new DummyText();

        assertEquals("test string that will be truncated", TextUtils.limitText(title, style, 340));

        assertEquals("test string that will be...", TextUtils.limitText(title, style, 339));

View Full Code Here


        assertEquals("tes...", TextUtils.limitText(title, style, 60));
    }

    public void testDrawingTextTruncatedBeforeCommasEtc() {
        final String title = "test string, that? is truncated";
        final Text style = new DummyText();

        assertEquals("test string, that...", TextUtils.limitText(title, style, 210));

        assertEquals("test string...", TextUtils.limitText(title, style, 199));
    }
View Full Code Here

        assertEquals("test string...", TextUtils.limitText(title, style, 199));
    }

    public void testNoSpace() {
        final String title = "test string, that? is truncated";
        final Text style = new DummyText();

        assertEquals("...", TextUtils.limitText(title, style, 5));
    }
View Full Code Here

    public void setUp() throws Exception {
       
        TestToolkit.createInstance();

        view = new DummyView();
        final Text style = new DummyText();
        titleText = new TitleText(view, style, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK)) {
            @Override
            protected String title() {
                return title;
            }
View Full Code Here

        final String detail = ((MessageContent) getContent()).getDetail();
        final StringTokenizer st = new StringTokenizer(detail, "\n\r");
        while (st.hasMoreTokens()) {
            final String line = st.nextToken();
            final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
            size.ensureWidth((line.startsWith("\t") ? 20 : 0) + text.stringWidth(line));
            size.extendHeight(text.getTextHeight());
        }

        size.extend(40, 20);
        return size;
    }
View Full Code Here

    @Override
    public void draw(final Canvas canvas) {
        super.draw(canvas);

        final int left = 10;
        final Text title = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
        int y = 10 + title.getAscent();
        final String message = ((MessageContent) getContent()).getMessage();
        final String heading = ((MessageContent) getContent()).title();
        final String detail = ((MessageContent) getContent()).getDetail();

        final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
        canvas.drawText(heading, left, y, black, title);
        y += title.getTextHeight();
        final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
        canvas.drawText(message, left, y, 500, black, text);

        y += text.stringHeight(message, 500);
        canvas.drawText(detail, left, y, 1000, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1), text);
    }
View Full Code Here

        return 200;
    }

    @Override
    public Text getText() {
        return new Text() {

            @Override
            public int charWidth(final char ch) {
                return 10;
            }
View Full Code Here

        view = addBorder(parentContent, fieldContent, view);
        return view;
    }

    private View addBorder(final Content parentContent, final FieldContent fieldContent, View view) {
        final Text textStyle = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
        final Color colorStyle = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
        final TitleText titleText = new TitleText(view, textStyle, colorStyle) {
            @Override
            protected String title() {
                return parentContent.title() + "/" + fieldContent.getFieldName();
View Full Code Here

        final String message = ((MessageContent) getContent()).getMessage();
        final String heading = ((MessageContent) getContent()).title();

        size.ensureHeight(errorIcon.getHeight());
        final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
        final Text titleText = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
        size.extendWidth(text.stringWidth(message, MAX_TEXT_WIDTH));
        int textHeight = titleText.getLineHeight();
        textHeight += text.stringHeight(message, MAX_TEXT_WIDTH);
        size.ensureHeight(textHeight);

        size.ensureWidth(titleText.stringWidth(heading));

        size.extendWidth(errorIcon.getWidth());
        size.extendWidth(PADDING);

        size.extend(LEFT + RIGHT, TOP * 2);
 
View Full Code Here

        final int x = LEFT + errorIcon.getWidth() + PADDING;
        int y = TOP + 3 + Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getAscent();
        final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
        if (!heading.equals("")) {
            final Text title = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
            canvas.drawText(heading, x, y, black, title);
            y += title.getLineHeight();
        }
        canvas.drawText(message, x, y, MAX_TEXT_WIDTH, black, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.dnd.drawing.Text

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.