Package net.rim.device.api.ui

Examples of net.rim.device.api.ui.Font


        add(_domainField);
        add(_typeField);
        add(_contentField);

        Font default_font = Font.getDefault();
        heading_font = default_font.derive(Font.BOLD, 24);

        heading.setText("Event Log (newest items first)");
        heading.setFont(heading_font);

        add(separator1);
View Full Code Here


        super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR | MainScreen.HORIZONTAL_SCROLL);
        setTitle("NFC Read NDEF SmartTag v" + Constants.MYAPP_VERSION);
        this._screen = this;
        Utilities.log("XXXX NfcReadNdefSmartTag entered NfcReadNdefSmartTagScreen constructor");
       
        Font default_font = Font.getDefault();
        heading_font = default_font.derive(Font.BOLD, 24);

        heading.setText("Event Log (newest items first)");
        heading.setFont(heading_font);

        if (_listener_mgr.is_listening()) {
View Full Code Here

                    VGUtils.vgCreateImage(vg, bitmap, true,
                            VG10.VG_IMAGE_QUALITY_BETTER, rect);
        }

        // Get the default font and its FontSpec
        final Font font = Font.getDefault();
        final FontSpec fontSpec = font.getFontSpec();

        // Create text image
        _textImage =
                VGUtils.vgCreateTextAsImage(vg, fontSpec,
                        "Tap or click to swap screens", null, null);
View Full Code Here

            final int[] highlightLength) {
        final int x = rect.x;
        final int y = rect.y;
        final int textWidth = rect.width;

        final Font oldFont = g.getFont();

        final Font font = g.getFont();
        final Font highlightFont =
                font.derive(font.isBold() ? Font.EXTRA_BOLD : Font.BOLD);

        try {
            // Just draw the text normally if there's no highlight region
            final int numHighlightStartIndexes =
                    highlightStartIndex == null ? 0
                            : highlightStartIndex.length;

            if (numHighlightStartIndexes == 0) {
                g.setFont(oldFont);
                g.drawText(text, 0, text.length(), x, y, DrawStyle.ELLIPSIS,
                        textWidth);
                return;
            }

            int textStartIndex = 0;
            int offsetX = 0;

            boolean hasEndText = true;

            /**
             * <pre>
             *   Text Highlight Algorithm
             *  
             *   Given the set of highlightStartIndex values and the
             *   highlightLength values, we already know exactly which
             *   portions of the text need to be highlighted and how many
             *   characters to highlight.
             *
             *   The algorithm below uses the aforementioned values to
             *   determine the highlighted and non-highlighted regions of
             *   text. Then in a single pass through the text, it draws the
             *   text regions as required.
             *
             *   The text highlighting algorithm works as follows by iterating
             *   through the set of highlight indexes and performing the required
             *   text highlighting operations. These operations are as follows:
             *
             *   1. Calculate the start index for the current portion of the text
             *      to draw.
             *
             *   2. Determine if the start index for the text to draw is
             *      equal to the current highlight index. If it's not equal,
             *      the characters from the start index to the current highlight
             *      index are not highlighted. If it is equal, then the amount of
             *      characters to highlight is dictated by the highlight length.
             *      
             *   3. Draw the text before the current highlight index in a
             *      non-highlighted font.
             *
             *   4. Draw the text from the highlight index to the
             *      highlight index + highlight length in a highlighted font.
             *      Repeat steps 1 to 4 until the last highlight region is drawn.
             *  
             *   5. There may be text after the last highlight index that hasn't
             *      been drawn. Therefore, there is a check to see if there is
             *      any such text and if so, it is drawn in the non-highlighted font.
             * </pre>
             */

            int i = 0;
            for (i = 0; i < numHighlightStartIndexes; i++) {
                if (i != 0) {
                    // Calculate the start index for current portion of the
                    // text to draw.
                    textStartIndex =
                            highlightStartIndex[i - 1] + highlightLength[i - 1];
                }

                // Draw the text before the highlight region
                if (highlightStartIndex[i] != textStartIndex) {
                    g.setFont(oldFont);
                    g.drawText(text, textStartIndex, highlightStartIndex[i]
                            - textStartIndex, x + offsetX, y, 0, textWidth
                            - offsetX);
                }

                // Draw the highlighted text
                offsetX +=
                        oldFont.getAdvance(text, textStartIndex,
                                highlightStartIndex[i] - textStartIndex);
                g.setFont(highlightFont);
                g.drawText(text, highlightStartIndex[i], highlightLength[i], x
                        + offsetX, y, 0, textWidth - offsetX);

                final int nextOffsetX =
                        highlightFont.getAdvance(text, highlightStartIndex[i],
                                highlightLength[i]);
                offsetX += nextOffsetX;
            }

            i--;
View Full Code Here

        /**
         * @see net.rim.device.api.ui.Field#layout(int, int)
         */
        protected void layout(int width, int height) {
            final Font font = getFont();
            width = Math.min(width, font.getAdvance(_displayText) + height);
            height = Math.min(height, font.getHeight());
            setExtent(width, height);
        }
View Full Code Here

        // Read paths from file
        final PathFileReader pathReader = new PathFileReader();
        _svgPathsArray = pathReader.getPaths(vg11, "/res/paths.txt");

        // Get the default Font and its FontSpec
        final Font font = Font.getDefault();
        final FontSpec fontSpec = font.getFontSpec();

        // Create text images
        _textImage =
                VGUtils.vgCreateTextAsImage(vg, fontSpec,
                        "Tap or click to swap screens", null, null);
View Full Code Here

                _textbox_text.setTrait("#text", _textboxText);

                try {
                    // Obtain the font object corresponding to the text element
                    final FontFamily family = FontFamily.forName("BBMillbank");
                    final Font font =
                            family.getFont(Font.PLAIN, 15, Ui.UNITS_px);

                    // Set the X and Y co-ordinates of the cursor rect
                    _textbox_cursor.setFloatTrait("x",
                            (Display.getWidth() / 2 - 83 + font
                                    .getAdvance(_textboxText)));
                    _textbox_cursor.setFloatTrait("y", 144.0f);
                } catch (final ClassNotFoundException cnfe) {
                    System.out.println(cnfe.toString());
                }
View Full Code Here

            _paintRect.set(rect.x, rect.y + _titleAreaHeight, rect.width,
                    rect.height - _titleAreaHeight);
            _contentBorder.paint(graphics, _paintRect);

            final Font oldFont = graphics.getFont();
            try {
                graphics.setFont(_font);
                graphics.drawText(_title, rect.x + _titleBorder.getLeft(),
                        rect.y + _titleBorder.getTop(), DrawStyle.ELLIPSIS,
                        rect.width - _titleBorderLeftAndRight);
View Full Code Here

     * @see Field#layout(int, int)
     */
    protected void layout(final int width, final int height) {
        // Split text into lines based on the given width
        final StringBuffer currentLine = new StringBuffer();
        final Font font = getFont();
        _lines = new Vector();
        _words = new Vector();

        // Add words one by one and form lines
        final TextComponentStringTokenizer tokenizer =
                new TextComponentStringTokenizer(_text);
        while (tokenizer.hasMoreTokens()) {
            final String word = tokenizer.nextToken();
            _words.addElement(word);

            if (font.getAdvance(currentLine.toString() + word) < width) {
                // Current word still fits into the line, add it
                currentLine.append(word);
            } else {
                // The word doesn't fit, make a new line
                _lines.addElement(currentLine.toString());
View Full Code Here

TOP

Related Classes of net.rim.device.api.ui.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.