Example #1
0
 public void drawPause(Graphics2D graphics) {
   Rectangle2D textBackground = new Rectangle2D.Double(219, 232, 292, 146);
   Rectangle2D textBackground2 = new Rectangle2D.Double(222, 235, 286, 140);
   String text = "Paused!";
   String text2 = "Press              to Resume";
   String text3 = "Press                          to";
   String text4 = "Return to Menu";
   String text5 = "Enter";
   String text6 = "BackSpace";
   graphics.setColor(Color.gray);
   graphics.fill(textBackground);
   graphics.setColor(Color.darkGray);
   graphics.fill(textBackground2);
   graphics.setColor(Color.orange);
   Font arial2 = new Font("Tekton Pro", Font.PLAIN, 25);
   Font arial = new Font("Tekton Pro", Font.PLAIN, 50);
   graphics.setFont(arial);
   graphics.setColor(Color.white);
   graphics.drawString(text, 285, 285);
   graphics.setColor(Color.orange);
   graphics.setFont(arial2);
   graphics.drawString(text2, 250, 310);
   graphics.drawString(text3, 260, 335);
   graphics.drawString(text4, 290, 360);
   graphics.setColor(Color.red);
   graphics.drawString(text5, 315, 310);
   graphics.drawString(text6, 325, 335);
 }
Example #2
0
  @Override
  public void draw(Graphics2D g) {
    for (BBox box : walls) {
      camera.draw(box);
    }

    for (BBox box : platforms) {
      camera.draw(box);
    }

    camera.draw(character1);

    camera.drawCamera();
    if (black) {
      camera.drawClear(g);
      g.setColor(Color.WHITE);
    } else {
      camera.drawWhite(g);
    }
    g.setFont(g.getFont().deriveFont(Font.PLAIN, 12));
    g.drawString("Max speed: " + character1.getMaxSpeed(), 10, 10);
    g.drawString("Acceleration: " + character1.getAcceleration(), 10, 20);
    g.drawString("Friction: " + character1.getFriction(), 10, 30);
    g.drawString("Jump: " + character1.getJump(), 10, 40);
    g.drawString("Gravity: " + character1.getGravity(), 10, 50);
    g.drawString("----------------" + character1.getGravity(), 10, 60);
    g.drawString("Controls: ", 10, 70);
    g.drawString("--------", 10, 80);
    g.drawString("q, a, w, s, e, d", 10, 90);
    g.drawString("r, f, t, g, c, v, b", 10, 100);
  }
Example #3
0
 private void trataDesenhoBotao(Graphics2D dbg, Botao bt, int XTela, int YTela) {
   // TODO Auto-generated method stub
   dbg.setFont(Constantes.FonteNormal);
   if (bt.name == "range") {
     dbg.setColor(Color.white);
     dbg.drawString(
         "$" + torrePai.armaAtiva.custoRange,
         (int) bt.getX() + bt.getSizeX() + 10 - XTela,
         (int) bt.getY() + bt.getSizeY() - 2 - YTela);
   }
   if (bt.name == "fire") {
     dbg.setColor(Color.white);
     dbg.drawString(
         "$" + torrePai.armaAtiva.custoFire,
         (int) bt.getX() + bt.getSizeX() + 10 - XTela,
         (int) bt.getY() + bt.getSizeY() - 2 - YTela);
   }
   if (bt.name == "dano") {
     dbg.setColor(Color.white);
     dbg.drawString(
         "$" + torrePai.armaAtiva.custoDano,
         (int) bt.getX() + bt.getSizeX() + 10 - XTela,
         (int) bt.getY() + bt.getSizeY() - 2 - YTela);
   }
 }
Example #4
0
  @Override
  public void paint(Graphics g) {

    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
    if (metrics == null) {
      metrics = g2d.getFontMetrics(font);
      width = this.getWidth();
      height = this.getHeight();
      playerHealthPosX = width - healthbarWidth - 30;
    }

    g2d.setColor(new Color(255, 0, 0));
    g2d.fillRect(30, 0, (int) (healthOwnerM * healthbarWidth), height);

    if (isMultiplayer) {
      int hToSub = (int) ((1 - healthPlayerM) * healthbarWidth);
      g2d.fillRect(playerHealthPosX + hToSub, 0, healthbarWidth - hToSub, height);
    }
    g2d.setColor(new Color(0, 0, 0));
    g2d.setFont(font);
    g2d.drawString(pointsOwner, ownerStringPosX, stringHeight);
    if (isMultiplayer) {
      playerStringPosX = width - healthbarWidth - 35 - metrics.stringWidth(pointsPlayer);
      g2d.drawString(pointsPlayer, playerStringPosX, stringHeight);
    }
  }
