Ejemplo n.º 1
0
  public static Image createThumbnail(Image image, int width, int height) {
    int sourceWidth = image.getWidth();
    int sourceHeight = image.getHeight();

    if ((width > sourceWidth) && (height > sourceHeight)) {
      return image;
    }
    int thumbWidth = width;
    int thumbHeight = thumbWidth * sourceHeight / sourceWidth;
    if (thumbHeight > height) {
      thumbHeight = height;
      thumbWidth = thumbHeight * sourceWidth / sourceHeight;
    }
    // #sijapp cond.if modules_ANDROID is "true"#
    Image scaled = image.scale(thumbWidth, thumbHeight);
    if (null != scaled) return scaled;
    // #sijapp cond.end#

    Image thumb = Image.createImage(thumbWidth, thumbHeight);
    Graphics g = thumb.getGraphics();

    for (int y = 0; y < thumbHeight; ++y) {
      for (int x = 0; x < thumbWidth; ++x) {
        g.setClip(x, y, 1, 1);
        int dx = x * sourceWidth / thumbWidth;
        int dy = y * sourceHeight / thumbHeight;
        g.drawImage(image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
      }
    }
    return thumb;
  }
Ejemplo n.º 2
0
  protected void doPaintAxis(final Graphics g) {
    if (scaleSizeInPixel == 0 || mapBackground != null) {
      return;
    }

    final Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
    g.setFont(font);
    g.setColor(0x00000000);

    final int textBottom = height - 4 - SCALE_HEIGTH;
    int left = 0;
    for (int i = 0; i < scaleConfiguration.labelLocation.length; i++) {
      final float location = scaleConfiguration.labelLocation[i];
      final float value = scaleConfiguration.labelValue[i];
      String label = Utils.floatToString(value, true);
      if (location == 0) {
        left = (font.stringWidth(label) / 2) + 2;
      } else if (location == 1) {
        label += " " + scaleConfiguration.unit;
      }
      g.drawString(
          label,
          left + (int) (scaleSizeInPixel * location),
          textBottom,
          Graphics.BOTTOM | Graphics.HCENTER);
    }
    g.drawRect(left, height - 2 - SCALE_HEIGTH, scaleSizeInPixel, SCALE_HEIGTH);
    g.fillRect(left, height - 2 - SCALE_HEIGTH, scaleSizeInPixel / 2, SCALE_HEIGTH);
  }
Ejemplo n.º 3
0
  private void paint_Confirm(Graphics g) {
    int h = 50;
    Painter.drawDialog(g, 0, gd.screenHeight - h, gd.screenWidth, h, Painter.DIALOG_DEEP);
    g.setColor(Color.black);
    if (gd.player.bag.get(
            gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
            gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
        != null) {
      if (gd.bag_tabIndex == 0) {
        g.drawString(
            "是否要使用物品\""
                + (gd.gameObjectManager.getItem(gd.player.bag.getList(Bag.ITEM)[gd.bag_curIndex])
                    .name)
                + "\"",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);

      } else {
        g.drawString(
            "是否要将装备\""
                + (gd.gameObjectManager.getEquip(gd.player.bag.getList(Bag.EQUIP)[gd.bag_curIndex])
                    .name)
                + "\"穿上",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);
      }
    }
  }
Ejemplo n.º 4
0
 public void systemShowInf(String infStr) {
   g.setColor(128, 255, 255);
   g.fillRect(disWidth + 50, disHeight + 166, 80, 15);
   g.setColor(0, 0, 0);
   g.drawString(infStr, disWidth + 55, disHeight + 166, 0);
   flushGraphics();
 }
Ejemplo n.º 5
0
 public void drawMenu() {
   try {
     if (page == 3) {
       setFont(16);
       g.drawString(nickname, disWidth + 80, disHeight + 15, 0);
     }
     // 判斷在遊戲說明時,防止文字超出螢幕,當超出螢幕時放到下一頁面
     if (page == 1) {
       setFont(0);
       g.setColor(255, 255, 255);
       for (int i = 0; gameUserInfCount < gameUserInf.length; gameUserInfCount++, i += 17) {
         if (gameUserInfCount % 5 != 4) // 遊戲說明
         g.drawString(gameUserInf[gameUserInfCount], disWidth + 10, disHeight + 70 + i, 0);
         else { // 顯示還有下一頁的文字
           g.drawString(gameUserInf[gameUserInfCount], disWidth + 135, disHeight + 70 + i, 0);
           gameUserInfCount++;
           break;
         }
       }
       flushGraphics();
     }
     changeMeun();
     flushGraphics();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 6
0
  private static final boolean Tiger_Paint_Small(Graphics g) {
    // #if !(TIGER=="TRUE")
    return true;
    // #else
    if (logo == null) {

      logo = new Image[PicIdx.length];
      for (int i = PicIdx.length - 1; i >= 0; i--) logo[i] = GetImage(PicIdx[i]);
      if (SoundOn != 0) Tiger_Sound_Play();
    }

    if (++runTime >= TIGER_DURING / FRAME_DT) {
      logo = null;
      FreeAllImage();
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.ClearBtns();
      // #endif
      Tiger_Finished = true;
      Tiger_Sound_Final();
      return true;
    } else {
      cCPdrawCleanScreen(g, 0x0); // 清屏
      if (runTime < (TIGER_DURING / 3) / FRAME_DT) {
        g.drawImage(logo[0], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 2 / 3) / FRAME_DT) {
        g.drawImage(logo[1], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < TIGER_DURING / FRAME_DT) {
        g.drawImage(logo[2], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      }
      return false;
    }
    // #endif
  }
Ejemplo n.º 7
0
  /**
   * Paint this window. This method should not generally be overridden by subclasses. This method
   * carefully stores the clip, translation, and color before calling into subclasses. The graphics
   * context should be translated such that it is in this window's coordinate space (0,0 is the top
   * left corner of this window).
   *
   * @param g The graphics object to use to paint this window.
   * @param refreshQ The custom queue which holds the set of refresh regions needing to be blitted
   *     to the screen
   */
  public void paint(Graphics g, CGraphicsQ refreshQ) {
    // We reset our dirty flag first. Any layers that become
    // dirty in the duration of this method will then cause it
    // to toggle back to true for the subsequent pass.
    // IMPL NOTE: when layers start to do complex animation, there will
    // likely need to be better atomic handling of the dirty state,
    // and layers becoming dirty and getting painted
    this.dirty = false;

    // Store the clip, translate, font, color
    cX = g.getClipX();
    cY = g.getClipY();
    cW = g.getClipWidth();
    cH = g.getClipHeight();

    tranX = g.getTranslateX();
    tranY = g.getTranslateY();

    font = g.getFont();
    color = g.getColor();

    // We set the basic clip to the size of this window
    g.setClip(bounds[X], bounds[Y], bounds[W], bounds[H]);

    synchronized (layers) {
      sweepAndMarkLayers();
      copyAndCleanDirtyLayers();
    }
    paintLayers(g, refreshQ);

    // We restore the original clip. The original font, color, etc.
    // have already been restored
    g.setClip(cX, cY, cW, cH);
  }
Ejemplo n.º 8
0
 protected void paint(Graphics g) {
   int w = getWidth(), h = getHeight();
   g.setClip(0, 0, w, h);
   g.setColor(bgColor);
   g.fillRect(0, 0, w, h);
   g.setColor(fgColor);
   String msg = null;
   switch (state) {
     case INITIALIZING:
       msg = "Initializing...";
       break;
     case FAILED:
       msg = "Failed";
       break;
     case PAUSED:
       msg = "Paused";
       break;
     case LOADING:
       msg = "Loading...";
       break;
   }
   if (msg != null) {
     g.drawString(msg, w >> 1, h >> 1, Graphics.HCENTER | Graphics.BASELINE);
   } else {
     int x = 0, col = 0, y = 0, row = 0, di = curLine;
     while (di < data.length) {
       char c = (char) data[di++];
       if (c == 0) {
         y += charHeight;
         row++;
         x = 0;
         col = 0;
         if (row == screenRows) return;
         continue;
       }
       if (col++ < curColumn) continue;
       boolean longline = false;
       if (col == curColumn + screenColumns) {
         while (di < data.length)
           if (data[di++] == 0) {
             di--;
             break;
           } else {
             longline = true;
           }
       }
       int cx = (c & 15) * charWidth;
       int cy = ((c >> 4) - 2) * charHeight;
       g.setClip(x, y, charWidth, charHeight);
       if (longline) {
         g.setColor(llColor);
         g.fillRect(x, y, charWidth, charHeight);
         g.setColor(fgColor);
       }
       g.drawImage(font, x - cx, y - cy, Graphics.TOP | Graphics.LEFT);
       x += charWidth;
     }
   }
 }
Ejemplo n.º 9
0
 public Image colImage(int color) {
   Image img =
       Image.createImage(Font.getDefaultFont().getHeight(), Font.getDefaultFont().getHeight());
   Graphics g = img.getGraphics();
   g.setColor(color);
   g.fillRect(0, 0, img.getWidth(), img.getHeight());
   return img;
 }
Ejemplo n.º 10
0
 // 删除行,只是简单的把该行置黑
 protected void deleteRow(Graphics g, int y) {
   g.setColor(KetrisCanvas.BACKGROUD);
   g.fillRect(
       KetrisCanvas.GAMEAREA_X + KetrisCanvas.BRICK_WIDTH,
       KetrisCanvas.GAMEAREA_Y + y * KetrisCanvas.BRICK_WIDTH,
       10 * KetrisCanvas.BRICK_WIDTH,
       KetrisCanvas.BRICK_WIDTH);
 }
Ejemplo n.º 11
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.º 12
0
 /*
  * 图片上添加字符
  */
 public static Image effect_image_add_str(Image src, String str, int x_pos, int y_pos) {
   Image temp = Image.createImage(src.getWidth(), src.getHeight());
   Graphics g = temp.getGraphics();
   g.drawImage(src, 0, 0, Graphics.LEFT | Graphics.TOP);
   g.setColor(0x000000);
   g.drawString(str, x_pos, y_pos, Graphics.LEFT | Graphics.TOP);
   return temp;
 }
Ejemplo n.º 13
0
 // }
 public void drawCursor(Graphics g, int width, int height) {
   int x = xCursor * imgWidth;
   g.setColor(ColorScheme.LIST_BGND);
   g.fillRect(0, 0, width, height);
   g.translate(x, 0);
   super.drawCursor(g, imgWidth, lineHeight);
   g.translate(-x, 0);
 }
Ejemplo n.º 14
0
 // 顯示畫面
 public void drawDisplay() {
   g = getGraphics();
   g.setColor(0, 0, 0);
   g.drawRect(disWidth - 1, disHeight - 1, 176 + 1, 208 + 1);
   layMa.paint(g, disWidth, disHeight);
   g.drawString(getWidth() + "|" + getHeight(), 0, 0, 0);
   flushGraphics();
 }
Ejemplo n.º 15
0
 //	畫出所輸入的字
 public void showBufferString() {
   if (page == 0) {
     drawUser_pass();
   } else if (page == 2) {
     g.setColor(255, 255, 255);
     g.drawString(nickname, disWidth + 60, disHeight + 115, 0);
   }
 }
Ejemplo n.º 16
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 x, int y) {
   setColor(g.getColor());
   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.º 17
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.º 18
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);
      }
    }
  }
Ejemplo n.º 19
0
  public void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();

    try {
      g.drawImage(img, w / 2, h / 2, Graphics.VCENTER | Graphics.HCENTER);
    } catch (Exception e) {
      g.drawString(e.getMessage(), w / 2, h / 2, Graphics.BASELINE | Graphics.HCENTER);
    }
  }
Ejemplo n.º 20
0
 public void drawFightCheck(Graphics g, int viewX, int viewY) {
   g.setColor(255, 255, 255);
   int x, y;
   for (int i = 0; i < fightRange.length; i++) {
     if (!canMoveFight(i)) continue;
     x = fightRange[i][1] * MyGameCanvas.CHECKWIDTH;
     y = fightRange[i][0] * MyGameCanvas.CHECKHEIGHT;
     g.drawRect(x - viewX, y - viewY, MyGameCanvas.CHECKWIDTH, MyGameCanvas.CHECKHEIGHT);
   }
 }
Ejemplo n.º 21
0
 public void paint(Graphics g) {
   g.setColor(color);
   String scoreStr = label + score;
   int offset = (g.getFont().stringWidth(scoreStr)) / 2;
   g.drawString(
       scoreStr,
       r.getLocation().getRealX() - offset,
       r.getLocation().getRealY(),
       Graphics.TOP | Graphics.LEFT);
 }
Ejemplo n.º 22
0
  /** paint */
  public void paint(Graphics g) {
    g.setFont(MainCanvas.nameFont);

    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    UIPainter.paintBackground(g);

    int i;
    for (i = 0; i < myTools.size(); i++) {
      if (se == i) {
        g.setColor(0, 0, 0);
        g.fillRect(
            0, i * MainCanvas.nameFont.getHeight(), getWidth(), MainCanvas.nameFont.getHeight());
        g.setColor(255, 255, 255);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      } else {
        g.setColor(0, 0, 0);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      }
    }

    UIPainter.paintLeftSoft(g, "Добавить");
    UIPainter.paintRightSoft(g, "Отмена");
  }
Ejemplo n.º 23
0
 public void paint(Graphics g) {
   if (startFlag == 0) {
     g.setColor(0, 0, 0);
     g.fillRect(0, 0, getWidth(), getHeight());
     g.setColor(255, 255, 255);
     g.drawString("Loading Terrain....0%", getWidth() / 2, 0, Graphics.TOP | Graphics.HCENTER);
     startFlag = 1;
   } else {
     drawGround(g);
   }
 }
Ejemplo n.º 24
0
  /* (non-Javadoc)
   * @see de.enough.polish.ui.Item#paintContent(int, int, int, int, javax.microedition.lcdui.Graphics)
   */
  protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
    // set the color according to the style
    if (this.style != null) {
      g.setColor(this.style.getFontColor());
    } else {
      g.setColor(0x000000);
    }

    // draw the keys
    g.drawString(getKeys(this.keyboard.isShift()), x, y, Graphics.LEFT | Graphics.TOP);
  }
