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);
 }
Example #2
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);
 }
Example #3
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);
  }
Example #4
0
  public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
    g.drawImage(background, 0, 0);

    g.setFont(menüSchriftStart); // render in mouseoverarea möglich!!!
    g.drawString("START", xtitle1, ytitle1);
    g.setFont(menüSchriftOptionen);
    g.drawString("OPTIONEN", xtitle2, ytitle2);
    g.setFont(menüSchriftCredits);
    g.drawString("CREDITS", xtitle3, ytitle3);
  }
 @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);
  }
Example #7
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);
  }
Example #8
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   myTime = new MyTime();
   g.setFont(font);
   g.setColor(fontColor);
   g.drawString(myTime.time, drawPointX, drawPointY);
 }
Example #9
0
  public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE && gamerunner.running) {

      Graphics gr = this.getGraphics();
      gr.setFont(new Font("TimesRoman", Font.PLAIN, 40));
      gr.drawString("PAUSE", (int) this.getWidth() / 2, this.getHeight() / 2);
      if (!online) {
        gamerunner.running = false;
      }
      if (soundan) {} // end of if
      Menu menu = new Menu(this);
      // volume.setValue(vol);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      gamerunner.running = true;
      if (soundan) {} // end of if
    } // end of if-else
    else if (e.getKeyCode() == KeyEvent.VK_R && !online) {
      restartGame();
    } else if (e.getKeyCode() == KeyEvent.VK_F11) {
      dispose();
      setUndecorated(true);
      String[] arguments = {"fullscreen"};
      new JavaGame(arguments);
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER && online) {
      String message =
          JOptionPane.showInputDialog(null, "Chat", "Nachricht", JOptionPane.PLAIN_MESSAGE);
      try {
        if (!message.isEmpty()) {
          client.sendNewChatMessage(player[client.id].name, message);
        }
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
Example #10
0
 // färger, se sid 43 i boken
 // grafiska metoder, sid 248 i boken
 public void paintComponent(Graphics g) { // för att vara säker på att
   // "super"-klassen gör sitt
   // anropar vi den metoden, innan
   // vi skriver eller ritar
   super.paintComponent(g);
   g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2
   g.drawLine(200, 10, 200, 40);
   g.drawLine(215, 10, 205, 40);
   g.setColor(Color.white);
   g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h)
   g.setColor(Color.red);
   g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l
   g.setColor(Color.yellow);
   g.fillRect(200, 100, 30, 30);
   g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur
   g.fill3DRect(250, 50, 30, 50, true);
   // skriv ut en textsträng, samt ange läget i avståndet från
   // övre vänstra hörnet i x-led åt höger och i y-led neråt
   g.drawString("** Tjenare kompis !! **", 20, 20);
   f = new Font("Arial", Font.BOLD, 30);
   setBackground(Color.cyan);
   g.setFont(f);
   g.setColor(new Color(255, 175, 175));
   g.drawString("YEEEEEEEES!!", 100, 250);
 }
Example #11
0
  /** paint */
  public void paint(Graphics g) {
    g.setFont(MainCanvas.nameFont);

    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    UIPainter.paintBackground(g);

    int i;
    for (i = 0; i < myTools.size(); i++) {
      if (se == i) {
        g.setColor(0, 0, 0);
        g.fillRect(
            0, i * MainCanvas.nameFont.getHeight(), getWidth(), MainCanvas.nameFont.getHeight());
        g.setColor(255, 255, 255);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      } else {
        g.setColor(0, 0, 0);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      }
    }

    UIPainter.paintLeftSoft(g, "Добавить");
    UIPainter.paintRightSoft(g, "Отмена");
  }
Example #12
0
  protected void paintSyntaxLine(
      Graphics gfx,
      TokenMarker tokenMarker,
      int line,
      Font defaultFont,
      Color defaultColor,
      int x,
      int y) {
    textArea.getLineText(currentLineIndex, currentLine);
    currentLineTokens = tokenMarker.markTokens(currentLine, currentLineIndex);

    paintHighlight(gfx, line, y);

    gfx.setFont(defaultFont);
    gfx.setColor(defaultColor);
    y += fm.getHeight();
    x = SyntaxUtilities.paintSyntaxLine(currentLine, currentLineTokens, styles, this, gfx, x, y);
    /*
     * Draw characters via input method.
     */
    if (compositionTextPainter != null && compositionTextPainter.hasComposedTextLayout()) {
      compositionTextPainter.draw(gfx, lineHighlightColor);
    }
    if (eolMarkers) {
      gfx.setColor(eolMarkerColor);
      gfx.drawString(".", x, y);
    }
  }
Example #13
0
 private void drawDialog(Graphics g) {
   Painter.drawDialog(
       g,
       0,
       gd.screenHeight - g.getFont().getHeight() * 3 - 20,
       gd.screenWidth,
       g.getFont().getHeight() * 3 + 20,
       Painter.DIALOG_DEEP);
   g.setFont(Const.Font.FONTSMALL_PLAIN);
   // 对话人
   Painter.drawString(
       g, gd.dialog_name + ":", 10, gd.screenHeight - g.getFont().getHeight() * 3 - 10, 0xffffff);
   // 两行对话内容
   Painter.drawString(
       g,
       gd.dialog_content[gd.dialog_index],
       10,
       gd.screenHeight - g.getFont().getHeight() * 2 - 10,
       0xffffff);
   if (gd.dialog_index + 1 < gd.dialog_content.length) {
     Painter.drawString(
         g,
         gd.dialog_content[gd.dialog_index + 1],
         10,
         gd.screenHeight - g.getFont().getHeight() - 10,
         0xffffff);
   }
 }
  public void draw(Graphics page) // draws letter on screen
      {

    page.setColor(color);
    page.setFont(new Font("TimesRoman", Font.PLAIN, 24));
    page.drawString(testString, x, y);
  }
Example #15
0
  /**
   * Main Sudoku Paint. Paints everything for the sudoku board.
   *
   * @param m
   * @param g
   * @param w
   * @param oh
   */
  @Override
  public void paint(SudokuModel m, Graphics g, int w, int oh) {
    this.oh = oh;
    this.w = w;
    int h = oh - 100;
    this.h = h;
    g.setFont(new Font(SANS_SERIF, PLAIN, 50));

    m.checkConflict();

    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j) paintSmallGrid(g, i * w / 3, j * h / 3, w / 3, h / 3);

    m.updateSelection();
    for (int i = 0; i < 9; ++i)
      for (int j = 0; j < 9; ++j) paintBox(g, i * w / 9, j * h / 9, m.get(j, i), w / 9, h / 9);
    paintGrid(g, w, h);

    if (m.gameOver()) {
      g.setColor(Color.BLACK);
      g.fillRect(w / 2 - 200, h / 2 - 100, 400, 200);
      g.setColor(Color.RED);
      drawStringBox(g, w / 2 - 200, h / 2 - 200, "GAME OVER", 400, 400);
    }
  }
