Ejemplo n.º 1
0
  /*
   * Draw statusbar with a stored graphic later, and add date and status icons
   * for gps, battery, net and cell status.
   */
  protected void paintStatusBar(Graphics g) {
    if (screenOrientation() == PORTRAIT) {
      int x = 0;
      int y = getHeight() - HEIGHT_STATUSBAR;
      int width = getWidth();
      int height = getHeight();
      g.setClip(x, y, width, height);

      g.setColor(COLOR_STATUSBAR_BG);
      g.fillRect(x, y, width, height);
      g.setColor(COLOR_OUTLINE);
      g.drawLine(0, y, width, y);
      g.drawLine(30, y, 30, height);
      g.drawLine(getWidth() - 30, y, width - 30, height);
      g.setColor(COLOR_TEXT);
      g.drawString("VIEW", 15, height, Graphics.HCENTER | Graphics.BOTTOM);
      g.drawString("MENU", width - 15, height, Graphics.HCENTER | Graphics.BOTTOM);
      g.drawString(
          DateUtils.getDateTimeStr(), width >> 1, height, Graphics.HCENTER | Graphics.BOTTOM);
    } else {
      // fixme: Put some effort here later.
      g.setColor(COLOR_TEXT);
      g.drawString("Landscape view not implemented", 0, 40, Graphics.TOP | Graphics.LEFT);
    }
  }
Ejemplo n.º 2
0
 public void drawDeath(Graphics g, int viewX, int viewY) {
   if (!isDeath) return;
   g.setColor(255, 0, 0);
   g.drawLine(
       getX() - viewX, getY() - viewY, getX() + getWidth() - viewX, getY() + getHeight() - viewY);
   g.drawLine(
       getX() - viewX, getY() + getHeight() - viewY, getX() + getWidth() - viewX, getY() - viewY);
 }
Ejemplo n.º 3
0
  /**
   * Draws a line with appropriate thickness. End of lines are horizontal.
   *
   * @param g Graphics context on which to draw.
   * @param xStart Starting x coordinate.
   * @param yStart Starting y coordinate.
   * @param xEnd End x coordinate.
   * @param yEnd End y coordinate.
   * @param maxX Maximum x coordinate.
   * @param maxY Maximum y coordinate.
   * @param thickness Thickness of the line. Should be greater than 1
   */
  public static void drawLine(
      Graphics g, int xStart, int yStart, int xEnd, int yEnd, int thickness) {

    if (thickness < 2) {
      return;
    }

    int x1, y1, x2, y2;

    // set x1 to lower, x2 to higher value
    if (xStart > xEnd) {
      x1 = xEnd;
      x2 = xStart;
    } else {
      x1 = xStart;
      x2 = xEnd;
    }

    // set y1 to lower, y2 to higher value
    if (yStart > yEnd) {
      y1 = yEnd;
      y2 = yStart;
    } else {
      y1 = yStart;
      y2 = yEnd;
    }

    if (drawAxisLine(g, x1, y1, x2, y2, thickness)) return;

    // sonst ist es ein bisschen komplizierter
    boolean notSteep = y2 - y1 < x2 - x1;
    if (notSteep) {
      y1 = xStart;
      y2 = xEnd;
      xStart = yStart;
      xEnd = yEnd;
    } else {
      y1 = yStart;
      y2 = yEnd;
    }
    int add;
    for (int i = 0; i < thickness; i++) {
      // update line position
      add = i % 2 == 0 ? -((i + 1) / 2) : (i + 1) / 2;
      x1 = xStart + add;
      x2 = xEnd + add;

      // System.out.println("g.drawLine(" + x1 + "," + y1 + "," + x2 + "," + y2 + ");");
      // draw single line
      if (notSteep) {
        g.drawLine(y1, x1, y2, x2);
      } else {
        g.drawLine(x1, y1, x2, y2);
      }
    }
  }
  protected void paint(Graphics g) {
    g.setColor(0xFAFAFA);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(0xDDDDDD);
    g.setStrokeStyle(Graphics.SOLID);
    g.drawLine(0, 0, getWidth(), 0);

    if (!pressedField) {
      g.setColor(0xE5E5E5);
    } else {
      pressedField = false;
      g.setColor(0xBCBCBC);
    }

    if (selected == Main.STATION_LIST_VIEW) {
      g.fillRect(0, 1, getWidth() / 2, getHeight() / 2);
    } else if (selected == Main.FAVORITE_LIST_VIEW) {
      g.fillRect(getWidth() / 2 + 1, 1, getWidth(), getHeight() / 2);
    } else if (selected == Main.MAP_SEARCH_VIEW) {
      g.fillRect(0, getHeight() / 2 + 1, getWidth() / 2, getHeight());
    } else if (selected == Main.GEOCODING_SEARCH_VIEW) {
      g.fillRect(getWidth() / 2 + 1, getHeight() / 2 + 1, getWidth(), getHeight());
    }

    g.setColor(0x000000);
    g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
    g.drawImage(imageStationListView, 60, 40, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.STATION_LIST_VIEW_TITLE, 60, 80, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageFavoriteListView, 180, 40, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.FAVORITE_LIST_VIEW_TITLE, 180, 80, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageMapSearchView, 60, 160, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.MAP_SEARCH_VIEW_TITLE, 60, 200, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageGeocodingSearchView, 180, 160, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.GEOCODING_SEARCH_VIEW_TITLE, 180, 200, Graphics.HCENTER | Graphics.TOP);
  }
