Package javax.microedition.lcdui

Examples of javax.microedition.lcdui.Font


    if (RenderedWord.fontSize == fontSize) {
    return;
  }
    RenderedWord.fontSize = fontSize;
    for (int i = 0; i < 7; i++) {
    Font f = Font.getFont(Font.FACE_PROPORTIONAL, i, fontSize);
      RenderedWord.font[i] = f;
      RenderedWord.fontWidth[i] = f.stringWidth(" ");
    }
    RenderedWord.heightFont = Font.getFont(Font.FACE_PROPORTIONAL,
      Font.STYLE_PLAIN, fontSize).getHeight() +
      AbstractView.getLineSpace();
  }
View Full Code Here


        {
            Image buffer = null;
            try
            {
                final int selectedIndex = this.selectedIndex;
                final Font font = this.font;
                final RowSet rowSet = this.rowSet;
                final String[] labels = this.labels;
                Graphics g = graphics;
                final int height = getHeight();
                if( !isDoubleBuffered() )
                {
                    buffer = Image.createImage( getWidth(), height );
                    g = buffer.getGraphics();
                }
                g.setColor( background );
                g.fillRect( 0, 0, getWidth(), height );
//                g.setColor( 0x85B0C6 );
//                g.fillRect( 0, 0, getWidth(), height );
//                g.setColor( background );
//                g.fillArc( 0, 0, getWidth(), height, 45, -45 );
                g.setFont( font );
                g.setColor( color );
                int y = 0;
                // Paint buttons
                final int fontHeight = font.getHeight();
                String status = null;
                if( buttons.size() > 0 )
                {
                    status = paintButtons( g );
                    y += 7 + maxButtonHeight;
                }
                if(
                        rowSet != null && rowSet.size() > 0 && fields.size() > 0 &&
                        labels != null && labels.length > 0
                )
                {
                    final int size = rowSet.size();
                    // Paint rows
                    rowSet.openSource();
                    final int itemCount = indexes.length;
                    for( int i = 0; i < itemCount; i++ )
                    {
                        final int index = indexes[i];
                        final boolean isSelectedLine = index == selectedIndex;
                        paintLine(
                                g,
                                y,
                                Tools.splitInLines(
                                    labels[i],
                                    font,
                                    font,
                                    getWidth() - 2,
                                    isSelectedLine ? currentMaxLines : 1,
                                    wrap
                                ),
                                isSelectedLine
                        );
                        y += lineHeight * (isSelectedLine ? currentMaxLines : 1);
                    }
                    if( selectedPane == LIST_PANE )
                    {
                        status = (selectedIndex + 1) + "/" + size;
                    }
                }
                else if( selectedPane == LIST_PANE )
                {
                    status = ResourceManager.getResource( "rowSetListView.noData" );
                }
                y = height - fontHeight - 2;
                g.setColor( color );
                g.drawLine( 1, y, getWidth() - 2, y );
                g.drawString(
                        status != null ? status : "",
                        1,
                        height - fontHeight + font.getBaselinePosition(),
                        Graphics.LEFT | Graphics.BASELINE
                );
            }
            catch( Exception e )
            {
View Full Code Here

        }
    }

    private String paintButtons( final Graphics g )
    {
        final Font font = this.font;
        int y = 1;
        int x = 1;
        final int maxX = getWidth() - 2;
        final int count = buttons.size();
        g.setColor( color );
        g.setStrokeStyle( Graphics.SOLID );
        ToolButton selected = null;
        final int fontHeight = font.getHeight();
        final int baseLine = font.getBaselinePosition();
        for( int i = 0; i < count && x < maxX; i++ )
        {
            final ToolButton button = (ToolButton) buttons.elementAt( i );
            final boolean isSelected = selectedPane == TOOLBAR_PANE && i == selectedButton;
            if( button.image != null )
            {
                if( isSelected )
                {
                    g.setColor( 0 );
                    g.drawRect(
                            x,
                            y,
                            button.image.getWidth() + 2,
                            button.image.getHeight() + 2
                    );
                    selected = button;
                }
                g.drawImage( button.image, x + 1, y + 1, Graphics.LEFT | Graphics.TOP );
                x += button.image.getWidth() + 2;
            }
            else if( button.text != null )
            {
                final String text = button.text;
                final int width = font.charsWidth(
                        text.toCharArray(),
                        0,
                        text.length()
                ) + 2;
                if( isSelected )
View Full Code Here

    public void addButton( final ToolButton button )
    {
        if( button.image == null )
        {
            final Font font = this.font;
            final int width = font.stringWidth( button.text ) + 2;
            final int height = font.getHeight() + 2;
            button.image = Image.createImage( width, height );
            final Graphics g = button.image.getGraphics();
            g.setColor( 0xD0D0D0 );
            g.fillRect( 0, 0, width, height );
            g.setColor( color );
            g.drawString(
                    button.text,
                    1,
                    1 + font.getBaselinePosition(),
                    Graphics.LEFT | Graphics.BASELINE
            );
            if( button.help == null )
            {
                button.help = button.text;
View Full Code Here

                ((DataListView) browser).getDataList().setWrap(
                        viewDef.getWrap() != null &&
                        viewDef.getWrap().booleanValue()
                );
            }
            Font font = null;
            if( viewDef.getFontFace() != null )
            {
                font = Font.getFont(
                        viewDef.getFontFace().intValue(),
                        viewDef.getFontStyle() != null ?
View Full Code Here

                menuDef.getFontFace() != null ||
                menuDef.getFontStyle() != null ||
                menuDef.getFontSize() != null
        )
        {
            final Font font = Font.getFont(
                    menuDef.getFontFace() != null ?
                    menuDef.getFontFace().intValue() :
                    Font.FACE_PROPORTIONAL,
                    menuDef.getFontStyle() != null ?
                    menuDef.getFontStyle().intValue() :
View Full Code Here

        final int count = words.size();
        final StringBuffer line = new StringBuffer();
        int lineWidth = 0;
        int index = 0;
        boolean skipping = false;
        Font font = font1;
        for( int i = 0; i < count && index < lines; i++ )
        {
            final String word = (String) words.elementAt( i );
            if( !skipping )
            {
                final int stringWidth = font.stringWidth( word );
                boolean newLine = false;
                if( word.charAt( 0 ) == '\n' )
                {
                    newLine = true;
                }
View Full Code Here

    private void testFontListBug()
    {
        if( isNokia() )
        {
            final Font font = Font.getFont(
                    Font.FACE_PROPORTIONAL,
                    Font.STYLE_PLAIN,
                    Font.SIZE_SMALL
            );
            final List list = new List( "", List.IMPLICIT );
View Full Code Here

        dirty = false;
    }

    private void paintList( final Graphics g )
    {
        final Font listFont = this.listFont;
        final Font helpFont = this.helpFont;

        if( dirty )
        {
            calcList();
        }
        final Vector items = this.items;

        int index = firstVisible;
        final int listBaseLine = listFont.getBaselinePosition();
        final int length = zones.length;
        for( int i = 0; i < length; i++ )
        {
            final MenuItem item = (MenuItem) items.elementAt( index );
            final int imageWidth = item.image != null ?
                                   item.image.getWidth() :
                                   0;
            final Rectangle zone = zones[i];
            if( index == selectedIndex )
            {
                g.setColor( selectedBackground );
                g.fillRoundRect(
                        1,
                        zone.getY(),
                        zone.getWidth(),
                        zone.getHeight(),
                        RADIUS,
                        RADIUS
                );
//                g.setColor( selectedBorder );
//                g.setStrokeStyle( Graphics.SOLID );
//                g.drawRoundRect(
//                        1,
//                        zone.getY(),
//                        zone.getWidth(),
//                        zone.getHeight(),
//                        RADIUS,
//                        RADIUS
//                );
                if( item.image != null )
                {
                    g.drawImage(
                            item.image,
                            3,
                            zone.getY(),
                            Graphics.LEFT | Graphics.TOP
                    );
                }
                final String[] help = Tools.splitInLines(
                        item.help,
                        helpFont,
                        helpFont,
                        zone.getWidth() - imageWidth - 1,
                        helpLines,
                        true
                );
                final int x = 4 + imageWidth;
                g.setFont( listFont );
                g.setColor( selectedColor );
                g.drawString(
                        item.label,
                        x,
                        zone.getY() + listBaseLine,
                        Graphics.LEFT | Graphics.BASELINE
                );
                if( help != null && help.length > 0 )
                {
                    g.setFont( helpFont );
                    final int helpBaseLine = helpFont.getBaselinePosition();
                    int y0 = zone.getY() + listFont.getHeight() + 1;
                    final int helpCount = help.length;
                    for( int j = 0; j < helpCount; j++ )
                    {
                        if( help[j] != null )
                        {
                            g.drawString(
                                help[j],
                                x,
                                y0 + helpBaseLine,
                                Graphics.LEFT | Graphics.BASELINE
                            );
                            y0 += helpFont.getHeight() + 1;
                        }
                    }
                }
            }
            else
View Full Code Here

    /** @noinspection FieldRepeatedlyAccessedInMethod,JavaDoc*/
    private synchronized void calcGrid()
    {
        final Vector items = this.items;
        final Font font = this.gridFont;

        final int itemCount = items.size();
        final int width = getWidth() - 2;
        final int height = getHeight() - font.getHeight() - helpFont.getHeight() - 4;
        final MenuItem item0 = ( (MenuItem) items.elementAt( 0 ) );
        final int iconWidth = item0.image.getWidth();
        final int itemWidth = iconWidth + 2;
        final int iconHeight = item0.image.getHeight();
        final int itemHeight = iconHeight + 2;

        final int maxCols = width / itemWidth;
        final int maxRows = height / itemHeight;

        if( itemCount < maxCols * maxRows )
        {
            cols = 1;
            rows = 1;
            int total = 0;
            while( total < itemCount )
            {
                if( cols < maxCols )
                {
                    cols++;
                }
                total = cols * rows;
                if( total < itemCount )
                {
                    if( rows < maxRows )
                    {
                        rows++;
                    }
                    total = cols * rows;
                }
            }
        }
        else
        {
            cols = maxCols;
            rows = maxRows;
        }
        final int hSpace = (width - (cols * itemWidth)) / (cols + 1);
        final int vSpace = (height - ( rows * itemHeight)) / ( rows + 1);
        int visibleCount = cols * rows;
        if( visibleCount > itemCount )
        {
            visibleCount = itemCount;
        }

        if( zones == null || zones.length != visibleCount )
        {
            zones = new Rectangle[ visibleCount ];
        }

        int y = 1;
        labelX = 1 + ( width / 2 );
        labelY = y + font.getBaselinePosition();
        y += font.getHeight() + vSpace;

        int count = 0;
        int index = firstVisible;
        for( int i = 0; i < rows && count < itemCount; i++ )
        {
View Full Code Here

TOP

Related Classes of javax.microedition.lcdui.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.