Example #16
0
  private void drawYLabel(Graphics g) {
    g.setFont(fontBold);

    // # radians to rotate.
    double theta = -Math.PI / 2;

    Rectangle plotRect = getPlotRect();
    /*
     The y axis laabel.
    */
    String yLabel = "True Positive Fraction";
    int stringWidth = fm.stringWidth(yLabel);

    // where to begin drawing (the rotated image)
    Point translate =
        new Point(fm.getAscent(), plotRect.y + (plotRect.height / 2 + stringWidth / 2));

    Graphics2D g2 = (Graphics2D) g;
    AffineTransform save = g2.getTransform();

    g2.translate(translate.x, translate.y);
    g2.rotate(theta);

    g2.setColor(boundaryColor);
    g2.drawString(yLabel, 0, 0);

    g2.setTransform(save);
  }
Example #17
0
  @SuppressWarnings("deprecation")
  public final void runOneComponent(
      Component comp, Rectangle bounds, Graphics g, Shape clip, int weightFlags) {
    if (comp == null || comp.getPeer() == null || !comp.isVisible()) {
      return;
    }
    boolean lightweight = comp.isLightweight();
    if ((lightweight && (weightFlags & LIGHTWEIGHTS) == 0)
        || (!lightweight && (weightFlags & HEAVYWEIGHTS) == 0)) {
      return;
    }

    if (bounds == null) {
      bounds = comp.getBounds();
    }

    if (clip == null || clip.intersects(bounds)) {
      Graphics cg = g.create();
      try {
        constrainGraphics(cg, bounds);
        cg.setFont(comp.getFont());
        cg.setColor(comp.getForeground());
        if (cg instanceof Graphics2D) {
          ((Graphics2D) cg).setBackground(comp.getBackground());
        } else if (cg instanceof Graphics2Delegate) {
          ((Graphics2Delegate) cg).setBackground(comp.getBackground());
        }
        run(comp, cg);
      } finally {
        cg.dispose();
      }
    }
  }
 public void paint(Graphics g) {
   Font f = new Font("TimesRoman", Font.BOLD, 14);
   g.setFont(f);
   g.setColor(Color.red);
   setBackground(Color.blue);
   g.drawString("Hello Java", 30, 100);
 }
