public void paint(Graphics g) {
   if (gevonden == true) {
     g.drawString("De waarde is gevonden.", 20, 50);
   } else {
     g.drawString("De waarde is niet gevonden.", 20, 50);
   }
 }
  public void draw(Graphics g) {
    animate();

    g.setColor(Color.black);
    g.fillRect(0, 0, dim.width, dim.height);
    g.setColor(Color.white);

    numpaint++;
    DebugPrinter dbg = new DebugPrinter(g, 50, 60);
    dbg.print(
        "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box");
    dbg.print("frame", numpaint);
    dbg.print("fps", 1 / timer.time_diff);

    Point top_left = point_by_vec(new Vec(-1, 1));
    g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true);
    for (int i = 0; i < springs.size(); i++) {
      Spring spring = springs.get2(i);
      Point p1 = point_by_vec(balls.get2(spring.start).pos);
      Point p2 = point_by_vec(balls.get2(spring.end).pos);
      g.drawLine(p1.x, p1.y, p2.x, p2.y);
    }
    for (int i = 0; i < balls.size(); i++) {
      Ball ball = balls.get2(i);
      Point p = point_by_vec(ball.pos);
      int screen_radius = screen_dist(RADIUS);
      g.setColor(Color.blue);
      g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.setColor(Color.white);
      g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.drawString("" + i, p.x, p.y);
    }
  }
Exemple #3
0
  public void mouseWheelMoved(MouseWheelEvent event) {

    int zoom = event.getWheelRotation();

    mx = event.getX();
    my = event.getY();

    showStatus("Mouse rotated (" + zoom + ")");

    // zoom out
    if (zoom >= 0) {
      dbg.setColor(Color.black);
      //			dbg.drawImage (background, SIZE/2-current_size/2,
      //			        SIZE/2-current_size/2, current_size, current_size, this);
    }
    // zoom in
    else if (zoom < 0) {
      int width = building.getWidth(this);
      int height = building.getHeight(this);
      dbg.drawImage(
          building, width, height, width / 2, height / 2, width, height, width, height, this);
    }

    repaint();
    event.consume();
  }
Exemple #4
0
  public void drawBoardTrim(Graphics board, int row, int column, int sizeOfSquare) {
    // Set the color to "goldish"
    board.setColor(Color.orange);

    // Apply solid color beneath the board to add thickness to trim
    board.fillRect(0, 0, (row * sizeOfSquare) + 5, (column * sizeOfSquare) + 5);
  }
 public void paint(Graphics g) {
   msg = this.getParameter("p1");
   System.out.println("paint...");
   g.setColor(Color.red);
   g.drawLine(10, 20, 50, 50);
   g.drawString(msg, 100, 200);
 }
Exemple #6
0
  /** Paint it. */
  public void paint(Graphics g) {
    Dimension d = getSize();
    if (!inited || buff == null || d.width != buffSize.width || d.height != buffSize.height) {
      buffSize.width = d.width;
      buffSize.height = d.height;
      buff = createImage(d.width + 4, d.height + 4);
      if (buff == null) return;
      buffG = buff.getGraphics();
      inited = true;
    }

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width, prefSize.height);
    PressedRect(buffG, 0, 0, prefSize.width - 2, prefSize.height - 2);

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width + 2, prefSize.height + 2);
    if (!gameover) if ((gameover = is_game_over())) end_game();
    for (int i = 0; i < rows; i++) {
      for (int j = 0; j < cols; j++) {
        drawBlock(buffG, i, j, status(i, j));
      }
    }
    // PressedRect(buffG,0,0,prefSize.width + 2,prefSize.height + 2);
    if (buff != null) g.drawImage(buff, 0, 0, null);
  }
 public void moveLayerThree(Graphics g) {
   backy += (int) (player1.getVelocity() * 0.1);
   midy += (int) (player1.getVelocity() * 0.5);
   drawEnemy(g);
   drawCoin(g);
   drawBox(g);
   drawPoof(g);
   drawStar(g);
   drawJumper(g);
   drawSpike(g);
   drawPup(g);
   if (backy <= dieHeight) {
     // System.out.println(die);
     g.drawImage(player1.move(2), player1.getX(), player1.getY(), this);
     if (player1.animationComplete()) {
       die = true;
     }
   } else {
     if (backy <= dieHeight) {
       player1.resetCounter();
     }
     if (keys[KeyEvent.VK_RIGHT]) {
       g.drawImage(player1.move(1), player1.getX(), player1.getY(), this);
     } else if (keys[KeyEvent.VK_LEFT]) {
       g.drawImage(player1.move(-1), player1.getX(), player1.getY(), this);
     } else {
       g.drawImage(player1.move(0), player1.getX(), player1.getY(), this);
     }
   }
 }