Ejemplo n.º 5
0
  void displayCharacterMap(Graphics g) {
    if (currentChars != null) {
      g.setColor(0xffffff);
      g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
      g.setColor(0x000000);
      g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
      for (int i = 0; i < currentChars.length; i++) {
        char ch = currentChars[i];
        if (isUppercase) {
          ch = String.valueOf(currentChars[i]).toUpperCase().charAt(0);
        }

        // TODO: if i*12 > getWidth() ?

        g.drawChar(ch, i * 12, getHeight() - inputHeight, Graphics.LEFT | Graphics.TOP);
        if (currentChars[currentKeyStep] == currentChars[i]) {
          g.drawRect(
              i * 12 - 2,
              getHeight() - inputHeight - 2,
              inputFont.charWidth(ch) + 4,
              inputHeight + 4);
        }
      }
    }
  }
Ejemplo n.º 6
0
  protected final void draw(
      final Graphics pG, final int pOffsetX, final int pOffsetY, final boolean pRemovable) {
    // Upper triangle
    pG.fillTriangle(
        mCenterX + pOffsetX,
        mTopY + pOffsetY,
        mLeftX + pOffsetX,
        mUpperTriangleBottomY + pOffsetY,
        mRightX + pOffsetX,
        mUpperTriangleBottomY + pOffsetY);

    // Lower triangle
    pG.fillTriangle(
        mCenterX + pOffsetX,
        mBottomY - 1 + pOffsetY,
        mLeftX + pOffsetX,
        mLowerTriangleTopY + pOffsetY,
        mRightX + pOffsetX,
        mLowerTriangleTopY + pOffsetY);

    // Top left corner
    pG.setColor(pRemovable ? mColorDrawDarker : mColorDrawLighter);
    pG.drawLine(
        mCenterX + pOffsetX, mTopY + pOffsetY, mLeftX + pOffsetX, mUpperTriangleBottomY + pOffsetY);

    // Top right corner
    pG.drawLine(
        mCenterX + pOffsetX,
        mTopY + pOffsetY,
        mRightX + pOffsetX,
        mUpperTriangleBottomY + pOffsetY);

    // Bottom left corner
    pG.drawLine(
        mCenterX + pOffsetX,
        mBottomY - 1 + pOffsetY,
        mLeftX + pOffsetX,
        mLowerTriangleTopY + 1 + pOffsetY);

    // Bottom right corner
    pG.setColor(pRemovable ? mColorDrawLighter : mColorDrawDarker);
    pG.drawLine(
        mCenterX + pOffsetX,
        mBottomY - 1 + pOffsetY,
        mRightX + pOffsetX,
        mLowerTriangleTopY + 1 + pOffsetY);
  }
Ejemplo n.º 7
0
 /**
  * Draws the specified character.
  *
  * @param g the graphics context
  * @param c the character to be drawn
  * @param x the x coordinate of the anchor point
  * @param y the y coordinate of the anchor point
  * @return the x coordinate for the next character
  */
 public int drawChar(Graphics g, char c, int charColor, int x, int y) {
   setColor(charColor);
   int nextX = drawOneChar(g, c, x, y);
   if ((style & Font.STYLE_UNDERLINED) != 0) {
     int yU = y + this.baseline + 2;
     g.drawLine(x, yU, nextX - 1, yU);
   }
   return nextX;
 }
