Package com.sun.dtv.lwuit

Examples of com.sun.dtv.lwuit.Font


    public void drawMonthView(Graphics g, com.sun.dtv.lwuit.Calendar cal, Component mv) {

        drawBorder(g, mv, 0x020202, 0x080808, 2);
        setFG(g, mv);

        Font f = mv.getStyle().getFont();
        int fh = f.getHeight();

        int w = mv.getWidth();
        int h = mv.getHeight();
        int labelH = (fh + DAY_SPACE_H);
        int ch = h - labelH;

        int dayWidth = (w / 7);
        int dayHeight = (ch / 6);

        long sd = cal.getSelectedDay();
        Date date = new Date();

        int fix = f.stringWidth("22") / 2;


        g.setColor(mv.getStyle().getBgSelectionColor());
        g.fillRect(mv.getX() + 2, mv.getY() + 2, mv.getWidth() - 4, mv.getStyle().getFont().getHeight());
View Full Code Here


        int line = ta.getLines();
        int oX = g.getClipX();
        int oY = g.getClipY();
        int oWidth = g.getClipWidth();
        int oHeight = g.getClipHeight();
        Font f = ta.getStyle().getFont();
        int fontHeight = f.getHeight();
        for (int i = 0; i < line; i++) {
            int x = ta.getX() + ta.getStyle().getPadding(Component.LEFT);
            int y = ta.getY() + ta.getStyle().getPadding(Component.TOP) +
                    (ta.getRowsGap() + fontHeight) * i;
            if(Rectangle.intersects(x, y, ta.getWidth(), fontHeight, oX, oY, oWidth, oHeight)) {
View Full Code Here

                prefW = Math.max(prefW, icon.getWidth());
                prefH = Math.max(prefH, icon.getHeight());
            }
        }
        String text = l.getText();
        Font font = style.getFont();
        if (font == null) {
            System.out.println("Missing font for " + l);
            font = Font.getDefaultFont();
        }
        if (text != null && text.length() > 0) {
            //add the text size
            switch (l.getTextPosition()) {
                case Label.LEFT:
                case Label.RIGHT:
                    prefW += font.stringWidth(text);
                    prefH = Math.max(prefH, font.getHeight());
                    break;
                case Label.BOTTOM:
                case Label.TOP:
                    prefW = Math.max(prefW, font.stringWidth(text));
                    prefH += font.getHeight();
                    break;
            }
        }
        //add the state image(relevant for CheckBox\RadioButton)
        if (stateImage != null) {
View Full Code Here

    /**
     * @inheritDoc
     */
    public Dimension getMonthViewPreferredSize(Component mv) {
        Font f = mv.getStyle().getFont();
        int fh = f.getHeight();
        int dayWidth = f.stringWidth("22");

        int w = (dayWidth + DAY_SPACE_W) * 7;
        int h = (fh + DAY_SPACE_H) * 5;

        return new Dimension(w + mv.getStyle().getPadding(Component.RIGHT) + mv.getStyle().getPadding(Component.LEFT), h + mv.getStyle().getPadding(Component.TOP) + mv.getStyle().getPadding(Component.BOTTOM));
View Full Code Here

     * @inheritDoc
     */
    public Dimension getTextAreaPreferredSize(TextArea ta) {
        int prefW = 0;
        int prefH = 0;
        Font f = ta.getStyle().getFont();

        //if this is a text field the preferred size should be the text width
        if (ta.getRows() == 1) {
            prefW = f.stringWidth(ta.getText());
        } else {
            prefW = f.stringWidth("W") * ta.getColumns();
        }
        int rows = ta.getRows();
        prefH = (f.getHeight() + 2) * rows;
        int columns = ta.getColumns();
        String str = "";
        for (int iter = 0; iter < columns; iter++) {
            str += 'W';
        }
        prefW = Math.max(prefW, f.stringWidth(str));
        prefH = Math.max(prefH, rows * f.getHeight());

        return new Dimension(prefW + ta.getStyle().getPadding(Component.RIGHT) + ta.getStyle().getPadding(Component.LEFT), prefH + ta.getStyle().getPadding(Component.TOP) + ta.getStyle().getPadding(Component.BOTTOM));
    }
View Full Code Here

        int gap = l.getGap();
        int stateIconSize = 0;
        int stateIconYPosition = 0;
        String text = l.getText();
        Style style = l.getStyle();
        Font font = style.getFont();
        int fontHeight = 0;
        if (text == null) {
            text = "";
        }
        if(text.length() > 0){
            fontHeight = font.getHeight();
        }
       
        if (stateIcon != null) {
            stateIconSize = stateIcon.getWidth(); //square image width == height
            stateIconYPosition = l.getY() + l.getStyle().getPadding(Component.TOP) + (l.getHeight() - l.getStyle().getPadding(Component.TOP) - l.getStyle().getPadding(Component.BOTTOM)) / 2 - stateIconSize / 2;
            preserveSpaceForState = stateIconSize + gap;
            g.drawImage(stateIcon, l.getX() + l.getStyle().getPadding(Component.LEFT), stateIconYPosition);
        }

        //default for bottom left alignment
        int x = l.getX() + l.getStyle().getPadding(Component.LEFT) + preserveSpaceForState;
        int y = l.getY() + l.getStyle().getPadding(Component.TOP);

        //set initial x,y position according to the alignment and textPosition
        if (l.getAlignment() == Component.LEFT) {
            switch (l.getTextPosition()) {
                case Label.LEFT:
                case Label.RIGHT:
                    y = y + (l.getHeight() - (l.getStyle().getPadding(Component.TOP) + l.getStyle().getPadding(Component.BOTTOM) + Math.max(((icon != null) ? icon.getHeight() : 0), l.getStyle().getFont().getHeight()))) / 2;
                    break;
                case Label.BOTTOM:
                case Label.TOP:
                    y = y + (l.getHeight() - (l.getStyle().getPadding(Component.TOP) + l.getStyle().getPadding(Component.BOTTOM) + ((icon != null) ? icon.getHeight() + gap : 0) + l.getStyle().getFont().getHeight())) / 2;
                    break;
            }
        } else if (l.getAlignment() == Component.CENTER) {
            switch (l.getTextPosition()) {
                case Label.LEFT:
                case Label.RIGHT:
                    x = x + (l.getWidth() - (preserveSpaceForState +
                            style.getPadding(Component.LEFT) +
                            style.getPadding(Component.RIGHT) +
                            ((icon != null) ? icon.getWidth() : 0) +
                            font.stringWidth(text))) / 2;
                    x = Math.max(x, l.getX() + style.getPadding(Component.LEFT) + preserveSpaceForState);
                    y = y + (l.getHeight() - (style.getPadding(Component.TOP) +
                            style.getPadding(Component.BOTTOM) +
                            Math.max(((icon != null) ? icon.getHeight() : 0),
                            fontHeight))) / 2;
                    break;
                case Label.BOTTOM:
                case Label.TOP:
                    x = x + (l.getWidth() - (preserveSpaceForState + style.getPadding(Component.LEFT) +
                            style.getPadding(Component.RIGHT) +
                            Math.max(((icon != null) ? icon.getWidth() : 0),
                            font.stringWidth(text)))) / 2;
                    x = Math.max(x, l.getX() + style.getPadding(Component.LEFT) + preserveSpaceForState);
                    y = y + (l.getHeight() - (style.getPadding(Component.TOP) +
                            style.getPadding(Component.BOTTOM) +
                            ((icon != null) ? icon.getHeight() + gap : 0) +
                            fontHeight)) / 2;
                    break;
            }
        } else if (l.getAlignment() == Component.RIGHT) {
            switch (l.getTextPosition()) {
                case Label.LEFT:
                case Label.RIGHT:
                    x = l.getX() + l.getWidth() - style.getPadding(Component.RIGHT) -
                            (preserveSpaceForState + ((icon != null) ? (icon.getWidth() + gap) : 0) +
                            font.stringWidth(text));
                    x = Math.max(x, l.getX() + style.getPadding(Component.LEFT) + preserveSpaceForState);

                    y = y + (l.getHeight() - (style.getPadding(Component.TOP) +
                            style.getPadding(Component.BOTTOM) +
                            Math.max(((icon != null) ? icon.getHeight() : 0),
                            fontHeight))) / 2;
                    break;
                case Label.BOTTOM:
                case Label.TOP:
                    x = l.getX() + l.getWidth() - style.getPadding(Component.RIGHT) -
                            preserveSpaceForState - (Math.max(((icon != null) ? (icon.getWidth()) : 0),
                            font.stringWidth(text)));
                    x = Math.max(x, l.getX() + style.getPadding(Component.LEFT) + preserveSpaceForState);
                    y = y + (l.getHeight() - (style.getPadding(Component.TOP) +
                            style.getPadding(Component.BOTTOM) +
                            ((icon != null) ? icon.getHeight() + gap : 0) + fontHeight)) / 2;
                    break;
View Full Code Here

        return drawnW;
    }

    protected int drawLabelText(Graphics g, Label l, String text, int x, int y, int textSpaceW) {

        Font f = l.getStyle().getFont();
        if (!l.isTickerRunning()) {
            int txtW = f.stringWidth(text);
            //if there is no space to draw the text add ... at the end
            if (txtW > textSpaceW && textSpaceW > 0) {
                if (l.isEndsWith3Points()) {
                    String points = "...";
                    int index = 1;
                    String tmp = text.substring(0, index);
                    int pointsW = f.stringWidth(points);
                    while (f.stringWidth(tmp) + pointsW < textSpaceW) {
                        index++;
                        if (index >= text.length()) {
                            break;
                        }
                        tmp = text.substring(0, index);
                    }
                    tmp = text.substring(0, index - 1) + points;
                    text = tmp;
                }
               
            }
        }

        g.drawString(text, l.getShiftText() + x, y);
        return Math.min(f.stringWidth(text), textSpaceW);
    }
View Full Code Here

        Calendar calendar = Calendar.getInstance();
        long firstOfMonth = getMonthExtent(calendar, cal.getDate(), true);

        int w = mv.getWidth();

        Font f = mv.getStyle().getFont();
        int fh = f.getHeight();

        int labelH = (fh + DAY_SPACE_H);

        int dayWidth = (w / 7);
        long currentDay = firstOfMonth;
View Full Code Here

        String displayText = getTextFieldString(ta);

        Style style = ta.getStyle();
        int x = 0;
        int cursorCharPosition = ta.getCursorPosition();
        Font f = ta.getStyle().getFont();
        int cursorX = 0;
        int xPos = 0;
        if (cursorCharPosition > 0) {
            xPos = f.stringWidth(ta.getText().substring(0, cursorCharPosition));
            cursorX = ta.getX() + style.getPadding(Component.LEFT) + xPos;
            if (ta.getWidth() > (f.getHeight() * 2) && cursorX >= ta.getWidth() - f.getHeight()) {
                while (x + xPos >= ta.getWidth() - f.getHeight() * 2) {
                    x--;
                }
            }
        }

        g.drawString(displayText, ta.getX() + x + style.getPadding(Component.LEFT),
                ta.getY() + style.getPadding(Component.TOP));

        String inputMode = ta.getInputMode();
        int inputModeWidth = f.stringWidth(inputMode);
        if (ta.handlesInput() && ta.getWidth() / 2 > inputModeWidth) {
            int drawXPos = ta.getX() + style.getPadding(Component.LEFT);
            if (xPos < ta.getWidth() / 2) {
                // draw on the right side
                drawXPos = drawXPos + ta.getWidth() - inputModeWidth - style.getPadding(Component.RIGHT) - style.getPadding(Component.LEFT);
View Full Code Here

     * Draws the cursor of the text field, blinking is handled simply by avoiding
     * a call to this method.
     */
    public void drawTextFieldCursor(Graphics g, TextField ta) {
        Style style = ta.getStyle();
        Font f = style.getFont();

        // display ******** if it is a password field
        String displayText = getTextFieldString(ta);
       
        int xPos = 0;
        int cursorCharPosition = ta.getCursorPosition();
        if (cursorCharPosition > 0) {
            xPos = f.stringWidth(displayText.substring(0, cursorCharPosition));
        }
        int cursorX = ta.getX() + style.getPadding(Component.LEFT) + xPos;
        int cursorY = ta.getY() + style.getPadding(Component.TOP);
        int x = 0;
        if (ta.getWidth() > (f.getHeight() * 2) && cursorX >= ta.getWidth() - f.getHeight()) {
            while (x + xPos >= ta.getWidth() - f.getHeight() * 2) {
                x--;
            }
        }
        int oldColor = g.getColor();
        g.setColor(style.getFgSelectionColor());
        g.drawLine(cursorX + x, cursorY, cursorX + x, cursorY + f.getHeight());
        g.setColor(oldColor);
    }
View Full Code Here

TOP

Related Classes of com.sun.dtv.lwuit.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.