protected void drawHistogram(Graphics g, MBinSummary binCnt) {
      //    ********************************
      // * Draw the histogram
      // ********************************
      MClusterSummary[] bins;
      int value;
      int height;
      int y;

      Color color;
      Font f = g.getFont();
      Font newFont = new Font(UIManager.getFont("Label.font").getName(), Font.PLAIN, 14);
      g.setFont(newFont);

      bins = binCnt.GetBins();
      // _maxBinsIndex

      // ***********************
      // draw the outliner even it is zero
      // ***********************
      value = bins[0].getCount();

      height = (int) ((double) value * _pixel_per_unit);

      y = _abs_line_height - height;

      g.setColor(MColorMgr.GetInstance().GetColor(0, MGlobal.FADE_IDX_MAX));
      g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
      g.setColor(Color.BLACK);
      g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
      g.drawString("0", (int) _bin_cur_x, _abs_axis_height);

      _bin_cur_x += (int) _bin_width_two;

      // ***********************
      // * draw the rest
      // ***********************

      for (int idx = 1; idx <= binCnt.GetMaxBinIndex(); idx++) {

        value = bins[idx].getCount();

        if (value > 0) {

          height = (int) ((double) value * _pixel_per_unit);

          y = _abs_line_height - height;

          g.setColor(MColorMgr.GetInstance().GetColor(idx, MGlobal.FADE_IDX_MAX));
          g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
          g.setColor(Color.BLACK);
          g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
          g.drawString(idx + "", (int) _bin_cur_x, _abs_axis_height);

          _bin_cur_x += (int) _bin_width_two;
        }
      }
      g.setFont(f);
      bins = null;
    }
Beispiel #2
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    // Clear screen.
    g.setColor(Color.white);
    g.fillRect(0, 0, getWidth(), getHeight());

    // draw entire component grey
    g.setColor(Fonts.sub_color);
    g.fillRect(0, 0, getWidth(), getHeight());

    // Write title.
    g.setColor(Color.BLACK);
    g.setFont(Fonts.big);
    g.drawString("Ear", 20, 150);
    g.drawString("Training", 20, 200);

    // Write "Choose Difficulty".
    g.setFont(Fonts.italic);
    g.drawString("Choose Difficulty", 20, 300);

    // Draw piano image
    keyboard.setDimensions(250, 0, getWidth(), getHeight());
    keyboard.paintComponent(g);
    mainMenu.paintComponent(g);
  }
Beispiel #3
0
  public void render(Graphics g) {

    Graphics2D g2d = (Graphics2D) g;

    menubg = ResourceTools.loadImageFromResource("skiinggame/4765.jpg");
    g.drawImage(menubg, 1, 1, null);
    Font fnt0 = new Font("arial", Font.BOLD, 50);
    playbutton = ResourceTools.loadImageFromResource("skiinggame/play_button.png");
    g.drawImage(playbutton, 250, 130, null);
    g.setFont(fnt0);
    g.setColor(Color.black);
    g.drawString("Ski Escape", 315, 100);

    Font fnt1 = new Font("arial", Font.BOLD, 30);
    g.setFont(fnt1);

    //        g.drawString("Play", playButton.x + 19, playButton.y + 35);

    g.setColor(new Color(0, 0, 0, 0));
    g2d.draw(playButton);

    //        g.drawString("Help", helpButton.x + 19, helpButton.y + 35);
    //        g2d.draw(helpButton);
    //        g.drawString("Quit", quitButton.x + 19, quitButton.y + 35);
    //        g2d.draw(quitButton);

  }
Beispiel #4
0
  public void paintComponent(Graphics g) {

    // draw the border
    g.setColor(Color.darkGray);
    g.fillRect(0, 0, 80, 80);
    g.fillRect(720 - 80, 0, 80, 80);
    g.fillRect(0, 0, 720, 60);
    g.fillRect(0, 608 - 80, 80, 80);
    g.fillRect(720 - 80, 608 - 80, 80, 80);
    g.fillRect(0, 608 - 60, 720, 60);

    // draw the objects
    super.paintComponent(g);

    Runner.scoreTotal = 200 * (100 * 500 + 3 * 10000);
    Runner.starsTotal = 3 * 200;

    // draw the score display
    g.setColor(new Color(20, 110, 255, 255));
    g.setFont(Runner.fontSmall);
    g.drawString("Score:", 338, 18);
    g.setFont(Runner.fontLarge);
    g.drawString("" + Runner.scoreTotal, 361 - String.valueOf(Runner.scoreTotal).length() * 9, 50);

    // draw the star display
    g.setColor(new Color(225, 225, 0, 255));
    g.drawImage(TextureCache._textures.get("star").getTexture(0, 32, 32), 100, 14, null);
    g.drawString("x " + Runner.starsTotal, 140, 40);

    // draw the trophy display

  }