Ejemplo n.º 8
0
 void displayStatus(Graphics g) {
   if (statusString != null) {
     g.setColor(0xffffff);
     g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
     g.setColor(0x000000);
     g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
     g.drawString(statusString, 0, getHeight() - inputHeight - 2, Graphics.LEFT | Graphics.TOP);
   }
 }
Ejemplo n.º 9
0
 void displayCurrentCommand(Graphics g) {
   g.setColor(0xffffff);
   g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
   g.setColor(0x000000);
   g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
   g.drawString(
       "Ctrl" + " + " + currentCharCommand,
       0,
       getHeight() - inputHeight,
       Graphics.LEFT | Graphics.TOP);
 }
Ejemplo n.º 10
0
  // protected void paint(Graphics g, int w, int h) {
  protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
    final int c = y + contentHeight / 2;

    g.setColor(0x949494);
    g.setFont(this.font);

    if (displayString == null || displayString.length() == 0) {
      g.drawLine(leftBorder, c, rightBorder, c);
      return;
    }

    int totalStringWidth = this.font.stringWidth(displayString) + this.linePadding;
    if (this.isLayoutCenter) {
      totalStringWidth += this.linePadding;
    }

    int lineLen = rightBorder - leftBorder - totalStringWidth;
    if (this.isLayoutCenter) {
      lineLen /= 2;
    }

    if (this.isLayoutCenter || this.isLayoutRight) {
      g.drawLine(leftBorder, c, leftBorder + lineLen, c);
    } else {
      g.drawLine(leftBorder + totalStringWidth, c, leftBorder + totalStringWidth + lineLen, c);
    }

    g.setColor(this.fontColor);
    if (this.isLayoutCenter) {
      g.drawString(
          displayString, leftBorder + lineLen + this.linePadding, y, Graphics.LEFT | Graphics.TOP);
    } else if (this.isLayoutRight) {
      g.drawString(displayString, rightBorder, y, Graphics.RIGHT | Graphics.TOP);
    } else {
      g.drawString(displayString, leftBorder, y, Graphics.LEFT | Graphics.TOP);
    }
    if (this.isLayoutCenter) {
      g.setColor(0x949494);
      g.drawLine(leftBorder + lineLen + totalStringWidth, c, rightBorder, c);
    }
  }
Ejemplo n.º 11
0
 void displayCursor(Graphics g) {
   int x = getCursorX();
   int y = getCursorY();
   if (x >= 0 && x <= vectorLines.elementAt(y).toString().length()) {
     if (isSelected(x, y)) {
       g.setColor(0xffffff);
     } else {
       g.setColor(0x000000);
     }
     g.drawLine(caretLeft, (y) * inputHeight, caretLeft, (y + 1) * inputHeight);
   }
 }
Ejemplo n.º 12
0
 /**
  * Draws the specified characters.
  *
  * @param g the graphics context
  * @param data the array of characters to be drawn
  * @param offset the start offset in the data
  * @param length the number of characters to be drawn
  * @param x the x coordinate of the anchor point
  * @param y the y coordinate of the anchor point
  * @param anchors the anchor point for positioning the text
  * @return the x coordinate for the next character
  */
 public int drawChars(Graphics g, char[] data, int offset, int length, int x, int y, int anchors) {
   int xx = getX(charsWidth(data, offset, length), x, anchors);
   int yy = getY(y, anchors);
   setColor(g.getColor());
   for (int i = offset; i < offset + length; i++) {
     xx = drawOneChar(g, data[i], xx, yy);
   }
   if ((style & Font.STYLE_UNDERLINED) != 0) {
     int yU = y + this.baseline + 2;
     g.drawLine(x, yU, xx - 1, yU);
   }
   return xx;
 }
Ejemplo n.º 13
0
  void displayScrollBar(Graphics g) {
    int x = getCursorX();
    int y = getCursorY();
    g.setColor(0xffffff);
    g.fillRect(getWidth() - 5, 0, 5, getHeight());
    g.setColor(0x000000);
    g.drawLine(getWidth() - 5, 0, getWidth() - 5, getHeight());

    int hScrollMin = inputHeight;

    int yScroll = (((linesOnScreen - 1) * y) * inputHeight) / getLinesCount();

    g.fillRect(getWidth() - 5, yScroll, 5, hScrollMin);
  }