Example #5
0
  public void render(int w, int h, Graphics2D g2) {

    g2.translate(w * .2, h * .2);

    GeneralPath p = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    p.moveTo(0.0f, 0.0f);
    p.lineTo(w * .5f, 0.0f);
    p.lineTo(w * .5f, h * .2f);
    p.lineTo(0.0f, h * .2f);
    p.closePath();

    p.moveTo(w * .05f, h * .05f);
    p.lineTo(w * .55f, h * .05f);
    p.lineTo(w * .55f, h * .25f);
    p.lineTo(w * .05f, h * .25f);
    p.closePath();

    g2.setColor(LIGHT_GRAY);
    g2.fill(p);
    g2.setColor(BLACK);
    g2.draw(p);
    g2.drawString("NON_ZERO rule", 0, -5);

    g2.translate(0.0f, h * .45);

    p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    g2.setColor(LIGHT_GRAY);
    g2.fill(p);
    g2.setColor(BLACK);
    g2.draw(p);
    g2.drawString("EVEN_ODD rule", 0, -5);
  }
  private void paintString(
      Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Graphics2D g2 = (Graphics2D) g;
    String progressString = progressBar.getString();
    g2.setFont(progressBar.getFont());
    Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height);
    Rectangle oldClip = g2.getClipBounds();

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      g2.setColor(getSelectionBackground());
      g2.drawString(progressString, renderLocation.x, renderLocation.y);
      g2.setColor(getSelectionForeground());
      g2.clipRect(fillStart, y, amountFull, height);
      g.drawString(progressString, renderLocation.x, renderLocation.y);
    } else { // VERTICAL
      g2.setColor(getSelectionBackground());
      AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
      g2.setFont(progressBar.getFont().deriveFont(rotate));
      renderLocation = getStringPlacement(g2, progressString, x, y, width, height);
      g2.drawString(progressString, renderLocation.x, renderLocation.y);
      g2.setColor(getSelectionForeground());
      g2.clipRect(x, fillStart, width, amountFull);
      g2.drawString(progressString, renderLocation.x, renderLocation.y);
    }
    g2.setClip(oldClip);
  }
  @Override
  public void draw(Graphics2D g) {
    g.setColor(Color.white);
    g.drawString("Score: " + SCORE, 5, 15);

    g.setColor(Color.red);
    g.drawString("Health: " + player.getHealth(), 5, 35);

    blocks.draw(g);
    player.draw(g);
    level.draw(g);

    if (level.isGameOver()) {
      g.setColor(Color.red);
      g.setFont(gameScreen);
      String gameOver = "GAME OVER!";
      int gameOverWidth = g.getFontMetrics().stringWidth(gameOver);
      g.drawString(gameOver, (Display.WIDTH / 2) - (gameOverWidth / 2), Display.HEIGHT / 2);
    }

    if (level.isComplete()) {
      g.setColor(Color.green);
      g.setFont(gameScreen);
      String complete = "LEVEL COMPLETE!";
      int completeWidth = g.getFontMetrics().stringWidth(complete);
      g.drawString(complete, (Display.WIDTH / 2) - (completeWidth / 2), Display.HEIGHT / 2);
    }
  }
Example #8
0
 public void paintBar(Graphics2D g) {
   g.setColor(Color.RED);
   g.setFont(new Font("", 1, 25));
   g.drawString(
       "Infecting Computer...",
       fitTextInBoxWidth("Infecting Computer...", g, FakeVTroll.WIDTH),
       100);
   g.setColor(Color.GRAY);
   g.fillRoundRect(50, FakeVTroll.HEIGHT / 2, FakeVTroll.WIDTH - 100, 20, 10, 10);
   g.setColor(Color.RED);
   g.fillRoundRect(50, FakeVTroll.HEIGHT / 2, calcBarProgress(FakeVTroll.WIDTH - 100), 20, 10, 10);
   g.setFont(new Font("", 1, 15));
   g.setColor(Color.BLACK);
   g.drawString(
       progressPercent2 + "%",
       fitTextInBoxWidth(progressPercent2 + "%", g, FakeVTroll.WIDTH),
       (FakeVTroll.HEIGHT / 2) + 15);
   if (shouldUseScare) {
     g.setFont(new Font("", 1, 20));
     g.drawString(
         fakeInstalls[fakeInstUse],
         fitTextInBoxWidth(fakeInstalls[fakeInstUse], g, FakeVTroll.WIDTH),
         (FakeVTroll.HEIGHT / 2) + 90);
   }
 }