Exemple #8
0
  /**
   * Draw the vectors at the data points. If this data has been attached to an Axis then scale the
   * data based on the axis maximum/minimum otherwise scale using the data's maximum/minimum
   *
   * @param g Graphics state
   * @param bounds The data window to draw into
   */
  public void draw_data(Graphics g, Rectangle bounds) {
    Color c;

    if (xaxis != null) {
      xmax = xaxis.maximum;
      xmin = xaxis.minimum;
    }

    if (yaxis != null) {
      ymax = yaxis.maximum;
      ymin = yaxis.minimum;
    }

    xrange = xmax - xmin;
    yrange = ymax - ymin;

    /*
     ** draw the legend before we clip the data window
     */
    draw_legend(g, bounds);
    /*
     ** Clip the data window
     */
    if (clipping) g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height);

    c = g.getColor();

    if (linecolor != null) g.setColor(linecolor);
    else g.setColor(c);

    drawVectors(g, bounds);

    g.setColor(c);
  }
Exemple #9
0
  public void paint(Graphics g) {
    g.setColor(Color.pink);

    g.drawRect(40, 40, 80, 80);
    g.drawLine(80, 10, 40, 40);
    g.drawLine(80, 10, 120, 40);
    g.drawRect(70, 80, 20, 40);
  }
Exemple #10
0
 public void paint(Graphics g) {
   if (first_paint == 1) {
     g.setColor(new Color(0x0));
     g.fillRect(0, 0, SIZE_X, SIZE_Y);
     g.setColor(new Color(0xffffff));
     g.drawRect(0, 0, SIZE_X - 1, SIZE_Y - 1);
     first_paint = 0;
   }
 }
Exemple #11
0
  // Countdown Paint Handler
  public void paint(Graphics g) {
    FontMetrics fm = g.getFontMetrics();

    int strWidth = fm.stringWidth(countString);

    int appletWidth = size().width;

    g.drawString(countString, (appletWidth - strWidth) / 2, 20);
  }
Exemple #12
0
  /*
   *  Draws a frame around the data area.
   */
  protected void drawFrame(Graphics g, int x, int y, int width, int height) {
    Color c = g.getColor();

    if (framecolor != null) g.setColor(framecolor);

    g.drawRect(x, y, width, height);

    g.setColor(c);
  }
Exemple #13
0
 public void tekenBoom(Graphics g, int x, int y, int breedte, int hoogte) {
   int diameterB = breedte * 3;
   int diameterH = hoogte * 4 / 5;
   g.setColor(new Color(160, 82, 45));
   g.fillRect(x, y - hoogte, breedte, hoogte);
   g.setColor(Color.GREEN);
   g.fillOval(
       x + (breedte / 2) - (diameterB / 2), y - (hoogte + (diameterH / 2)), diameterB, diameterH);
 }
  public void paint(Graphics g) {

    msg = "Vertical: " + vertSB.getValue();
    msg += ", Horizontal: " + horzSB.getValue();
    g.drawString(msg, 6, 160);

    // show current mouse drag position

    g.drawString("*", horzSB.getValue(), vertSB.getValue());
  }
 public void displayScore(
     Graphics g, int cx, int cy, int sx1, int sy1, int sx2, int sy2, int sx3, int sy3) {
   // displayes the score and stuff
   g.setFont(scoreFont);
   g.setColor(Color.WHITE);
   g.drawImage(new ImageIcon("InGameMenu/coin.png").getImage(), cx, cy, this);
   g.drawString("" + coins, sx1, sy1);
   g.drawString("" + score, sx2, sy2);
   g.drawString("" + height + " m", sx3, sy3);
 }
  public void paint(Graphics g) {

    int x = 10;
    int y = 60;
    g.drawString("Tafel van " + inputgetal, x, y);
    for (int i = 1; i < 11; i++) {
      y += 15;
      g.drawString(i + " x " + inputgetal + " = " + (inputgetal * i), x, y);
    }
  }
  /**
   * Called to draw the panel.
   *
   * @param g Graphics device to draw the panel to.
   */
  public void paintComponent(Graphics g) {
    final Point scrollPosition = getScrollPosition();
    g.translate(-scrollPosition.x, -scrollPosition.y);

    try {
      super.paintComponent(g);
    } finally {
      g.translate(scrollPosition.x, scrollPosition.y);
    }
  }