Ejemplo n.º 14
0
 /**
  * Draws the specified substring.
  *
  * @param g the graphics context
  * @param text the text to be drawn
  * @param offset the index of a first character
  * @param length the number of characters
  * @param x the x coordinate of the anchor point
  * @param y the y coordinate of the anchor point
  * @param anchors the anchor point for positioning the text
  * @return the x coordinate for the next string
  */
 public int drawSubstring(
     Graphics g, String text, int textColor, int offset, int length, int x, int y, int anchors) {
   int xx = getX(substringWidth(text, offset, length), x, anchors);
   int yy = getY(y, anchors);
   setColor(textColor);
   for (int i = offset; i < offset + length; i++) {
     xx = drawOneChar(g, text.charAt(i), xx, yy);
   }
   if ((style & Font.STYLE_UNDERLINED) != 0) {
     int yU = y + this.baseline + 2;
     g.drawLine(x, yU, xx - 1, yU);
   }
   return xx;
 }
Ejemplo n.º 15
0
  public void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();

    g.setColor(0xffffff);
    g.fillRect(0, 0, w, h);
    g.setColor(0x000000);

    for (int x = 0; x < w; x += 10) g.drawLine(0, w - x, x, 0);

    int z = 50;
    g.drawRect(z, z, 20, 20);
    z += 20;
    g.fillRoundRect(z, z, 20, 20, 5, 5);
    z += 20;
    g.drawArc(z, z, 20, 20, 0, 360);
  }
Ejemplo n.º 16
0
  protected void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();

    // Create a green background
    g.setColor(tableColor);
    g.fillRect(0, 0, width, height);

    // Ask each stack to paint itself.
    // PlayStack
    for (int i = 0; i < stacks.length; i++) {
      stacks[i].paint(g);
    }

    // Draw some fancies
    g.setColor(0x00FFFFFF);
    g.drawLine(width / 2, marginTop, width / 2, marginTop + cardHeight);

    // Draw the cursor over the currently-selected stack
    cursor.paint(g);

    // Update the timer strip.
    timerStrip.paint(g);
  }
Ejemplo n.º 17
0
  public static void drawLineWithBorder(
      Graphics g,
      int xStart,
      int yStart,
      int xEnd,
      int yEnd,
      int thickness,
      int innerColor,
      int outerColor) {

    if (thickness < 2) {
      return;
    }

    int x1, y1, x2, y2;
    int r = thickness / 2;
    g.setColor(innerColor);

    // set x1 to lower, x2 to higher value
    if (xStart > xEnd) {
      x1 = xEnd;
      x2 = xStart;
    } else {
      x1 = xStart;
      x2 = xEnd;
    }

    // set y1 to lower, y2 to higher value
    if (yStart > yEnd) {
      y1 = yEnd;
      y2 = yStart;
    } else {
      y1 = yStart;
      y2 = yEnd;
    }

    if (drawAxisLine(g, x1, y1, x2, y2, thickness)) {
      int pos;
      if (x1 == x2) {
        g.setColor(outerColor);
        pos = x1 + r;
        g.drawLine(pos, y1, pos, y2);
        pos = x1 - r;
        g.drawLine(pos, y1, pos, y2);
      } else if (y1 == y1) {
        g.setColor(outerColor);
        pos = y1 + r;
        g.drawLine(x1, pos, x2, pos);
        pos = y1 - r;
        g.drawLine(x1, pos, x2, pos);
      }
      return;
    }

    // sonst ist es ein bisschen komplizierter
    boolean notSteep = y2 - y1 < x2 - x1;
    if (notSteep) {
      y1 = xStart;
      y2 = xEnd;
      xStart = yStart;
      xEnd = yEnd;
    } else {
      y1 = yStart;
      y2 = yEnd;
    }
    int add;
    for (int i = 0; i < thickness - 2; i++) {
      // update line position
      add = i % 2 == 0 ? -((i + 1) / 2) : (i + 1) / 2;
      x1 = xStart + add;
      x2 = xEnd + add;

      // System.out.println("g.drawLine(" + x1 + "," + y1 + "," + x2 + "," + y2 + ");");
      // draw single line
      if (notSteep) {
        g.drawLine(y1, x1, y2, x2);
      } else {
        g.drawLine(x1, y1, x2, y2);
      }
    }
    g.setColor(outerColor);
    if (notSteep) {
      g.drawLine(y1, yStart + r, y2, yEnd + r);
      g.drawLine(y1, yStart - r, y2, yEnd - r);
    } else {
      g.drawLine(xStart + r, y1, xEnd + r, y2);
      g.drawLine(xStart - r, y1, xEnd - r, y2);
    }
  }