Beispiel #5
0
  public void render(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Font titleFont = new Font("TimesRoman", Font.BOLD, 40);
    g.setFont(titleFont);
    g.setColor(Color.WHITE);
    g.drawString("INSTRUCTIONS", 60, 47);

    Font textFont = new Font("TimesRoman", Font.BOLD, 20);
    g.setFont(textFont);
    g.drawString("Player 1", 20, 95);
    g.drawString("Player 2", 280, 95);

    g2d.draw(startGame);
    g.drawString("Start Game", 277, 188);

    Font instructionFont = new Font("TimesRoman", Font.BOLD, 14);
    g.setFont(instructionFont);
    g.drawString("UP Key: Move Up", 20, 115);
    g.drawString("DOWN Key: Move Down", 20, 135);
    g.drawString("W: Move Up", 280, 115);
    g.drawString("S: Move Down", 280, 135);

    g.drawString("P: Pause/Resume", 137, 175);
    g.drawString("R: Restart", 160, 195);
  }
  public void paintComponent(Graphics g) {
    try {
      // set background
      g.setColor(Color.LIGHT_GRAY);
      g.fillRect(0, 0, this.getWidth(), this.getHeight());

      // Draw Image
      Graphics2D g2d = (Graphics2D) g;
      g2d.drawImage(image, 0, 0, 50, 50, null);

      // draw text under image
      g2d.setColor(Color.BLACK);
      g.setFont(new Font("Monotype Corsiva", Font.PLAIN, 15));
      g.drawString(lines[1], 0, 60);

      // draw lines of text
      g.setFont(new Font("Arial", Font.PLAIN, 20));
      for (int i = 2; i < lines.length; i++) {
        if (lines[i].contains("red")) {
          g2d.setColor(Color.red);
          g.drawString(lines[i].replaceFirst("red", ""), 70, 25 + ((i - 2) * 20));
        } else if (lines[i].contains("blue")) {
          g2d.setColor(Color.BLUE);
          g.drawString(lines[i].replaceFirst("blue", ""), 70, 25 + ((i - 2) * 20));
        } else {
          g2d.setColor(Color.BLACK);
          g.drawString(lines[i], 70, 25 + ((i - 2) * 20));
        }
      }
    } catch (Exception e) {
      LogHandling.logMessage("Can't draw main menu   " + e);
    }
  }
  // Keeps track of the current frame #, gives directions, and a win message.
  @Override
  public boolean nextFrame() {
    framecount++;
    BufferedImage bg = Utility.loadBufferedImage("bonusLevel/BG_Colin_Monroe.png", this);
    bground.drawImage(bg, 0, 0, null);

    if (framecount > 6000) return false; // game times out after 6000 frames
    // draw each ball
    for (int i = 0; i < NUMBALLS; i++) // draw each ball using method
    {
      drawBall(i);
    }
    if (score == 100) // if score reaches limit (100) then initiate win sequence
    {
      canvas.setFont(new Font("TimesRoman", Font.PLAIN, 30));
      String message = "You WIN!!";
      canvas.drawChars(message.toCharArray(), 0, message.length(), 350, 160);
      canvas.setFont(new Font("TimesRoman", Font.PLAIN, 14));
      winCounter++;
      if (winCounter == 100) return false;
    } else if (framecount <= 200)
    // ^at the beginning of level, (first 200 frames) display instructions
    {
      canvas.setFont(new Font("TimesRoman", Font.PLAIN, 30));
      String message = "Click the Prime Numbers!";
      canvas.drawChars(message.toCharArray(), 0, message.length(), 240, 160);
      canvas.setFont(new Font("TimesRoman", Font.PLAIN, 14));
    } else // display score throughout gameplay
    {
      String message = "Score:" + Integer.toString(getScore());
      canvas.drawChars(message.toCharArray(), 0, message.length(), 370, 160);
    }
    repaint();
    return true;
  }
 void drawRoiLabel(Graphics g, int index, Roi roi) {
   Rectangle r = roi.getBounds();
   int x = screenX(r.x);
   int y = screenY(r.y);
   double mag = getMagnification();
   int width = (int) (r.width * mag);
   int height = (int) (r.height * mag);
   int size = width > 40 && height > 40 ? 12 : 9;
   if (font != null) {
     g.setFont(font);
     size = font.getSize();
   } else if (size == 12) g.setFont(largeFont);
   else g.setFont(smallFont);
   boolean drawingList = index >= LIST_OFFSET;
   if (drawingList) index -= LIST_OFFSET;
   String label = "" + (index + 1);
   if (drawNames && roi.getName() != null) label = roi.getName();
   FontMetrics metrics = g.getFontMetrics();
   int w = metrics.stringWidth(label);
   x = x + width / 2 - w / 2;
   y = y + height / 2 + Math.max(size / 2, 6);
   int h = metrics.getAscent() + metrics.getDescent();
   if (bgColor != null) {
     g.setColor(bgColor);
     g.fillRoundRect(x - 1, y - h + 2, w + 1, h - 3, 5, 5);
   }
   if (!drawingList && labelRects != null && index < labelRects.length)
     labelRects[index] = new Rectangle(x - 1, y - h + 2, w + 1, h);
   g.setColor(labelColor);
   g.drawString(label, x, y - 2);
   g.setColor(defaultColor);
 }
 /**
  * Draw a light gray mask over the track with a text
  *
  * @param g graphics object
  * @param height height of the graphics
  * @param text a text to display
  */
 protected void drawMultiGenomeMask(Graphics g, int height, String text) {
   Font oldFont = g.getFont();
   Font newFont = g.getFont().deriveFont(Font.BOLD, 14);
   g.setFont(newFont);
   g.setColor(Colors.RED);
   g.drawString(text, 10, height - 5);
   g.setFont(oldFont);
 }