Exemple #18
0
  protected void drawVectors(Graphics g, Rectangle w) {

    int ix0, iy0;
    int ix1, iy1;

    double x0, y0, x1, y1, dx, dy;

    //      Is there any data to draw? Sometimes the draw command will
    //      will be called before any data has been placed in the class.

    if (data == null || data.length < stride) return;

    //      Lets draw the vectors

    for (int i = 0; i < length; i += stride) {

      x0 = data[i];
      y0 = data[i + 1];
      dx = data[i + 2] * getScaleFactor();
      dy = data[i + 3] * getScaleFactor();

      x1 = x0 + dx;
      y1 = y0 + dy;

      if (inside(x0, y0) || inside(x1, y1)) {

        ix0 = (int) (w.x + ((x0 - xmin) / xrange) * w.width);
        iy0 = (int) (w.y + (1.0 - (y0 - ymin) / yrange) * w.height);

        ix1 = (int) (w.x + ((x1 - xmin) / xrange) * w.width);
        iy1 = (int) (w.y + (1.0 - (y1 - ymin) / yrange) * w.height);

        g.drawLine(ix0, iy0, ix1, iy1);

        /*
         ** Now draw the head of the vector. To avoid scaling problems
         ** the head is drawn using pixel units. This would not work
         ** if we had multiple output devices.
         */

        dx = (double) (ix1 - ix0);
        dy = (double) (iy1 - iy0);

        ix0 = ix1 - (int) (0.25 * (dx - dy) + 0.5);
        iy0 = iy1 - (int) (0.25 * (dx + dy) + 0.5);

        g.drawLine(ix0, iy0, ix1, iy1);

        ix0 = ix1 - (int) (0.25 * (dx + dy) + 0.5);
        iy0 = iy1 - (int) (0.25 * (-dx + dy) + 0.5);

        g.drawLine(ix0, iy0, ix1, iy1);
      }
    }
  }
Exemple #19
0
 public void getColorOfSquare(Graphics board, int row, int column) {
   // If the square falls on both an even row and column, it's a red square
   if ((row % 2) == (column % 2)) {
     // Set the red color
     board.setColor(Color.red);
   } else // otherwise it's black
   {
     // Set the black color
     board.setColor(Color.black);
   }
 }
Exemple #20
0
 public void stare_paint(Graphics g) {
   int licznik = 0;
   test++;
   for (int i = 0; i < 100; i += 3) {
     g.setColor(kolory[licznik++ % kolory.length]);
     g.fillRoundRect(i, i, 400 - i * 2, 200 - i * 2, 10, 10);
   }
   g.setFont(f);
   g.setColor(kolor);
   g.drawString("Trebuchet MS jest " + test, 50, 100);
 }
  public static int drawTree(Graphics g, int left, int right, int n, int x1, int y1) {
    int x2 = (left + right) / 2;
    int y2 = y1 + 70;
    if (n < number) {
      g.drawLine(x1, y1, x2, y2);
      g.drawString(String.valueOf(n), x2 - 10, y2 + 10);
    } else g.drawString(String.valueOf(n), x2 - 10, y2);

    if (n == 0 || n == 1) return n;
    else return drawTree(g, left, x2, n - 1, x2, y2) + drawTree(g, x2, right, n - 2, x2, y2);
  }
Exemple #22
0
  public void run() {
    int i = -1, tx = -1, ty = -1, alive_cnt;
    int[] dx = {0, 1, 0, -1};
    int[] dy = {-1, 0, 1, 0};
    Graphics g = getGraphics();

    while (true) {
      try {
        alive_cnt = 0;
        for (i = 0; i < NUM_PLAYERS; i++) {
          if (palive[i] == 1) {
            if (i > 0) DoAI(i);
            tx = px[i] + dx[pdir[i]];
            ty = py[i] + dy[pdir[i]];
            if ((tx < 0)
                || (tx >= SIZE_X)
                || (ty < 0)
                || (ty >= SIZE_Y)
                || (map[tx + ty * SIZE_X] != 0)) {
              palive[i] = 0;
            } else {
              px[i] = tx;
              py[i] = ty;
              map[tx + ty * SIZE_X] = (byte) (i + 1);
            }
          }
          if (palive[i] == 1) {
            alive_cnt++;
            g.setColor(new Color(pcolor[i]));
            g.drawLine(px[i], py[i], px[i], py[i]);
          }
        }
        if (palive[0] == 0) {
          g.setColor(new Color(0xff7070));
          g.drawString("You Lose!", 50, 120);
          repaint();
          stop();
        } else if (alive_cnt == 1) {
          g.setColor(new Color(0x7070ff));
          g.drawString("You Win!", 50, 120);
          repaint();
          stop();
        }

        repaint();
        Thread.sleep(25);
      } catch (InterruptedException e) {

        g.drawString("IException!", 50, 100);
        repaint();
        stop();
      } catch (Exception e) {
        g.drawString("Exception:" + e.toString() + "\n", 50, 100);
        repaint();
      }
    }
  }
 public void paint(Graphics g) {
   switch (msg) {
     case (1):
       g.drawString("Mouse in Window", 0, 100);
       break;
     case (2):
       g.drawString("Mouse outside Window", 0, 100);
       break;
     case (0):
       g.drawString(
           "(" + String.valueOf(coordx) + "," + String.valueOf(coordy) + ")", coordx, coordy);
   }
 }
 public void lvlClearMenu(Graphics g) {
   // Menu that shows up after a level has been cleared
   if (pause == true && lvlClear == true) {
     g.drawImage(
         new ImageIcon("InGameMenu/pauseBckgrnd.png").getImage(), 0, 0, this); // <Graphics stuff
     g.drawImage(new ImageIcon("InGameMenu/stageClearPic.png").getImage(), 100, 0, this);
     displayScore2(g, 115, 350, 185, 380, 110, 440, 110, 490); // Displays stats
     g.drawImage(
         resumeB.getPic(mx, my), resumeB.getX(), resumeB.getY(), this); // Draws resume button
     g.drawImage(
         menuB.getPic(mx, my), menuB.getX(), menuB.getY(), this); // Draws the back to menu button
   }
 }
 public void gameOverMenu(
     Graphics g) { // CHANGE THIS TO INCLUDE HIGHSCORES AND STUFF AFTER TEXTFILES ARE MADE
   // Menu that shows up when user gets Game Over
   if (pause == true && die == true) {
     g.drawImage(
         new ImageIcon("InGameMenu/pauseBckgrnd.png").getImage(), 0, 0, this); // Graphics stuff
     g.setFont(scoreFont);
     g.setColor(Color.BLACK);
     g.drawImage(new ImageIcon("InGameMenu/GameOver.png").getImage(), 10, 200, this);
     displayScore2(g, 115, 350, 185, 385, 110, 440, 110, 490); // Shows stats
     g.drawImage(menuB.getPic(mx, my), menuB.getX(), menuB.getY(), this); // Draws menu button
   }
 }
