Package javax.microedition.lcdui

Examples of javax.microedition.lcdui.Graphics


  public void draw(Graphics aGraphic, int aX, int aY, boolean aBody,
      boolean aScrollBar) {
    //#ifdef DLOGGING
//@    if (finestLoggable) {logger.finest("draw aX,aY,width,height,aBody,aScrollBar=" + aX + "," + aY + "," + width + "," + height + "," + aBody + "," + aScrollBar);}
    //#endif
    Graphics g = offscreen.getGraphics();
    // Draw background
    g.setColor(background);
    if (aBody) {
      g.fillRect(0, 0, width, height);
    }
    // Draw text
    g.setColor(foreground);
    drawText(g);
    if (aBody) {
      // Draw border
      g.setColor(foreground);
      g.drawRect(0, 0, width - 1, height - 1);
      if (aScrollBar) {
        // Draw scroll
        g.setColor(background);
        g.fillRect(width - scrollWidth, 0, scrollWidth - 1, height - 1);
        g.setColor(foreground);
        g.drawRect(width - scrollWidth, 0, scrollWidth - 1, height - 1);
        int scroll = getScrollPosition(height, scrollHeight);
        g.fillRect(width - scrollWidth, scroll,
            scrollWidth - 1, scrollHeight - 1);
      }
    }
    // Draw offscreen
    aGraphic.drawImage(offscreen, aX, aY, Graphics.LEFT | Graphics.TOP);
View Full Code Here


            {
                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
                );
View Full Code Here

        Image tile = Image.createImage(this.getClass().getResourceAsStream("/front.jpg"));
        int tw = tile.getWidth();
        int th = tile.getHeight();
        int xmax = getWidth() / tw;
        int ymax = getHeight() / th;
        Graphics g = frontLayer.getGraphics();
        for (int i = 0; i <= xmax; ++i)
        {
          for (int j = 0; j <= ymax; ++j)
          {
            g.drawImage(tile, i * tw, j * th, Graphics.TOP | Graphics.LEFT);
          }
        }
      } catch (IOException e)
      {
        e.printStackTrace();
        // no tile available, draw default color (black)
        Graphics g = frontLayer.getGraphics();
        g.setColor(0x00000000);
        g.fillRect(0, 0, getWidth(), getHeight());
      }
    }
   
    // prepare the tiled back  layer.
    if (backLayer == null)
    {
      backLayer = Image.createImage(getWidth(), getHeight());
      try
      {
        Image tile = Image.createImage(this.getClass().getResourceAsStream("/back.jpg"));
        int tw = tile.getWidth();
        int th = tile.getHeight();
        int xmax = getWidth() / tw;
        int ymax = getHeight() / th;
        Graphics g = backLayer.getGraphics();
        for (int i = 0; i <= xmax; ++i)
        {
          for (int j = 0; j <= ymax; ++j)
          {
            g.drawImage(tile, i * tw, j * th, Graphics.TOP | Graphics.LEFT);
          }
        }
      } catch (IOException e)
      {
        e.printStackTrace();
        // no tile available, draw default color (black)
        Graphics g = backLayer.getGraphics();
        g.setColor(0x00000000);
        g.fillRect(0, 0, getWidth(), getHeight());
      }
    }

    if (worldLayer == null)
    { // initialize world
View Full Code Here

    // sent event to hero.
    hero.clock();

    // scroll the worldPanel to the left
    Graphics g = gameLayer.getGraphics();

    g.copyArea(clockStep, 0, gameLayer.getWidth() - clockStep, gameLayer.getHeight(), 0, 0, Graphics.TOP | Graphics.LEFT);
 
    Graphics wg = worldLayer.getGraphics();
    wg.copyArea(clockStep, 0, gameLayer.getWidth() - clockStep, gameLayer.getHeight(), 0, 0, Graphics.TOP | Graphics.LEFT);

   
    score++;
    caveGeneratorCounter++;

    updateDifficulty();

    // generate new terain to the empty part on the right

    int h = getHeight();
    int w = getWidth();

    if (rnd.nextLong() % (100) < caveGeneratorRandomSpeedReverse)
      caveGeneratorSpeed = -caveGeneratorSpeed;
    if (rnd.nextLong() % (100) < caveGeneratorRandomSpeedChange)
    {
      caveGeneratorSpeed += (rnd.nextLong() % (2) == 0 ? -1 : 1);
      if (caveGeneratorSpeed >= 3 || caveGeneratorSpeed <= -3)
        caveGeneratorSpeed = 0;
    }
   


    for (int i = clockStep; i > 0; --i)
    {
      frameCounter++;
      if (caveGeneratorPos >= h || caveGeneratorPos < 0)
        caveGeneratorSpeed = -caveGeneratorSpeed;
      caveGeneratorPos += caveGeneratorSpeed;
      g.setColor(0x00000000);
      g.drawLine(w-i,0,w-i,h);
      g.setColor(0xFFFFFFFF);
      g.drawLine(w - i, (caveGeneratorPos - (caveSize / 2)), w - i, (caveGeneratorPos + (caveSize / 2)));
     
      wg.drawRegion(frontLayer, frameCounter % w, 0, 1, h, Sprite.TRANS_NONE, w - i, 0, Graphics.TOP | Graphics.LEFT);
      wg.drawRegion(backLayer, frameCounter % w, (caveGeneratorPos - (caveSize / 2)), 1, caveSize, Sprite.TRANS_NONE, w - i, (caveGeneratorPos - (caveSize / 2)), Graphics.TOP | Graphics.LEFT);
    }
   
   
   
    return true;
View Full Code Here

        {
            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
            );
View Full Code Here

    }

    public void paint( Graphics graphics, final int x0, final int y0, int w, int h )
    {
        final Image buffer = Image.createImage( w, h );
        final Graphics g = buffer.getGraphics();
        g.setColor( 0xFFFFFF );
        g.fillRect( 0, 0, w, h );

        if( showLabel )
        {
            if( labelAbove )
            {
View Full Code Here

    {
        AbstractView.touchLastAccess();
        if( items.size() > 0 )
        {
            Image buffer = null;
            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(), getHeight() );
            if( mode == GRID )
            {
                paintGrid( g );
            }
            else
View Full Code Here

    }

    public void repaint() {
        //Create base image for table
        iTable = Image.createImage(WIDTH, HEIGHT);
        Graphics gTable = iTable.getGraphics();
        //Fill background with black
        gTable.fillRect(0, 0, WIDTH, HEIGHT);

        if ((screenWidth >= 220) && (screenHeight >= 300)) {

            //Draw deck
            gTable.drawRegion(BACK_CARD, 0, 0, BACK_CARD.getWidth(),
                                BACK_CARD.getHeight(), Sprite.TRANS_ROT270, 0, 0,
                                Graphics.TOP|Graphics.LEFT);
        }
        //Draw discarded
        Vector discarded = table.getDiscarded();
        if(discarded.size() > 1) {

            int len = discarded.size();
            if(len % 2 == 0) {

                Image toDraw = ((Card) discarded.elementAt(len-2)).getGraphic().getRender();
                gTable.drawRegion(toDraw, 0, 0, toDraw.getWidth(), toDraw.getHeight(),
                                  Sprite.TRANS_ROT270, HX, HY, Graphics.TOP|Graphics.LEFT);
                gTable.drawImage(((Card) discarded.elementAt(len-1))
                                .getGraphic().getRender(), VX, VY,
                                Graphics.TOP|Graphics.LEFT);
            } else {

                gTable.drawImage(
                                ((Card) discarded.elementAt(len-2))
                                .getGraphic().getRender(), VX, VY,
                                Graphics.TOP|Graphics.LEFT);
                Image toDraw = ((Card)discarded.elementAt(len-1)).getGraphic().getRender();
                gTable.drawRegion(toDraw, 0, 0, toDraw.getWidth(), toDraw.getHeight(),
                                   Sprite.TRANS_ROT270, HX, HY, Graphics.TOP|Graphics.LEFT);
            }
        } else {

            gTable.drawImage(
                            ((Card)discarded.elementAt(0))
                            .getGraphic().getRender(), VX, VY,
                            Graphics.TOP|Graphics.LEFT);
        }
    }
View Full Code Here

        return iTable;
    }

    public void drawAtualColor(int rgb) {

        Graphics g = iTable.getGraphics();
        g.setColor(rgb);
        g.fillRoundRect(CX, CY, 20, 20, 5, 5);
        g.setColor(0);
    }
View Full Code Here

            //#endif
        }

        GraphicCard newCard = new GraphicCard();
        newCard.render = Image.createImage(srcImage.getWidth(), srcImage.getHeight());
        Graphics gCard = newCard.render.getGraphics();

        //Draw base image
        gCard.drawImage(srcImage, 0, 0, Graphics.TOP|Graphics.LEFT);


        //Draw the number
        if(card.getNumber() != Card.NO_NUMBER) {
           gCard.setColor(255, 255, 255);
           String numbers = Integer.toString(card.getNumber());
           //Draw top number
           gCard.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
           gCard.drawString(numbers, 2, 2, Graphics.TOP|Graphics.LEFT);
           gCard.setColor(colors[card.getColor()]);
           //Draw center number
           gCard.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_MEDIUM));
           gCard.drawString(numbers, 11, 11, Graphics.TOP|Graphics.LEFT);
        }

        return newCard;
    }
View Full Code Here

TOP

Related Classes of javax.microedition.lcdui.Graphics

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.