Beispiel #10
0
 public void paint(Graphics g) {
   // draw the text
   g.setColor(leafRed);
   g.setFont(bigFont);
   g.drawString(line1, 15, 100);
   g.setFont(smallFont);
   g.drawString(line2, 46, 140);
 }
Beispiel #11
0
 public void drawPause(Graphics g) {
   Font font = new Font("Arial", Font.BOLD, 40);
   g.setFont(font);
   g.setColor(new Color(210, 84, 0));
   g.drawString("PAUSED", 175, 220);
   font = new Font("Arial", Font.BOLD, 20);
   g.setFont(font);
   g.drawString("Press [ESC] again to resume", 120, 250);
 }
Beispiel #12
0
  /**
   * Renders graphics such as backgrounds, colour, image locations, image size, etc.
   *
   * @panam graphic object
   * @return render game
   */
  public void render(Graphics g) {
    if (System.currentTimeMillis() - startTime > duration) {
      translate = 1;
      imageTranslate = 1;

      return;
    }
    // renders timeStop cutIn picture
    effect.render(g);
    if (eventName.equals("timeStopCutIn")) {
      // g.drawImage(homuraCutInBg,5,5,GameSystem.ABSWIDTH,GameSystem.ABSHEIGHT,null);
      // g.setColor(Color.WHITE);
      // g.fillRect(0, 0, 700, 700);
      // g.drawImage(homuraCutIn,(int) (100-translate),0,null);
      g.drawImage(
          cutInLarge,
          (int) (-1 * GameSystem.ABSWIDTH / 2 + translate),
          -1 * GameSystem.ABSHEIGHT / 3,
          null);
      g.drawImage(background, (int) (-1 * imageTranslate - 20), 0, null);
      g.setColor(Color.BLACK);
      g.setFont(new Font("arial", Font.ITALIC, 32));
      g.drawImage(homuraCutIn, (int) (GameSystem.ABSWIDTH / 3 - translate), 0, null);
      g.drawString("TIME STOP", 50, 400);
    } else if (eventName.equals("madokaCutIn")) {
      g.drawImage(
          madokaCutInLarge,
          (int) (-1 * GameSystem.ABSWIDTH / 2 + translate + 100),
          -1 * GameSystem.ABSHEIGHT / 3,
          null);
      g.drawImage(pinkStripes, (int) (-1 * imageTranslate - 20), 0, null);
      g.setColor(Color.BLACK);
      g.setFont(new Font("arial", Font.ITALIC, 32));
      g.drawImage(madokaCutIn, (int) (GameSystem.ABSWIDTH / 3 - translate + 100), 0, null);
      g.drawString("", 50, 400);
    } else if (eventName.equals("sayakaCutIn")) {
      // Graphics2D g2D = (Graphics2D)g;
      // g.drawImage(blueBlob,rand.nextInt(GameSystem.ABSWIDTH)-blueBlob.getWidth()/2,rand.nextInt(GameSystem.ABSHEIGHT)-blueBlob.getWidth()/2,null);
      // g.drawImage(background, (int) (-1*imageTranslate-20),0,null);
      g.drawImage(blueBgTrans, 0, 0, null);
      createStripes(g);
      g.drawImage(
          saCutIn1,
          (int) (GameSystem.ABSWIDTH / 4 - translate + 100),
          (int) (-1 * translate / 3),
          null);
      // createStripes(g);
      // createStripes(g);
      // g.drawImage(blueBlob,rand.nextInt(GameSystem.ABSWIDTH),rand.nextInt(GameSystem.ABSHEIGHT),null);
      // g.drawImage(blueBlob,rand.nextInt(GameSystem.ABSWIDTH),rand.nextInt(GameSystem.ABSHEIGHT),null);

    } else if (eventName.equals("sayakaCutIn2")) {
      g.drawImage(blueBgTrans, 0, 0, null);
      createStripes(g);
      g.drawImage(saCutIn2, (int) (-100 + translate), (int) (120 + translate / 3), null);
    }
  }
  @Override
  public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    // draw entire component white
    g.setColor(Color.white);
    g.fillRect(0, 0, getWidth(), getHeight());

    // yellow circle
    g.setColor(Color.yellow);
    g.fillOval(0, 0, 240, 240);

    // magenta circle
    g.setColor(Color.magenta);
    g.fillOval(160, 160, 240, 240);

    // paint the icon below blue sqaure
    int w = java2sLogo.getIconWidth();
    int h = java2sLogo.getIconHeight();
    java2sLogo.paintIcon(this, g, 280 - (w / 2), 120 - (h / 2));

    // paint the icon below red sqaure
    java2sLogo.paintIcon(this, g, 120 - (w / 2), 280 - (h / 2));

    // transparent red square
    g.setColor(m_tRed);
    g.fillRect(60, 220, 120, 120);

    // transparent green circle
    g.setColor(m_tGreen);
    g.fillOval(140, 140, 120, 120);

    // transparent blue square
    g.setColor(m_tBlue);
    g.fillRect(220, 60, 120, 120);

    g.setColor(Color.black);

    g.setFont(monoFont);
    FontMetrics fm = g.getFontMetrics();
    w = fm.stringWidth("Java Source");
    h = fm.getAscent();
    g.drawString("Java Source", 120 - (w / 2), 120 + (h / 4));

    g.setFont(sanSerifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("and");
    h = fm.getAscent();
    g.drawString("and", 200 - (w / 2), 200 + (h / 4));

    g.setFont(serifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("Support.");
    h = fm.getAscent();
    g.drawString("Support.", 280 - (w / 2), 280 + (h / 4));
  }
Beispiel #14
0
  // public void paintComponent(Graphics screen) {
  public void paint(Graphics screen) {
    //    if (okButton == null) setup();

    Dimension size = getSize();
    if ((size.width != sizeW) || (size.height != sizeH)) {
      // component has been resized
      offscreen = null;
    }

    if (offscreen == null) {
      sizeW = size.width;
      sizeH = size.height;
      //      setButtonBounds();
      if (Toolkit.highResDisplay()) {
        offscreen = createImage(sizeW * 2, sizeH * 2);
      } else {
        offscreen = createImage(sizeW, sizeH);
      }
    }

    Graphics g = offscreen.getGraphics();
    /*Graphics2D g2 =*/ Toolkit.prepareGraphics(g);

    g.setFont(font);
    if (metrics == null) {
      metrics = g.getFontMetrics();
      ascent = metrics.getAscent();
    }

    g.setColor(bgcolor[mode]);
    g.fillRect(0, 0, sizeW, sizeH);

    g.setColor(fgcolor[mode]);
    // https://github.com/processing/processing/issues/3265
    if (message != null) {
      g.setFont(font); // needs to be set each time on osx
      g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
    }

    if (indeterminate) {
      // int x = cancelButton.getX();
      // int w = cancelButton.getWidth();
      int w = Preferences.BUTTON_WIDTH;
      int x = getWidth() - Preferences.GUI_SMALL - w;
      int y = getHeight() / 3;
      int h = getHeight() / 3;
      g.setColor(new Color(0x80000000, true));
      g.drawRect(x, y, w, h);
      for (int i = 0; i < 10; i++) {
        int r = (int) (x + Math.random() * w);
        g.drawLine(r, y, r, y + h);
      }
    }

    screen.drawImage(offscreen, 0, 0, sizeW, sizeH, null);
  }
Beispiel #15
0
 private void renderCommand(Graphics g) {
   g.setColor(Colour.getColour("WHITE"));
   g.setFont(Fonts.getFont("STANDARD_ITALIC"));
   g.drawString("commands", 50, 560);
   g.setFont(Fonts.getFont("STANDARD"));
   g.drawString("ATTACK", 50, 605);
   g.drawString("SKILLS", 50, 650);
   g.drawString("BERSERK", 50, 695);
   g.drawString("ITEM", 50, 740);
 }
Beispiel #16
0
 public void drawLose(Graphics g) {
   Font font = new Font("Arial", Font.BOLD, 60);
   g.setFont(font);
   g.setColor(new Color(210, 84, 0));
   g.drawString("Slow Draw", 100, 200);
   g.drawString("You Lose", 120, 260);
   font = new Font("Arial", Font.BOLD, 20);
   g.setFont(font);
   g.drawString("Press [ENTER] to restart", 140, 300);
 }
Beispiel #17
0
 public void drawWin(Graphics g) {
   Font font = new Font("Arial", Font.BOLD, 40);
   g.setFont(font);
   g.setColor(new Color(210, 84, 0));
   g.drawString("This town ain't big", 15, 100);
   g.drawString("enough for the both of us!", 15, 140);
   font = new Font("Arial", Font.BOLD, 20);
   g.setFont(font);
   g.drawString("You Won", 210, 180);
   g.drawString("Press [ENTER] to restart", 140, 300);
 }
Beispiel #18
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Dimension sz = getSize();
    int top = Math.max(0, (sz.height - tableHeight) / 2);
    int left = Math.max(0, (sz.width - tableWidth) / 2);
    Model model = getModel();
    if (model == null) return;
    Selection sel = model.getSelection();
    int columns = sel.size();
    if (columns == 0) {
      g.setFont(BODY_FONT);
      GraphicsUtil.drawCenteredText(
          g, Strings.get("tableEmptyMessage"), sz.width / 2, sz.height / 2);
      return;
    }

    g.setColor(Color.GRAY);
    int lineY = top + cellHeight + HEADER_SEP / 2;
    g.drawLine(left, lineY, left + tableWidth, lineY);

    g.setColor(Color.BLACK);
    g.setFont(HEAD_FONT);
    FontMetrics headerMetric = g.getFontMetrics();
    int x = left;
    int y = top + headerMetric.getAscent() + 1;
    for (int i = 0; i < columns; i++) {
      x = paintHeader(sel.get(i).toShortString(), x, y, g, headerMetric);
    }

    g.setFont(BODY_FONT);
    FontMetrics bodyMetric = g.getFontMetrics();
    Rectangle clip = g.getClipBounds();
    int firstRow = Math.max(0, (clip.y - y) / cellHeight - 1);
    int lastRow = Math.min(rowCount, 2 + (clip.y + clip.height - y) / cellHeight);
    int y0 = top + cellHeight + HEADER_SEP;
    x = left;
    for (int col = 0; col < columns; col++) {
      SelectionItem item = sel.get(col);
      ValueLog log = model.getValueLog(item);
      int radix = item.getRadix();
      int offs = rowCount - log.size();
      y = y0 + Math.max(offs, firstRow) * cellHeight;
      for (int row = Math.max(offs, firstRow); row < lastRow; row++) {
        Value val = log.get(row - offs);
        String label = val.toDisplayString(radix);
        int width = bodyMetric.stringWidth(label);
        g.drawString(label, x + (cellWidth - width) / 2, y + bodyMetric.getAscent());
        y += cellHeight;
      }
      x += cellWidth + COLUMN_SEP;
    }
  }