Exemple #26
0
 public static void titlePage(Graphics g, String name, int period) {
   Expo.setBackground(g, Expo.gold);
   Expo.setColor(g, Expo.white);
   Expo.fillRectangle(g, 100, 100, 900, 550);
   Expo.setColor(g, Expo.red);
   Font title = new Font("Algerian", Font.BOLD, 48);
   g.setFont(title);
   g.drawString("Flags of the World", 225, 240);
   Expo.setColor(g, Expo.blue);
   g.drawString("by: " + name, 225, 340);
   Expo.setColor(g, Expo.green);
   g.drawString("Period: " + period, 225, 440);
   Expo.delay(3000); // Wait 3 second before showing first flag.
 }
 public void paint(Graphics g) {
   if (mainMenu) {
     drawTitleScreen(g);
   } else if (gamePlaying) {
     drawBricks(g);
     g.setColor(Color.green);
     g.fillRect(pad.x(), 590, pad.width(), 10);
     g.fillOval(
         ball.x_Pos() - ball.radius(),
         ball.y_Pos() - ball.radius(),
         ball.radius() * 2,
         ball.radius() * 2);
   }
 } // paint method
    public void paint(Graphics g) {
      g.setColor(getBackground());
      g.fillRect(0, 0, getWidth(), getHeight());

      for (int i = 0; i < numImages; i++) {
        if (x[i] > 3 * i) {
          nudge(i);
          squish(g, icon[i], xh[i], yh[i], scale[i]);
        } else {
          x[i] += .05;
          y[i] += .05;
        }
      }
    }
Exemple #29
0
  public void paint(Graphics g) {
    // chose Font with selected value
    f =
        new Font(
            lFont.getSelectedItem(),
            lStyle.getSelectedIndex(),
            Integer.parseInt(lSize.getSelectedItem()));

    // Clear Background
    g.setColor(Color.white);
    g.fillRect(0, 85, 400, 200);
    g.setColor(Color.black);

    if (f != null) {
      g.setFont(f);
    }

    g.drawString(sString.getText(), 20, 120);

    // Get Unicode char format FFFF in textfield sChar
    String s = sChar.getText();
    char c;
    try {
      c = (char) Integer.parseInt(s, 16);
      if (Character.isDefined(c)) g.drawString("char \\u" + s + " is " + c, 20, 180);
      else g.drawString("char \\u" + s + " not exist", 20, 180);
    } catch (Exception e) { // Can parse this string
      g.drawString("" + e, 20, 180);
    }
  }
 void drawBricks(Graphics g) {
   for (int x = 0; x < numBricksX; x++) {
     for (int y = 0; y < numBricksY; y++) {
       if (brickWall[x][y].notBroken()) {
         g.setColor(brickWall[x][y].colour());
         g.fillRect(
             brickWall[x][y].brickX(),
             brickWall[x][y].brickY(),
             brickWall[x][y].brickWidth(),
             brickWall[x][y].brickHeight());
       }
     }
   }
 }