Ejemplo n.º 18
0
  protected void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();
    if (_phase == 0) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) g.drawLine(0, i % 150, 149, 149 - i % 150);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 1) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) g.drawLine(0, i % h, w - 1, h - 1 - i % h);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 2) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.fillRect(0, 0, 150, 150);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 3) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.fillRect(0, 0, w, h);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 4) {
      Image img = Image.createImage(150, 150);
      img.getGraphics().setColor(0x456789);
      img.getGraphics().setFont(Font.getDefaultFont());
      img.getGraphics().drawString("ahoj", 0, 0, Graphics.LEFT | Graphics.TOP);
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.drawImage(img, 0, 0, Graphics.LEFT | Graphics.TOP);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 5) {
      long t = System.currentTimeMillis();
      GeneralFont f = GeneralFont.SystemFontsBold[0];
      for (int i = 0; i < 1000; i++) f.drawString(g, "0123", 0, 0, Graphics.TOP | Graphics.LEFT);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 6) {
      long t = System.currentTimeMillis();
      GeneralFont f = GeneralFont.NumberFonts[0];
      for (int i = 0; i < 1000; i++) f.drawString(g, "0123", 0, 0, Graphics.TOP | Graphics.LEFT);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 7) {
      long t = System.currentTimeMillis();
      double a, b, c;
      for (int i = 0; i < 10000; i++) {
        a = Math.cos(Math.sin(Math.floor(1.1 + i)));
        b = Math.sqrt(a);
        c = (a * b + a * b + a * b) % (1 + b * b);
        _times[_phase] = (long) c;
      }
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 8) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) {
        //				Earth.atan2(i*0.001, (i+1)*0.001);
        Earth.gg2lat(Earth.lat2gg(50));
      }
      _times[_phase++] = System.currentTimeMillis() - t;
    }

    Font f = Font.getDefaultFont();
    int y = 0;
    g.setColor(0);
    g.fillRect(0, 0, w, h);
    g.setColor(0xffffff);
    g.setFont(f);
    for (int i = 0; i < _phase; i++) {
      g.drawString(_tests[i] + ": " + _times[i] + "ms", 0, y, Graphics.LEFT | Graphics.TOP);
      y += f.getHeight();
    }
    if (_phase < _tests.length) {
      g.drawString("<testing...>", 0, y, Graphics.LEFT | Graphics.TOP);
      new Thread() {
        public void run() {
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
          }
          repaint();
        }
      }.start();
    } else g.drawString("<done>", 0, y, Graphics.LEFT | Graphics.TOP);
  }
  public void drawItem(Graphics g, int offset, boolean selected, boolean drawsec) {
    // g.setColor(0);
    boolean ralign = false;
    boolean underline = false;

    // #if NICK_COLORS
    // # 	boolean nick=false;
    // #endif

    int w = offset;
    int dw;
    int imageYOfs = ((getVHeight() - imgHeight()) >> 1);
    // #if ALCATEL_FONT
    // #         int fontYOfs=(( getVHeight()-font.getHeight() )>>1) +1;
    // #else
    int fontYOfs = ((getVHeight() - font.getHeight()) >> 1);
    // #endif
    int imgWidth = imgWidth();

    g.setFont(font);
    for (int index = 0; index < elementCount; index++) {
      Object ob = elementData[index];
      if (ob != null) {

        if (ob instanceof String) {
          // string element
          String s = (String) ob;
          // #if NICK_COLORS
          // #                     if (nick) {
          // #                         int color=g.getColor();
          // #                         dw=0;
          // #                         int p1=0;
          // #                         while (p1<s.length()) {
          // #                             int p2=p1;
          // #                             char c1=s.charAt(p1);
          // #                             //processing the same cp
          // #                             while (p2<s.length()) {
          // #                                 char c2=s.charAt(p2);
          // #                                 if ( (c1&0xff00) != (c2 &0xff00) ) break;
          // #                                 p2++;
          // #                             }
          // #                             g.setColor( (c1>255) ? ColorScheme.strong(color) :
          // color);
          // #                             dw=font.substringWidth(s, p1, p2-p1);
          // #                             if (ralign) w-=dw;
          // #                             g.drawSubstring( s, p1, p2-p1,
          // #                                     w,fontYOfs,Graphics.LEFT|Graphics.TOP);
          // #                             if (!ralign) w+=dw;
          // #                             p1=p2;
          // #                         }
          // #
          // #                         g.setColor(color);
          // #                     } else {
          // #endif
          dw = font.stringWidth(s);
          if (ralign) w -= dw;
          g.drawString(s, w, fontYOfs, Graphics.LEFT | Graphics.TOP);
          if (underline) {
            int y = getVHeight() - 1;
            g.drawLine(w, y, w + dw, y);
            underline = false;
          }
          if (!ralign) w += dw;
          // #if NICK_COLORS
          // #                     }
          // #endif

        } else if ((ob instanceof Integer)) {
          // image element or color
          int i = ((Integer) ob).intValue();
          switch (i & 0xff000000) {
            case IMAGE:
              if (imageList == null) break;
              if (ralign) w -= imgWidth;
              imageList.drawImage(g, ((Integer) ob).intValue(), w, imageYOfs);
              if (!ralign) w += imgWidth;
              break;
            case COLOR:
              g.setColor(0xFFFFFF & i);
              break;
            case RALIGN:
              ralign = true;
              w = g.getClipWidth() - 1;
              break;
            case UNDERLINE:
              underline = true;
              break;
              // #if NICK_COLORS
              // #                         case NICK_ON:
              // #                             nick=true;
              // #                             break;
              // #                         case NICK_OFF:
              // #                             nick=false;
              // #                             break;
              // #endif
          }
        } /* Integer*/ else if (ob instanceof VirtualElement) {
          int clipw = g.getClipWidth();
          int cliph = g.getClipHeight();
          ((VirtualElement) ob).drawItem(g, 0, false, false);
          g.setClip(g.getTranslateX(), g.getTranslateY(), clipw, cliph);
          // TODO: рисование не с нулевой позиции и вычисление ширины
        }
      } // if ob!=null
    } // for
  }