Beispiel #19
0
  @Override
  public void repaint(Graphics g) {

    if (start) {
      if (show) {
        try {

          currentXp = ctx.skills.getExperience(Skills.HERBLORE);
          long currCount = currentXp;
          if (lastCount != currCount) {
            long currentXp = ctx.skills.getExperience(Skills.FLETCHING);
            experienceGained = (currentXp - startXp);
            made++;
          }
          lastCount = currCount;

        } catch (Exception a) {
          a.printStackTrace();
        }
        g.setColor(Constants.BLACK_TRANS);
        g.fillRect(7, 395, 490, 114);

        g.setColor(Color.PINK);
        g.setFont(Constants.PAINT_TITLE_FONT);
        g.drawString("Tornado Fletcher", 170, 410);
        g.drawString("Time running: " + runTime.toElapsedString(), 158, 425);

        g.setColor(Color.PINK);
        g.setFont(Constants.PAINT_TEXT_FONT);
        StringBuilder experience = new StringBuilder();
        experience.append("Experience: ");
        experience.append(experienceGained);
        experience.append(" (+");
        experience.append(sd.experience(SkillData.Rate.HOUR, Skills.FLETCHING));
        experience.append(")");
        g.drawString(experience.toString(), 10, 454);
        g.drawString(
            "TTL: "
                + (ctx.skills.getLevel(Skills.FLETCHING) == 99
                    ? "N/A"
                    : Timer.format(sd.timeToLevel(SkillData.Rate.HOUR, Skills.FLETCHING))),
            10,
            468);
        g.drawString("Fletched: " + Misc.perHourInfo(startTime, made), 10, 482);
        g.drawString("- Tornado", 435, 506);
      }
    }
    int x = (int) ctx.mouse.getLocation().getX();
    int y = (int) ctx.mouse.getLocation().getY();

    mt.add(ctx.mouse.getLocation());
    mt.draw(g, x, y);
  }
 @Override
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   x = 20;
   y = 30;
   g.setFont(courierItalic);
   displayMetrics(g);
   g.setFont(timesPlain);
   displayMetrics(g);
   g.setFont(scriptBold);
   displayMetrics(g);
 }
  public void paintComponent(Graphics g) { // paintComponent

    super.paintComponent(g); // refresh screen (paint background)

    Font f = new Font("Helvetica", Font.BOLD, 40);
    g.setFont(f);
    g.drawString("DON'T ABUSE", 40, 130);
    g.drawString("SUBSTANCES", 40, 180);
    f = new Font("Helvetica", Font.BOLD, 50);
    g.setFont(f);
    g.drawString("KIDS", 120, 240);
  }
  private void drawAllText(Graphics g) {
    g.setColor(Color.BLACK);
    Font prev_font = g.getFont();
    ;
    Font cur_Font = new Font("Arial", Font.BOLD, 10); // Book Antiqua
    g.setFont(cur_Font);
    int i = 0;
    // char[] str = m_x_str.toCharArray();
    // Axis
    int x = (int) (m_width * 0.85);
    if (m_x_unit.trim().length() > 0) {
      g.setColor(Color.BLUE);
      g.drawString("(" + m_x_unit + ")", x, m_y_offset + 10);
      g.setColor(Color.BLACK);
    }

    for (; i < m_x_str.length(); x += 10, i++)
      g.drawString(m_x_str.substring(i, i + 1), x, m_y_offset);

    if (m_Vdisplay) {
      i = 0;
      int y = m_y_offset - m_y_str.length() * 5;
      for (; i < m_y_str.length(); y += 10, i++)
        g.drawString(m_y_str.substring(i, i + 1), 10, m_y_offset - (int) (m_height * 0.5) + y);
      if (m_y_unit.trim().length() > 0) {
        g.setColor(Color.BLUE);
        g.drawString("(" + m_y_unit + ")", 10, y + 10);
        g.setColor(Color.BLACK);
      }

    } else {
      g.setColor(Color.BLACK);
      g.drawString(m_y_str, 10, m_y_offset - 30);
      g.setColor(Color.BLUE);
      g.drawString(" (" + m_y_unit + ")", 10, m_y_offset - 10);
      g.setColor(Color.BLACK);
    }

    // m_heading
    g.setColor(new Color(100, 100, 100)); // Color.black);//new Color(0.80f,0.36f,0.36f));
    cur_Font = new Font("Arial", Font.BOLD, 14);
    g.setFont(cur_Font);
    g.drawString(m_heading, (int) (m_width * 0.25), 15);

    // Current Value
    g.setColor(Color.BLACK);
    cur_Font = new Font("Arial", Font.BOLD, 10);
    g.setFont(cur_Font);
    g.drawString(m_y_str + " : " + m_cur_y + " " + m_y_unit, 35, m_height - 20);

    g.drawString(m_x_str + " : " + m_cur_x + " " + m_x_unit, 35, m_height - 12);
  }
