Example #1
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);
  }
  private synchronized void render(Graphics g) {
    if (level != null) {
      int xScroll = (int) (player.pos.x - screen.w / 2);
      int yScroll = (int) (player.pos.y - (screen.h - 24) / 2);
      soundPlayer.setListenerPosition((float) player.pos.x, (float) player.pos.y);
      level.render(screen, xScroll, yScroll);
    }
    if (!menuStack.isEmpty()) {
      menuStack.peek().render(screen);
    }

    Font.draw(screen, "FPS: " + fps, 10, 10);
    // for (int p = 0; p < players.length; p++) {
    // if (players[p] != null) {
    // String msg = "P" + (p + 1) + ": " + players[p].getScore();
    // Font.draw(screen, msg, 320, screen.h - 24 + p * 8);
    // }
    // }
    if (player != null && menuStack.size() == 0) {
      Font.draw(screen, player.health + " / 10", 340, screen.h - 19);
      Font.draw(screen, "" + player.score, 340, screen.h - 33);
    }

    g.setColor(Color.BLACK);

    g.fillRect(0, 0, getWidth(), getHeight());
    g.translate((getWidth() - GAME_WIDTH * SCALE) / 2, (getHeight() - GAME_HEIGHT * SCALE) / 2);
    g.clipRect(0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE);

    if (!menuStack.isEmpty() || level != null) {

      // render mouse
      renderMouse(screen, mouseButtons);

      g.drawImage(screen.image, 0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE, null);
    }

    // String msg = "FPS: " + fps;
    // g.setColor(Color.LIGHT_GRAY);
    // g.drawString(msg, 11, 11);
    // g.setColor(Color.WHITE);
    // g.drawString(msg, 10, 10);

  }
Example #3
0
  /**
   * This method will draw the axes (if axes mode is on) and the line.
   *
   * @param gc the graphics
   * @see #setAxes
   * @see #setLog
   */
  void drawAll(Graphics gc) {
    Dimension osize = getSize();

    gc.setColor(getBackground());
    gc.fillRect(0, 0, osize.width, osize.height);

    gc.clipRect(0, 0, osize.width, osize.height);

    if (doAxes) {
      gc.setColor(axisColour);
      gc = paintAxis(gc);
    }

    gc.setColor(getBackground());
    gc.fillRect(0, 0, osize.width, osize.height); // trust the clip

    if (dataSet != null) {
      gc.setColor(graphColour);
      paintLine(gc);
    }
  }