Ejemplo n.º 20
0
  protected void paint(Graphics g) {
    int x = g.getClipX();
    int y = g.getClipY();
    int w = g.getClipWidth();
    int h = g.getClipHeight();

    // Draw the frame
    g.setColor(0xffffff);
    g.fillRect(x, y, w, h);

    // Draw each ball
    for (int i = 0; i < numBalls; i++) {
      if (balls[i].inside(x, y, x + w, y + h)) {
        balls[i].paint(g);
      }
    }

    g.setColor(0);
    g.drawRect(0, 0, width - 1, height - 1);

    long now = System.currentTimeMillis();
    String str = null;

    if (times_idx >= NUM_HISTORY) {
      long oldTime = times[times_idx % NUM_HISTORY];

      if (oldTime == now) {
        // in case of divide-by-zero
        oldTime = now - 1;
      }

      long fps = ((long) 1000 * (long) NUM_HISTORY) / (now - oldTime);

      if ((times_idx % 20) == 0) {
        str = numBalls + " Ball(s) " + fps + " fps";
      }
    } else {
      if ((times_idx % 20) == 0) {
        str = numBalls + " Ball(s)";
      }
    }

    if (msg != null) {
      g.setColor(0xffffff);
      g.setClip(0, height - STATUSBAR_HEIGHT, width, height);
      g.fillRect(0, height - STATUSBAR_HEIGHT, width, STATUSBAR_HEIGHT);

      g.setColor(0);
      g.drawString(msg, 5, height - STATUSBAR_HEIGHT - 2, 0);
      g.drawRect(0, 0, width - 1, height - 1);

      // draw a reflection line
      g.drawLine(0, height - STATUSBAR_HEIGHT, w, height - STATUSBAR_HEIGHT);

      msg = null;
    }

    if (str != null) {
      /*
       * Do a complete repaint, so that the message will
       * be shown even in double-buffer mode.
       */
      repaint();
      msg = str;
    }

    times[times_idx % NUM_HISTORY] = now;
    ++times_idx;
  }