Beispiel #23
0
 public void paint(Graphics g) {
   double beatWidth = sp.beatWidth;
   g.setFont(font);
   for (int i = 0; i < (sp.score.getEndTime()); i++) {
     int xLoc = (int) Math.round(i * beatWidth);
     if (i % timeSig == 0) {
       g.drawLine(xLoc, 0, xLoc, height);
       if (beatWidth > 15) g.drawString("" + i, xLoc + 2, height - 2);
     } else {
       g.drawLine(xLoc, height / 2, xLoc, height);
     }
   }
 }
Beispiel #24
0
 /**
  * Helper method for redraw to draw screen during phase of maze generation, screen is hard coded
  * only attribute percentdone is dynamic
  *
  * @param gc graphics is the off screen image
  */
 void redrawGenerating(Graphics gc) {
   gc.setColor(Color.yellow);
   gc.fillRect(0, 0, Constants.VIEW_WIDTH, Constants.VIEW_HEIGHT);
   gc.setFont(largeBannerFont);
   FontMetrics fm = gc.getFontMetrics();
   gc.setColor(Color.red);
   centerString(gc, fm, "Building maze", 150);
   gc.setFont(smallBannerFont);
   fm = gc.getFontMetrics();
   gc.setColor(Color.black);
   centerString(gc, fm, maze.getPercentDone() + "% completed", 200);
   centerString(gc, fm, "Hit escape to stop", 300);
 }