Example #19
0
 @Override
 public void draw(final Graphics g) {
   // System.out.println("Ritar: " + this);
   g.setColor(color);
   g.setFont(new Font("serif", Font.PLAIN, size));
   g.drawString(text, x, y);
 }
Example #20
0
  /** Affichage du logo */
  protected void drawLogo(Graphics g) {

    int x = 5;
    int y = 2;

    g.setColor(getBackground());
    g.fillRect(0, 0, W, H);

    // Remplissage
    fillBG(g, x, y, Color.white);

    // Dessin
    drawGrid(
        g,
        x,
        y,
        !isAvailable()
            ? Aladin.MYGRAY
            : isActive() ? Aladin.GREEN : isMouseIn() ? Color.blue : Color.black);

    // Label
    g.setColor(isAvailable() ? Color.black : Aladin.MYGRAY);
    g.setFont(Aladin.SPLAIN);
    g.drawString(LABEL, W / 2 - g.getFontMetrics().stringWidth(LABEL) / 2, H - 2);
  }
Example #21
0
  public void paint(Graphics g) {
    g.drawImage(Title, 450, 100, this);
    g.setFont(new Font("TimesRoman", Font.BOLD, 24));
    g.setColor(new Color(0x660033));

    setIconImage(icon);
  }
Example #22
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);
    }
  }
Example #23
0
  /**
   * Paints the graphic component
   *
   * @param g Graphic component
   */
  public void paint(Graphics g) {
    if (environment != null) {
      Sudoku env = (Sudoku) environment;
      Board board = env.getBoard();

      int n = SudokuLanguage.DIGITS;
      int sqrt_n = (int) (Math.sqrt(n) + 0.1);

      g.setColor(Color.lightGray);
      Font font = g.getFont();
      g.setFont(new Font(font.getName(), font.getStyle(), 20));
      for (int i = 0; i < n; i++) {
        int ci = getCanvasValue(i);
        if (i % sqrt_n == 0) {
          g.drawLine(ci, DRAW_AREA_SIZE + MARGIN, ci, MARGIN);
          g.drawLine(DRAW_AREA_SIZE + MARGIN, ci, MARGIN, ci);
        }

        for (int j = 0; j < n; j++) {
          int cj = getCanvasValue(j);
          int value = board.get(i, j);
          if (value > 0) {
            g.setColor(Color.black);
            g.drawString("" + value, cj + CELL_SIZE / 5, ci + CELL_SIZE);
            g.setColor(Color.lightGray);
          }
        }
      }
      g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN);
      g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN, DRAW_AREA_SIZE + MARGIN);
    }
  }