Example #9
0
  @Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(new Color(0, 0, 0));

    for (int j = 0; j < 8; j++) {
      ImageIcon ii = new ImageIcon(this.getClass().getResource("/images/" + 2 + ".png"));
      g2.drawImage(ii.getImage(), j * 70, 560, this);
    }

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        ImageIcon ii =
            new ImageIcon(this.getClass().getResource("/images/" + mGame[i][j] + ".png"));
        g2.setFont(new Font("ARIAL", Font.BOLD, 60));
        if (mGame[i][j] == OK) {
          g2.drawString(" " + logic.getScore(), j * 70, i * 70);
        }
        if (mGame[i][j] == ERROR) {
          g2.drawString("-3", j * 70, i * 70);
        }
        g2.drawImage(ii.getImage(), j * 70, i * 70, this);
        g2.setFont(new Font("ARIAL", Font.BOLD, 20));
        g2.setColor(Color.DARK_GRAY);

        g2.drawString("Seus Tijolos : " + logic.getScore(), 10, 600);
        g2.drawString("Quantidade : " + QUANTIDADE_TIJOLO, 200, 600);
        g2.drawString("Tempo : " + time, 450, 600);
      }
    }
  }
Example #10
0
  /**
   * Draws the entity's sprite at the entity's current position. If the entity has no sprite, a red
   * rectangle is drawn instead.
   *
   * @param g Graphics context to draw on.
   */
  public void draw(Graphics2D g) {
    // David : Thomas, clean this up. whatever follows your conventions.
    //		the deubbing if statment is not inteneded to used simulation wide. but you can if you want
    //		the above is just to help with the debugging of cars
    // David : Thomas, fix this
    if (sprite == null) {
      System.err.println("Sprite is null!. chossing cars/testDummy.jpg sprite");
      try {
        new Sprite("cars/testDummy.jpg").draw(g, x - w / 2, y - h / 2, dirRad(), x, y);
      } catch (java.io.FileNotFoundException e) {
        System.out.println(e.getMessage());
      }
    } else {
      // if nothing is wrong, draw the sprite
      sprite.draw(g, x - w / 2, y - h / 2, dirRad(), x, y);
    }

    if (debugging) {

      g.setColor(Color.BLACK);
      // draw the x and y of each entity
      g.drawString(String.format("x:%.1f", x), (int) (x - w / 2 + 3), (int) (y));
      g.drawString(String.format("y:%.1f", y), (int) (x - w / 2 + 3), (int) (y + 10));
    }
  }
Example #11
0
 private void drawTooltip(FishState fishUnderMouse) {
   int tooltipHeight = 20, tooltipBottomMargin = 10;
   bufferGraphics.setColor(Color.WHITE);
   bufferGraphics.fillRect(
       0, buffer.getHeight() - tooltipHeight, buffer.getWidth(), tooltipHeight);
   bufferGraphics.setColor(Color.BLACK);
   if (fishUnderMouse != null) {
     bufferGraphics.drawString(
         String.format(
             "Frame %d ID %d, Nut %.2f, Change %.2f, Speed %.2f, Dir %s",
             state.seqID,
             fishUnderMouse.fish_id,
             fishUnderMouse.getNutrients(),
             Rules.decay(fishUnderMouse),
             fishUnderMouse.getSpeed(),
             fishUnderMouse.getRudderVector()),
         5,
         buffer.getHeight() - tooltipBottomMargin);
   } else {
     bufferGraphics.drawString(
         String.format(
             "Frame %d, Fish %d, Controllers %d, Max fish %d, Max nut %.2f",
             state.seqID,
             state.getNumFish(),
             state.getNumControllers(),
             state.getMaxFish(),
             state.getMaxNutrients()),
         5,
         buffer.getHeight() - tooltipBottomMargin);
   }
 }