Beispiel #25
0
 /**
  * Helper method for redraw to draw final screen, screen is hard coded
  *
  * @param gc graphics is the off screen image
  */
 void redrawFinish(Graphics gc) {
   gc.setColor(Color.blue);
   gc.fillRect(0, 0, Constants.VIEW_WIDTH, Constants.VIEW_HEIGHT);
   gc.setFont(largeBannerFont);
   FontMetrics fm = gc.getFontMetrics();
   gc.setColor(Color.yellow);
   centerString(gc, fm, "You won!", 100);
   gc.setColor(Color.orange);
   gc.setFont(smallBannerFont);
   fm = gc.getFontMetrics();
   centerString(gc, fm, "Congratulations!", 160);
   gc.setColor(Color.white);
   centerString(gc, fm, "Hit any key to restart", 300);
 }
Beispiel #26
0
  public void render(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Font titleFont = new Font("TimesRoman", Font.BOLD, 50);
    g.setFont(titleFont);
    g.setColor(Color.WHITE);
    g.drawString("PONG", 125, 50);

    Font textFont = new Font("TimesRoman", Font.BOLD, 16);
    g.setFont(textFont);
    g2d.draw(onePlayer);
    g.drawString("One Player", 158, 98);
    g2d.draw(twoPlayer);
    g.drawString("Two Player", 158, 148);
  }
