コード例 #1
10
ファイル: Component.java プロジェクト: BlaZedaroof/MineBlock
  public void render() {
    Graphics g = screen.getGraphics();
    // Drawing Things!
    sky.render(g);
    level.render(
        g,
        (int) sX,
        (int) sY,
        (pixel.width / Tile.tileSize) + 2,
        (pixel.height / Tile.tileSize) + 2);
    character.render(g);
    inventory.render(g);
    health.render(g);

    for (int i = 0; i < mob.toArray().length; i++) {
      mob.get(i).render(g);
    }
    g = getGraphics();

    g.drawImage(screen, 0, 0, size.width, size.height, 0, 0, pixel.width, pixel.height, null);

    g.dispose();
  }
コード例 #2
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /** end displaying message and force a graph repaint */
  public void end() {

    super.stop();

    g2d.clearAll = true;
    g2d.paintAll = true;

    if (lg != null) lg.dispose();

    g2d.repaint();
  }
コード例 #3
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /**
   * This paints the entire plot. It calls the draw methods of all the attached axis and data sets.
   * The order of drawing is - Axis first, data legends next, data last.
   *
   * @params g Graphics state.
   */
  public void paint(Graphics g) {
    int i;
    Graphics lg = g.create();
    Rectangle r = bounds();

    /* The r.x and r.y returned from bounds is relative to the
     ** parents space so set them equal to zero.
     */
    r.x = 0;
    r.y = 0;

    if (DefaultBackground == null) DefaultBackground = this.getBackground();
    if (DataBackground == null) DataBackground = this.getBackground();

    //        System.out.println("Graph2D paint method called!");

    if (!paintAll) return;

    r.x += borderLeft;
    r.y += borderTop;
    r.width -= borderLeft + borderRight;
    r.height -= borderBottom + borderTop;

    paintFirst(lg, r);

    if (!axis.isEmpty()) r = drawAxis(lg, r);
    else {
      if (clearAll) {
        Color c = g.getColor();
        g.setColor(DataBackground);
        g.fillRect(r.x, r.y, r.width, r.height);
        g.setColor(c);
      }
      drawFrame(lg, r.x, r.y, r.width, r.height);
    }

    paintBeforeData(lg, r);

    if (!dataset.isEmpty()) {

      datarect.x = r.x;
      datarect.y = r.y;
      datarect.width = r.width;
      datarect.height = r.height;

      for (i = 0; i < dataset.size(); i++) {
        ((DataSet) dataset.elementAt(i)).draw_data(lg, r);
      }
    }

    paintLast(lg, r);

    lg.dispose();
  }
コード例 #4
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
 /**
  * Prepare a buffer for the image, return if the canvas is ready Only need to call this when the
  * size of the canvas is changed, Since we automatically detect the size change in paint() only
  * call this on start
  */
 public boolean newImgBuf() {
   Dimension sz = getSize();
   if (sz.width == 0 || sz.height == 0) return false;
   // quit if the current image already has the right size
   if (img != null && imgG != null && sz.equals(imgSize)) return true;
   img = createImage(sz.width, sz.height);
   if (imgG != null) imgG.dispose();
   imgG = img.getGraphics();
   imgSize = sz;
   return true;
 }
コード例 #5
0
 public void update(double slowdown, double arrival) {
   freeway.update(slowdown, arrival);
   if (buffer == null) {
     xsize = size().width;
     ysize = size().height;
     buffer = createImage(xsize, ysize);
   }
   Graphics bg = buffer.getGraphics();
   freeway.paint(bg, row, XDOTDIST, DOTSIZE);
   if (row < ysize - 2 * DOTSIZE + 1) row += DOTSIZE;
   else {
     bg.copyArea(0, DOTSIZE, xsize, ysize - DOTSIZE, 0, -DOTSIZE);
     bg.clearRect(0, ysize - DOTSIZE, xsize, DOTSIZE);
   }
   bg.dispose();
   repaint();
 }