Example #12
0
 public void drawLevel(Graphics2D graphics, int level) {
   String text = "Level:";
   graphics.setColor(Color.white);
   graphics.setFont(new Font("Tekton Pro", Font.PLAIN, 30));
   graphics.drawString(text, 30, 40);
   graphics.drawString(String.valueOf(level), 110, 40);
 }
Example #13
0
 public void drawLives(Graphics2D graphics, int Lives) {
   String text = "Lives:";
   graphics.setColor(Color.white);
   graphics.setFont(new Font("Tekton Pro", Font.PLAIN, 30));
   graphics.drawString(text, 30, 80);
   graphics.drawString(String.valueOf(Lives), 110, 80);
 }
Example #14
0
 public void drawScore(Graphics2D graphics, int Score) {
   String text = "Score:";
   graphics.setColor(Color.white);
   graphics.setFont(new Font("Tekton Pro", Font.PLAIN, 30));
   graphics.drawString(text, 30, 120);
   graphics.drawString(String.valueOf(Score), 120, 120);
 }
Example #15
0
  public void draw(Graphics2D graphics, DrawingProperties properties) {
    Color startingcol = graphics.getColor();
    Font startingfont = graphics.getFont();
    graphics.setColor(Constants.COLOR_ERROR);
    graphics.setFont(Constants.FONT_CANVAS_SMALL);

    int w = cmptodraw.getWidth();
    int h = cmptodraw.getHeight();
    if (componentName == null) componentName = cmptodraw.getTypeName().toString();

    // draw a rectangle
    graphics.setColor(Color.WHITE);
    graphics.fillRect(EDGE_OFFSET, EDGE_OFFSET, w - 2 * EDGE_OFFSET, h - 2 * EDGE_OFFSET);
    graphics.setColor(Constants.COLOR_ERROR);
    graphics.drawRect(EDGE_OFFSET, EDGE_OFFSET, w - 2 * EDGE_OFFSET, h - 2 * EDGE_OFFSET);

    // draw invalidated sign
    graphics.drawLine(EDGE_OFFSET, EDGE_OFFSET, w - EDGE_OFFSET, h - EDGE_OFFSET);
    graphics.drawLine(EDGE_OFFSET, h - EDGE_OFFSET, w - EDGE_OFFSET, EDGE_OFFSET);

    // draw border
    int wmeo = w - EDGE_OFFSET;
    int hmeo = h - EDGE_OFFSET;
    for (int j = BORDER_LINES_STEP * 2; j <= hmeo; j += BORDER_LINES_STEP) {
      graphics.drawLine(0, j, EDGE_OFFSET, j - BORDER_LINES_STEP);
      graphics.drawLine(wmeo, j, w, j - BORDER_LINES_STEP);
    }
    for (int i = 0; i <= wmeo; i += BORDER_LINES_STEP) {
      graphics.drawLine(i, EDGE_OFFSET, i + BORDER_LINES_STEP, 0);
      graphics.drawLine(i, h, i + BORDER_LINES_STEP, hmeo);
    }

    // draw component type name and instance name
    if (properties.drawingComponentNames) {
      Font oldf = graphics.getFont();
      Color oldc = graphics.getColor();

      Font f = new Font(Constants.TEXT_FONT_CANVAS, Font.PLAIN, Constants.TEXT_NORMAL_FONT_SIZE);
      graphics.setFont(f);
      graphics.drawString(
          cmptodraw.getName().toString(), 0, -Constants.TEXT_NORMAL_FONT_SIZE * 1.5f);

      f = new Font(Constants.TEXT_FONT_CANVAS, Font.PLAIN, Constants.TEXT_SMALL_FONT_SIZE);
      int r = oldc.getRed() + 140;
      r = (r > 230) ? (230) : (r);
      int g = oldc.getGreen() + 140;
      g = (g > 230) ? (230) : (g);
      int b = oldc.getBlue() + 140;
      b = (b > 230) ? (230) : (b);
      graphics.setColor(new Color(r, g, b));
      graphics.setFont(f);
      graphics.drawString(componentName, 0, -Constants.TEXT_NORMAL_FONT_SIZE * 0.5f);

      graphics.setFont(oldf);
      graphics.setColor(oldc);
    }

    graphics.setColor(startingcol);
    graphics.setFont(startingfont);
  }