Beispiel #27
0
 protected void paintComponent(Graphics g) {
   super.paintComponents(g);
   configureFormatter();
   double lineDistance = getLineDistance();
   Rectangle clip = g.getClipBounds();
   g.clearRect(clip.x, clip.y, clip.width, clip.height);
   g.setColor(Color.black);
   if (isVertical()) {
     double halfLineDistance = lineDistance / 2.0d;
     for (double line = (double) getHeight() - (minUnit % lineDistance);
         line > 0;
         line -= lineDistance) {
       g.drawLine(0, (int) line, getWidth(), (int) line);
     }
     for (double line = (double) getHeight() - ((minUnit - halfLineDistance) % lineDistance);
         line > 0;
         line -= lineDistance) {
       int inset = 3;
       g.drawLine(inset, (int) line, getWidth() - inset, (int) line);
     }
     String number = null;
     for (double line = (double) getHeight() - (minUnit % lineDistance);
         line > 0;
         line -= lineDistance) {
       g.setFont(font);
       String newNumber = format((getHeight() - line) / getPixelsPerUnit()) + getUnitName();
       if (!newNumber.equals(number)) g.drawString(newNumber, 2, (int) line - 2);
       number = newNumber;
     }
   } else {
     double halfLineDistance = lineDistance / 2.0d;
     for (double line = (minUnit % lineDistance); line < getWidth(); line += lineDistance) {
       g.drawLine((int) line, 0, (int) line, getHeight());
     }
     for (double line = (minUnit - halfLineDistance) % lineDistance;
         line < getWidth();
         line += lineDistance) {
       int inset = 3;
       g.drawLine((int) line, inset, (int) line, getHeight() - inset);
     }
     String number = null;
     for (double line = (minUnit % lineDistance); line < getWidth(); line += lineDistance) {
       // for (double line = unitStart; line < unitEnd; line += lineDistance) {
       g.setFont(font);
       String newNumber = format(line / getPixelsPerUnit()) + getUnitName();
       if (!newNumber.equals(number)) g.drawString(newNumber, ((int) line) + 3, getHeight() - 2);
       number = newNumber;
     }
   }
 }