Example #24
0
  private BufferedImage generateFrame(GifFrame frame) {
    int width = frame.getColumns() * CELL_WIDTH;
    BufferedImage img =
        new BufferedImage(width, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT, IMAGE_TYPE_GIF);
    Graphics graphics = img.getGraphics();
    for (int row = 0; row < frame.getRows(); row++) {
      for (int col = 0; col < frame.getColumns(); col++) {
        ImageIcon icon =
            new ImageIcon(
                "site/images/" + frame.getBoard().get(row, col).getImageFilename() + ".png");
        graphics.drawImage(icon.getImage(), col * CELL_WIDTH, row * CELL_HEIGHT, null);
      }
    }

    for (BoxOverlay overlay : frame.getOverlays()) {
      graphics.setColor(overlay.getColor());
      Rectangle rect = overlay.getRectangle();
      int rect_x = rect.getLeft() * CELL_WIDTH - OVERLAY_PADDING;
      int rect_y = rect.getTop() * CELL_HEIGHT - OVERLAY_PADDING;
      int rect_width = (rect.getRight() - rect.getLeft() + 1) * CELL_WIDTH + 2 * OVERLAY_PADDING;
      int rect_height = (rect.getBottom() - rect.getTop() + 1) * CELL_HEIGHT + 2 * OVERLAY_PADDING;
      graphics.drawRect(rect_x, rect_y, rect_width, rect_height);
      graphics.drawRect(rect_x - 1, rect_y - 1, rect_width + 2, rect_height + 2);
    }

    graphics.setColor(FONT_COLOR);
    graphics.setFont(FONT);
    FontMetrics fm = graphics.getFontMetrics();
    graphics.drawString(
        frame.getText(),
        width / 2 - fm.stringWidth(frame.getText()) / 2,
        frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT / 2 + fm.getHeight() / 2);

    return img;
  }
  public void drawVictory(Graphics g) {
    g.setColor(new Color(0, 0, 0, 200));
    g.fillRect(195, 220, 410, 110);
    g.setColor(new Color(255, 255, 255, 200));
    g.fillRect(200, 225, 400, 100);
    g.setColor(new Color(0, 0, 0, 200));
    g.setFont(new Font("Bell MT", Font.BOLD, 20));
    FontMetrics metrics = g.getFontMetrics(new Font("Bell MT", Font.BOLD, 20));
    int hgt = metrics.getHeight();

    String initialMessage;
    String followupMessage;

    if (nextWindow) {
      initialMessage = "You have gotten stronger.";
      followupMessage = player.getName() + " is now level " + player.getLevel() + "!";
    } else {
      initialMessage = "You survived!";
      followupMessage = "You and your allies gain " + totalExperience + " experience!";
    }

    // Hgt = 26
    int adv = metrics.stringWidth(initialMessage);
    g.drawString(initialMessage, getWidth() / 2 - adv / 2, 234 + hgt);
    adv = metrics.stringWidth(followupMessage);
    g.drawString(followupMessage, getWidth() / 2 - adv / 2, 269 + hgt);
  }
Example #26
0
  public void paint(Graphics g) {
    m_fm = g.getFontMetrics();

    g.setColor(getBackground());
    g.fillRect(0, 0, getWidth(), getHeight());
    getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());

    g.setColor(getForeground());
    g.setFont(getFont());
    m_insets = getInsets();
    int x = m_insets.left;
    int y = m_insets.top + m_fm.getAscent();

    StringTokenizer st = new StringTokenizer(getText(), "\t");
    while (st.hasMoreTokens()) {
      String sNext = st.nextToken();
      g.drawString(sNext, x, y);
      x += m_fm.stringWidth(sNext);

      if (!st.hasMoreTokens()) break;
      int index = 0;
      while (x >= getTab(index)) index++;
      x = getTab(index);
    }
  }