Ejemplo n.º 25
0
  /*--------------------------------------------------
   * Paint the text representing the key code
   *-------------------------------------------------*/
  protected void paint(Graphics g) {
    // Clear the background (to white)
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());

    // Set color and draw text
    // Draw with black pen
    g.setColor(0, 0, 0);
    // Close to the center
    g.drawImage(image, mX, mY, Graphics.HCENTER | Graphics.VCENTER);
  }
Ejemplo n.º 26
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.º 27
0
 /** 区别黑字白字 用法:H>>6黑字 H原值白字 */
 public static final void String_Splash_Paint(Graphics g, String str, int W, int H) {
   if (Paint_Index++ % 10 < 5) {
     if (H > 1000) { // 区别黑字白字
       g.setColor(0x000000);
       g.drawString(str, W >> 1, H >> 7, Graphics.TOP | Graphics.HCENTER);
     } else {
       g.setColor(0xFFFFFF);
       g.drawString(str, W >> 1, H >> 1, Graphics.TOP | Graphics.HCENTER);
     }
   }
 }
Ejemplo n.º 28
0
  /**
   * Metoda wyswietlajaca okreg obrazujacy postep wykrywania urzadzen
   *
   * @param g Referencja do obiektu klasy Graphics, ktory pozwala na narysowanie pasku postepu
   * @param progress Liczba z zakresu 0 - 359: zakres luku
   */
  public void showInquiryProgress(Graphics g, int progress) {
    int c = g.getColor();

    g.setColor(255, 255, 255);

    g.drawArc(screenWidth - 25, screenHeight - 57, 10, 16, 0, progress);

    g.setColor(c);

    bluetoothLogoSmallSprite.setPosition(screenWidth - 24, screenHeight - 56);
    bluetoothLogoSmallSprite.paint(g);
  }