Example #16
0
  public void draw(node leaf, Graphics2D g, int px, int py) {
    int lvl = leaf.getLevel();
    double l = lvl;
    counts[lvl]++;

    double xfraq = counts[lvl] / (spacing[lvl] + 1);
    double yfraq = l / depth;
    int x = new Double(1600 * xfraq).intValue();
    int y = new Double(1200 * yfraq).intValue() + 10;

    if (leaf.getAttr() != null) {
      g.drawString(leaf.getAttr(), x - 20, y);
    }
    if (leaf.getCrit() != null) {
      g.drawString(leaf.getCrit(), x - 20, y + 10);
    }
    if (leaf.getResult() != null) {
      g.drawString(leaf.getResult(), x - 20, y + 10);
    }
    g.drawLine(x, y, px, py);
    // g.fillRect(x,y,20,20);
    ArrayList children = leaf.getChildren();
    while (!children.isEmpty()) {
      draw((node) children.remove(0), g, x, y);
    }
  }
  @Override
  public final void pintar(Graphics2D g) {

    Graphics2D gBloque = (Graphics2D) g.create();
    pintarBloque(gBloque);
    gBloque.dispose();

    if (ayudaVisible) {
      final int altura = FUENTE * (ayudasMST.size() + ayudasBloque.size()) + MARGEN;
      int y = MetalSlugT.getAlto() - altura;
      g.setColor(Color.BLACK);
      g.fillRect(0, y, MetalSlugT.getAncho(), altura);

      g.setColor(Color.GREEN);
      g.setFont(g.getFont().deriveFont((float) FUENTE));
      for (String str : ayudasMST) {
        y += FUENTE;
        g.drawString(str, MARGEN, y);
      }
      for (String str : ayudasBloque) {
        y += FUENTE;
        g.drawString(str, MARGEN, y);
      }
    }
  }