Beispiel #28
0
  @Override
  protected void paintComponent(Graphics g) {
    measures.ensureComputed(g);

    Rectangle clip = g.getClipBounds();
    if (isOpaque()) {
      g.setColor(getBackground());
      g.fillRect(clip.x, clip.y, clip.width, clip.height);
    }

    long addr0 = model.getFirstOffset();
    long addr1 = model.getLastOffset();

    long xaddr0 = measures.toAddress(0, clip.y);
    if (xaddr0 == addr0) xaddr0 = measures.getBaseAddress(model);
    long xaddr1 = measures.toAddress(getWidth(), clip.y + clip.height) + 1;
    highlighter.paint(g, xaddr0, xaddr1);

    g.setColor(getForeground());
    Font baseFont = g.getFont();
    FontMetrics baseFm = g.getFontMetrics(baseFont);
    Font labelFont = baseFont.deriveFont(Font.ITALIC);
    FontMetrics labelFm = g.getFontMetrics(labelFont);
    int cols = measures.getColumnCount();
    int baseX = measures.getBaseX();
    int baseY = measures.toY(xaddr0) + baseFm.getAscent() + baseFm.getLeading() / 2;
    int dy = measures.getCellHeight();
    int labelWidth = measures.getLabelWidth();
    int labelChars = measures.getLabelChars();
    int cellWidth = measures.getCellWidth();
    int cellChars = measures.getCellChars();
    for (long a = xaddr0; a < xaddr1; a += cols, baseY += dy) {
      String label = toHex(a, labelChars);
      g.setFont(labelFont);
      g.drawString(
          label, baseX - labelWidth + (labelWidth - labelFm.stringWidth(label)) / 2, baseY);
      g.setFont(baseFont);
      long b = a;
      for (int j = 0; j < cols; j++, b++) {
        if (b >= addr0 && b <= addr1) {
          String val = toHex(model.get(b), cellChars);
          int x = measures.toX(b) + (cellWidth - baseFm.stringWidth(val)) / 2;
          g.drawString(val, x, baseY);
        }
      }
    }

    caret.paintForeground(g, xaddr0, xaddr1);
  }
Beispiel #29
0
  /*
   * Draws menu header (logo and particles)
   */
  private void drawMenuHeader(Graphics g) {
    g.setFont(Fonts.largefont);
    FontMetrics fm = g.getFontMetrics();
    g.setColor(Color.YELLOW);
    // Draw logo
    Image img = game.imgs[0];
    g.drawImage(img, (winSize.width - img.getWidth(null)) / 2, 30, null);
    g.setFont(Fonts.smallfont);
    fm = g.getFontMetrics();
    g.drawString("by Ben Homer", 10, winSize.height - 20);

    if (DBClient.loggedIn) {
      g.drawString("Logged in as: " + DBClient.getName(), 10, 30);
    }
  }
  /**
   * Creates a TextToken using a graphical tag. Such a tag is color or font related.
   *
   * @param g Graphics used to retrieve the font metrics.
   * @param tag A pseudo HTML tag without '<', '</' and '>'.
   * @return a new TextToken initialized according to the tag.
   */
  private TextToken updateGfx(Graphics g, String tag) {
    TextToken textTok = new TextToken();

    if (tag.startsWith("c=") || tag.startsWith("k=")) {
      Color color = tag.startsWith("c=") ? textTok.m_color : textTok.m_bkCol;
      int rgb = 0;

      textTok.m_font = new Font(m_name, m_style, m_size);
      g.setFont(textTok.m_font);

      try {
        rgb = Integer.decode(tag.substring(2)).intValue(); // #RRGGBB

        if (color == null || color.getRGB() == rgb) {
          if (tag.startsWith("c=")) {
            m_color = rgb;
            textTok.m_color = new Color(rgb);
            textTok.m_bkCol = m_bkCol != -1 ? new Color(m_bkCol) : null;
          } else {
            m_bkCol = rgb;
            textTok.m_bkCol = new Color(rgb);
            textTok.m_color = new Color(m_color);
          }
        }
      } catch (NumberFormatException e) {
        System.out.println("[updateTag] Wrong color format : " + tag);
        return null;
      }
    } else {
      textTok.m_color = new Color(m_color);

      if (tag.equals("b")) {
        m_style |= Font.BOLD;
      } else if (tag.equals("i")) {
        m_style |= Font.ITALIC;
      } else if (tag.startsWith("s=")) {
        m_size = Integer.parseInt(tag.substring(2));
      } else if (tag.startsWith("f=")) {
        m_name = tag.substring(2);
      } else {
        System.out.println("[updateGfx] Syntax error Tag : " + tag);
        return null;
      }
      textTok.m_font = new Font(m_name, m_style, m_size);
      g.setFont(textTok.m_font);
    }
    return textTok;
  }