Ejemplo n.º 29
0
  protected void paint(Graphics g) {
    int width = this.getWidth();

    // Fill in the background White
    g.setColor(0xFFFFFF); // White
    g.fillRect(0, 0, width, this.getHeight());

    int y = yPos;
    y += MARGIN;

    if (this.logo != null) {
      g.drawImage(this.logo, width / 2, y, Graphics.TOP | Graphics.HCENTER);
      y += logo.getHeight() + MARGIN;
    }

    g.setColor(0x0); // Black

    // Write the title "About"
    final Font titleFont =
        Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD | Font.STYLE_UNDERLINED, Font.SIZE_LARGE);

    /*
     * TODO: currently paints ALL the text, even if there is (a lot) more
     * than can fit on the screen. (must do this first time to assess
     * 'height', but shouldn't need to do it for any other repaint
     */
    for (int i = 0; i < TITLES.length; i++) {
      final int basicFontHeight = DEFAULT_SIMPLE_FONT.getHeight();
      final int titleFontHeight = titleFont.getHeight();
      // Write out the 'message' heading
      g.setFont(titleFont);
      final String title = TITLES[i];
      int stringWidth = g.getFont().stringWidth(title);
      g.drawString(title, (width - stringWidth) / 2, y, 0);
      y += titleFontHeight;

      // Write out the 'message' text.
      g.setFont(DEFAULT_SIMPLE_FONT);
      for (int j = 0; j < this.formattedMessages[i].length; j++) {
        final String message = this.formattedMessages[i][j];
        stringWidth = g.getFont().stringWidth(message);
        g.drawString(message, (width - stringWidth) / 2, y, 0);
        y += basicFontHeight;
      }
      y += basicFontHeight;
    }

    // Set the total-Height the first time
    if (firstTime) {
      totalHeight = y + MARGIN;
      firstTime = false;
    }
  }
Ejemplo n.º 30
0
  /*
   *  (non-Javadoc)
   * @see javax.microedition.lcdui.Canvas#paint(javax.microedition.lcdui.Graphics)
   */
  protected void paint(Graphics g) {

    g.setGrayScale(255);

    // Draw the image - for now start drawing in top left corner of screen
    g.fillRect(0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT);
    System.out.println("Screen size:" + Constants.SCREEN_WIDTH + ":" + Constants.SCREEN_HEIGHT);

    if (image == null) System.out.println("PhotoViewScreen::paint(): Image object was null.");

    g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
  }