Example #27
0
  // draws the button, based on the type of button (ImageIcon, Image, or String)
  public void draw(Graphics g) {
    if (visible) {
      // if its image/imageicon, draw it
      g.setColor(new Color(50, 200, 50));
      g.fillRect(x - 1, y - 1, width + 2, height + 2);
      if (mode.equals("Image") || mode.equals("ImageIcon")) {
        if (enabled) {
          g.drawImage(image, x, y, null);
        } else {
          g.drawImage(BWimage, x, y, null);
        }
        // if its string, draw the string
      } else {

        g.setFont(new Font("Arial", Font.PLAIN, 20));
        if (enabled) {
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        } else {
          g.setColor(new Color(255, 255, 255));
          g.fillRect(x - 1, y - 1, width + 2, height + 2);
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        }
      }
    }
  }
Example #28
0
  public void paintComponent(Graphics g) {
    if (name == "" && serialport == "") {
      Map<String, String> boardPreferences = Base.getBoardPreferences();
      if (boardPreferences != null) setBoardName(boardPreferences.get("name"));
      else setBoardName("-");
      setSerialPort(Preferences.get("serial.port"));
    }
    g.setColor(background);
    Dimension size = getSize();
    g.fillRect(0, 0, size.width, size.height);

    g.setFont(font);
    g.setColor(foreground);
    int baseline = (high + g.getFontMetrics().getAscent()) / 2;
    g.drawString(text, 6, baseline);

    g.setColor(messageForeground);
    String tmp = name + " on " + serialport;

    Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null);

    g.drawString(tmp, size.width - (int) bounds.getWidth() - 20, baseline);

    if (Base.isMacOS()) {
      g.drawImage(resize, size.width - 20, 0, this);
    }
  }
Example #29
0
  /** Paints the glyphs representing the given range. */
  public void paint(GlyphView v, Graphics g, Shape a, int p0, int p1) {
    sync(v);
    Segment text;
    TabExpander expander = v.getTabExpander();
    Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a : a.getBounds();

    // determine the x coordinate to render the glyphs
    int x = alloc.x;
    int p = v.getStartOffset();
    int[] justificationData = getJustificationData(v);
    if (p != p0) {
      text = v.getText(p, p0);
      int width = Utilities.getTabbedTextWidth(v, text, metrics, x, expander, p, justificationData);
      x += width;
      SegmentCache.releaseSharedSegment(text);
    }

    // determine the y coordinate to render the glyphs
    int y = alloc.y + metrics.getHeight() - metrics.getDescent();

    // render the glyphs
    text = v.getText(p0, p1);
    g.setFont(metrics.getFont());

    Utilities.drawTabbedText(v, text, x, y, g, expander, p0, justificationData);
    SegmentCache.releaseSharedSegment(text);
  }
Example #30
0
  /**
   * Function: drawNode Pre: Takes a graphics object g to draw on. Also takes two ints (x_size,
   * y_size) defining the screen size Also takes a node radius r Post: Prints out this node to the
   * screen appropriately
   */
  public void drawNode(Graphics g, int x_size, int y_size, int r) {
    // Don't print nodes that aren't activated
    if (!activated) return;

    // First, get some stats based on the Graphics area size
    // In particular, the size of the Node
    int px = (int) (x_size * x) - r; // X & Y positions
    int py = (int) (y_size * y) - r;

    // Set the font to appropriate no matter what
    // int sizor;    //The size for the text, based on radius
    g.setFont(new Font("Serif", Font.BOLD, r));

    // Find the color for the text, it's used often... we'll do this later now
    // String textcol = getOtherTextColor(color);  MOOF!  UPDATE THIS LATER!
    // Make sure the color is correct no matter what... adjust also later!

    // Node insides... get this color correct later, moof!
    g.setColor(getMyJavaColor());
    // g.setColor(Color.white);
    g.fillOval(px, py, r * 2, r * 2);

    // Node border
    g.setColor(getJavaColor(getOtherNodeColor(color)));
    g.drawOval(px, py, r * 2, r * 2);

    // Text inside... set up to be centered
    py = py + r + (int) (g.getFontMetrics().getAscent() / 2.2);
    px = px + r - (g.getFontMetrics().stringWidth("" + cindex) / 2);
    g.drawString("" + cindex, px, py);
  }