Example #18
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    currentX = leftMargin;
    currentY = topMargin;

    // Draw the links

    for (int i = 0; i < linkLines.length; i++) {
      if (weights[i].isActive()) {
        g2.setPaint(weights[i].getColor());
        g2.draw(linkLines[i]);
      }
    }

    g2.setPaint(Color.black);

    // Draw the input neurons
    g2.drawString("Inputs", (float) currentX, (float) currentY);
    currentY += titleSpace;

    for (int i = 0; i < genome.getInputs(); i++) {
      g2.drawImage(inputNeuron, (int) currentX, (int) currentY, null);
      currentY += space;
    }

    // Draw the hidden Neurons
    currentX += space;
    currentY = topMargin;
    g2.drawString("Hidden Layers", (float) currentX, (float) currentY);

    for (int i = 0; i < genome.getHiddenLayers(); i++) {
      currentY = topMargin + titleSpace;
      for (int j = 0; j < genome.getNeuronsInHiddenLayer(); j++) {
        g2.drawImage(hiddenNeuron, (int) currentX, (int) currentY, null);
        currentY += space;
      }
      currentX += space;
    }

    // Draw the output neurons
    currentY = topMargin;
    g2.drawString("Outputs", (float) currentX, (float) currentY);
    currentY += titleSpace;

    for (int i = 0; i < genome.getOutputs(); i++) {
      g2.drawImage(outputNeuron, (int) currentX, (int) currentY, null);
      currentY += space;
    }

    // Draw the links

    for (int i = 0; i < linkLines.length; i++) {
      if (weights[i].isActive()) {
        g2.setPaint(weights[i].getColor());
        g2.draw(linkLines[i]);
      }
    }
  }
  private void printHeatSinks(Graphics2D g2d) {
    Font font = UnitUtil.deriveFont(true, 8.0f);
    g2d.setFont(font);

    // Heat Sinks
    if (smallCraft.getHeatType() == Aero.HEAT_DOUBLE) {
      g2d.drawString(
          String.format("%1$s (%2$s)", smallCraft.getHeatSinks(), smallCraft.getHeatSinks() * 2),
          508,
          540);
      g2d.drawString("Double", 508, 546.5f);
    } else {
      g2d.drawString(String.format("%1$s (%1$s)", smallCraft.getHeatSinks()), 508, 540);
      g2d.drawString("Single", 508, 546.5f);
    }

    Dimension column = new Dimension(510, 556);
    Dimension pipShift = new Dimension(9, 9);

    for (int pos = 1; pos <= smallCraft.getHeatSinks(); pos++) {
      ImageHelper.drawHeatSinkPip(g2d, column.width, column.height);
      column.height += pipShift.height;

      if ((pos % 10) == 0) {
        column.height -= pipShift.height * 10;
        column.width += pipShift.width;
      }
    }
  }
  /*
   * paintComponent draws whenever repaint() is called. It draws the nodes and lines between the nodes.
   */
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    g2.setColor(new Color(92, 221, 92));
    g2.setStroke(new BasicStroke(10));

    for (Node n : draftboard.getNodes()) {
      for (Node r : n.getNodeRefs()) {
        g2.setColor(new Color(92, 221, 92));
        g2.setStroke(new BasicStroke(10));
        g2.drawLine(
            n.getLocation().x + NODE_LENGTH / 2,
            n.getLocation().y + NODE_LENGTH / 2,
            r.getLocation().x + NODE_LENGTH / 2,
            r.getLocation().y + NODE_LENGTH / 2);
      }
    }

    for (Node n : draftboard.getNodes()) {
      if (n.getClass() == CirclePost.class) {
        g2.drawImage(
            circleNode, n.getLocation().x, n.getLocation().y, NODE_LENGTH, NODE_LENGTH, null);
        g2.setColor(Color.BLACK);
        g2.drawString(n.getText(), n.getLocation().x + 50, n.getLocation().y + 50);
      } else if (n.getClass() == SquarePost.class) {

        g2.drawImage(
            squareNode, n.getLocation().x, n.getLocation().y, NODE_LENGTH, NODE_LENGTH, null);
        g2.setColor(Color.BLACK);
        g2.drawString(n.getText(), n.getLocation().x + 50, n.getLocation().y + 50);
      }
    }
  }
  /**
   * Creates BufferImage with text painted in black with white edge of sizes in parameters.
   *
   * @param text
   * @param font
   * @param textWidth
   * @param textHeight
   * @param ascent
   * @return
   */
  protected BufferedImage createImageWithText(
      String text, Font font, int textWidth, int textHeight, int ascent) {
    textWidth = textWidth + 2;
    textHeight = textHeight + 2;

    BufferedImage bi = new BufferedImage(textWidth, textHeight, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2 = bi.createGraphics();

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int x = 1;
    // int y = textHeight;
    int y = ascent;

    g2.setFont(font);

    // paint white border
    g2.setColor(Color.WHITE);
    g2.drawString(text, x + 1, y + 1);
    g2.drawString(text, x + 1, y - 1);
    g2.drawString(text, x - 1, y + 1);
    g2.drawString(text, x - 1, y - 1);

    // paint the black text
    g2.setColor(Color.BLACK);
    g2.drawString(text, x, y);

    g2.dispose();

    return bi;
  }
Example #22
0
 @Override
 public void drawTextAxis(
     Graphics2D g2d, Dimension dim, boolean isHorizontal, String text, double coordinate) {
   if (!this.showAxisFonts) return;
   g2d.setFont(this.axisFont);
   int width = g2d.getFontMetrics().stringWidth(text) + this.axisFontMargin;
   int height = g2d.getFontMetrics().getHeight();
   /*if (isHorizontal)
   	g2d.fillRect(0, (int) dim.getHeight()-width,
   			(int) dim.getWidth(), (int) dim.getHeight());
   else
   	g2d.fillRect(0, 0, width, (int) dim.getHeight());*/
   g2d.setFont(axisFont);
   AffineTransform orig = g2d.getTransform();
   double angle = Math.toRadians(90);
   if (this.showAxisFonts)
     if (!isHorizontal) {
       g2d.setColor(this.axisBackgroundColor);
       g2d.fillRect(axisFontMargin, (int) coordinate - height, width, height);
       g2d.setColor(this.axisFontColor);
       g2d.drawString(text, this.axisFontMargin, (int) coordinate - axisFontMargin);
     } else {
       g2d.rotate(
           -angle, (int) coordinate - this.axisFontMargin, (int) dim.getHeight() - axisFontMargin);
       g2d.setColor(this.axisBackgroundColor);
       g2d.fillRect(
           (int) coordinate - this.axisFontMargin, (int) dim.getHeight() - height, width, height);
       g2d.setColor(this.axisFontColor);
       g2d.drawString(
           text, (int) coordinate - this.axisFontMargin, (int) dim.getHeight() - axisFontMargin);
       g2d.setTransform(orig);
     }
 }
Example #23
0
  // Paint the component
  @Override
  public void paint(Graphics g, JComponent c) {
    // If there are no time or layouts yet, we can't paint
    if (this.timeString == null || this.textLayout == null) return;

    // Get a reference to the <Graphics2D> instance and set the
    // anti-aliasing on
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Draw the string in the position dictated by the layout.
    g2.drawString(timeString.getIterator(), 1, (int) (textLayout.getAscent()));

    if (timezoneString != null && textTimezoneLayout != null) {
      g2.drawString(
          timezoneString.getIterator(),
          0,
          (int)
              (textLayout.getAscent()
                  + textLayout.getDescent()
                  + textLayout.getLeading()
                  + textTimezoneLayout.getAscent()
                  + MARGIN));
    }
  }
Example #24
0
 @Override
 public void paintComponent(Graphics g) {
   Graphics2D g2d = (Graphics2D) g;
   super.paintComponent(g2d);
   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   if (level < MAX_LEVEL) {
     g2d.drawImage(ground, 0, 0, Game.WIDTH, Game.HEIGHT2, null);
     g2d.drawImage(barbg, 250, Game.HEIGHT, 500, 100, null);
     play.draw(g2d);
     if (numDonuts < MAX_DONUTS) {
       g2d.setFont(font.deriveFont(30f));
       g2d.setColor(Color.BLACK);
       g2d.drawString("Level " + (level + 1), 280, Game.HEIGHT + 50);
       g2d.setColor(Color.BLUE);
       g2d.drawString(score + "", 670, Game.HEIGHT + 30);
       g2d.setColor(Color.RED);
       g2d.drawString(numDonuts + "/" + MAX_DONUTS, 450, Game.HEIGHT + 30);
     }
   } else {
     g2d.setColor(Color.CYAN);
     g2d.fillRect(0, 0, Game.WIDTH, Game.HEIGHT2);
     g2d.setFont(font.deriveFont(30f));
     g2d.setColor(Color.BLACK);
     if (perioTime % 12 > 0 && perioTime % 12 < 6) g2d.drawString("Please wait..", 320, 300);
     else g2d.drawString("Please wait...", 320, 300);
   }
 }
 protected void drawMultiplier(int xpix, int ypix, int exponent, Graphics2D g2) {
   Font oldFont = g2.getFont();
   g2.drawString("10", xpix, ypix); // $NON-NLS-1$
   g2.setFont(g2.getFont().deriveFont(Font.PLAIN, 9.0f));
   g2.drawString("" + exponent, xpix + 16, ypix - 6); // $NON-NLS-1$
   g2.setFont(oldFont);
 }
Example #26
0
  public void drawColorBar(Graphics2D g, int x, int y, int w, int h, double valueScale) {
    int n = colors.length;

    for (int i = 0; i < n; i++) {
      g.setColor(colors[i]);
      if (w < h) {
        g.fillRect(x, y + i * h / n, w, h / n + 1);
      } else {
        g.fillRect(x + i * w / n, y, w / n + 1, h);
      }
    }

    int fw, fh;
    FontMetrics fm = g.getFontMetrics();
    fh = fm.getHeight() / 2;
    fw =
        fm.stringWidth(
                String.valueOf(
                    Math.max((int) Math.abs(max * valueScale), (int) Math.abs(min * valueScale))))
            + fm.stringWidth("0.123");
    g.setColor(noDataColor);
    if (title != null) {
      g.drawString(title, x - fw - 3, y - fh * 3 / 2);
    }
    for (int i = 0; i <= intervalCount; i++) {
      g.setColor(colors[(int) (1.0 * i * n / intervalCount - 1e-10)]);
      final double val = min + i * (max - min) / intervalCount;
      final String txt = String.format("%.3f", val * valueScale);
      if (w < h) {
        g.drawString(txt, x - fw - 3, y + i * h / intervalCount + fh / 2);
      } else {
        g.drawString(txt, x + i * w / intervalCount - fw / 2, y + fh - 3);
      }
    }
  }
Example #27
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(new Color(219, 219, 72));
   Graphics2D g2d = (Graphics2D) g;
   RenderingHints rh =
       new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
   g2d.setRenderingHints(rh);
   Font fnt = new Font("STENCIL", Font.BOLD, 100);
   g2d.setColor(new Color(62, 11, 214));
   g2d.setFont(fnt);
   g2d.drawString("Hangman", 240, 100);
   fnt = new Font("STENCIL", Font.ITALIC, 30);
   g2d.setFont(fnt);
   g2d.setColor(new Color(11, 214, 201));
   g2d.drawString("created by Ashwin Gupta", 240, 125);
   /*g2d.setFont(new Font("Arial", Font.PLAIN, 75));
   g2d.drawString("PAINT BIG ", 100, 400);
   g2d.drawString("HANGMAN HERE", 100, 500);*/
   // int offset= 20;
   HangComponents dh = new HangComponents();
   g2d.setColor(Color.DARK_GRAY);
   for (int i = 0; i < 8; i++) {
     if (i == 7 || i == 6) {
       g2d.setStroke(new BasicStroke(45));
       g2d.draw(dh.hangman[i]);
     } else g2d.fill(dh.hangman[i]);
   }
 }
  protected void drawCoords(
      Graphics2D g,
      Color coordcolor,
      int offx,
      int cols,
      int COORDDELTA,
      int maxy,
      int offy,
      int rows,
      int maxx) {
    g.setColor(coordcolor);
    for (int c = offx; c <= offx + cols * BUCKET; c++) {
      int startx = (int) (BORDER + ((c - offx) / BUCKET * pixpercol));
      if (c % COORDDELTA == 0) {

        g.drawLine(startx, BORDER + (int) pixpercol, startx, maxy + (int) pixpercol);
        int value = c * coordscale;
        g.drawString("" + value, startx - 3, maxy + this.fontsize + 6);
      }
    }
    for (int r = offy; r <= offy + rows * BUCKET; r++) {
      int starty = (int) ((((r - offy) / BUCKET - 1) * pixperrow));
      if (r % COORDDELTA == 0) {
        g.drawLine(BORDER, maxy - starty, maxx, maxy - starty);
        int x = Math.max(1, BORDER - 10 - (int) (10 * (int) Math.log10(r + 1)));
        x = Math.min(x, BORDER - 15);
        int value = r * coordscale;
        g.drawString("" + value, x, maxy - starty + 3);
      }
    }
  }
  @Override
  public void onRepaint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;

    final Color color1 = new Color(213, 214, 175);
    final Color color2 = new Color(0, 0, 0);
    final Color color3 = new Color(1, 1, 1);

    final BasicStroke stroke1 = new BasicStroke(1);

    final Font font1 = new Font("Verdana", 3, 18);
    final Font font2 = new Font("Verdana", 1, 12);

    if (Game.isLoggedIn()) {
      currentWcExp = Skills.getExperience(Skills.WOODCUTTING);
      woodcuttingExpGained = currentWcExp - startWoodcuttingExp;
      int xpHour = (int) (3600000.0 / (runTime.getElapsed()) * woodcuttingExpGained);

      g.setColor(color1);
      g.fillRect(8, 394, 487, 114);
      g.setColor(color2);
      g.setStroke(stroke1);
      g.drawRect(8, 394, 487, 114);
      g.setFont(font1);
      g.setColor(color3);
      g.drawString("AnDraynorWillowChopper v0.3", 219, 421);
      g.setFont(font2);
      g.drawString("Status: " + Status, 18, 433);
      g.drawString("Run Time: " + runTime.toElapsedString(), 18, 452);
      g.drawString("Xp gained: " + woodcuttingExpGained + "(" + xpHour + ")/hr", 19, 472);
      g.drawString("WoodCutting Level: " + Skills.getLevel(Skills.WOODCUTTING), 18, 491);
    }
  }
Example #30
0
 @Override
 public void Draw(Graphics2D g2) {
   for (int i = 0; i < items.size(); i++) {
     if (SelectedIndex == i) g2.drawString(">>", 40, y + i * 12);
     g2.drawString((String) (items.toArray()[i]), 70, y + i * 12);
   }
 }