Package java.awt

Examples of java.awt.FontMetrics


      int index = -1;
      for (CreditsLine line : lines) {
        index++;
        if (index == initialLines) initialHeight = y;
        if (line.type == 0) y += 10;
        FontMetrics fm = fms[line.type];
        line.y = y + fm.getAscent();
        y += fm.getHeight();
      }
      linesHeight = y;
    }
   
    Paint[] paint = paintSteady;
View Full Code Here


      if (AppPreferences.SHOW_TICK_RATE.getBoolean()) {
        String hz = tickCounter.getTickRate();
        if (hz != null && !hz.equals("")) {
          g.setColor(TICK_RATE_COLOR);
          g.setFont(TICK_RATE_FONT);
          FontMetrics fm = g.getFontMetrics();
          int x = getWidth() - fm.stringWidth(hz) - 5;
          int y = fm.getAscent() + 5;
          g.drawString(hz, x, y);
        }
      }

      GraphicsUtil.switchToWidth(g, 1);
View Full Code Here

    }
   
    private void paintString(Graphics g, String msg) {
      Font old = g.getFont();
      g.setFont(old.deriveFont(Font.BOLD).deriveFont(18.0f));
      FontMetrics fm = g.getFontMetrics();
      int x = (getWidth() - fm.stringWidth(msg)) / 2;
      if (x < 0) x = 0;
      g.drawString(msg, x, getHeight() - 23);
      g.setFont(old);
      return;
    }
View Full Code Here

    private static int toDim(int offs) {
      return offs * 3 / 2;
    }
     
    private void drawText(Graphics g, int x, int y) {
      FontMetrics fm;
      String str;
     
      g.setColor(headerColor);
      g.setFont(headerFont);
      g.drawString("Logisim", x, y + 45);
      g.setFont(copyrightFont); fm = g.getFontMetrics();
      str = "\u00a9 " + Main.COPYRIGHT_YEAR;
      g.drawString(str, x + IMAGE_WIDTH - fm.stringWidth(str), y + 16);
      g.setFont(versionFont); fm = g.getFontMetrics();
      str = "Version " + Main.VERSION_NAME;
      g.drawString(str, x + IMAGE_WIDTH - fm.stringWidth(str), y + 75);
    }
View Full Code Here

    int w;
    int border = EditableLabelField.FIELD_BORDER;
    if (dimsKnown) {
      w = width + 1 + 2 * border;
    } else {
      FontMetrics fm = field.getFontMetrics(font);
      ascent = fm.getAscent();
      descent = fm.getDescent();
      w = 0;
    }
   
    int x0 = x;
    int y0 = getBaseY() - ascent;
View Full Code Here

  }

  public Bounds getBounds(Graphics g) {
    int x = this.x;
    int y = this.y;
    FontMetrics fm;
    if (font == null)   fm = g.getFontMetrics();
    else                fm = g.getFontMetrics(font);
    int width = fm.stringWidth(text);
    int ascent = fm.getAscent();
    int descent = fm.getDescent();
    switch (halign) {
    case TextField.H_CENTER:    x -= width / 2; break;
    case TextField.H_RIGHT:  x -= width; break;
    default:                    break;
    }
View Full Code Here

    Font old = g.getFont();
    if (font != null) g.setFont(font);

    int x = this.x;
    int y = this.y;
    FontMetrics fm = g.getFontMetrics();
    int width = fm.stringWidth(text);
    int ascent = fm.getAscent();
    int descent = fm.getDescent();
    switch (halign) {
    case TextField.H_CENTER:    x -= width / 2; break;
    case TextField.H_RIGHT:  x -= width; break;
    default:                    break;
    }
View Full Code Here

      }
      g.setFont(font);
      if (lines == 1 && !backs) {
        GraphicsUtil.drawCenteredText(g, label, x, y);
      } else {
        FontMetrics fm = g.getFontMetrics();
        int height = fm.getHeight();
        y = y - (height * lines - fm.getLeading()) / 2 + fm.getAscent();
        back = label.indexOf('\\');
        while (back >= 0 && back <= label.length() - 2) {
          char c = label.charAt(back + 1);
          if (c == 'n') {
            String line = label.substring(0, back);
View Full Code Here

    if (showState) {
      String str;
      int dispStart;
      int dispEnd;
      ArrayList<Integer> specials = new ArrayList<Integer>();
      FontMetrics fm = null;
      KeyboardData state = getKeyboardState(painter);
      synchronized(state) {
        str = state.toString();
        for (int i = state.getNextSpecial(0); i >= 0; i = state.getNextSpecial(i + 1)) {
          char c = state.getChar(i);
          specials.add(Integer.valueOf(c << 16 | i));
        }
        if (!state.isDisplayValid()) {
          fm = g.getFontMetrics(DEFAULT_FONT);
          state.updateDisplay(fm);
        }
        dispStart = state.getDisplayStart();
        dispEnd = state.getDisplayEnd();
      }
     
      if (str.length() > 0) {
        Bounds bds = painter.getBounds();
        drawBuffer(g, fm, str, dispStart, dispEnd, specials, bds);
      }
    } else {
      Bounds bds = painter.getBounds();
      int len = getBufferLength(painter.getAttributeValue(ATTR_BUFFER));
      String str = Strings.get("keybDesc", "" + len);
      FontMetrics fm = g.getFontMetrics();
      int x = bds.getX() + (WIDTH - fm.stringWidth(str)) / 2;
      int y = bds.getY() + (HEIGHT + fm.getAscent()) / 2;
      g.drawString(str, x, y);
    }
  }
View Full Code Here

   
    public void draw(InstancePainter painter) {
      KeyboardData data = getKeyboardState(painter);
      Bounds bds = painter.getInstance().getBounds();
      Graphics g = painter.getGraphics();
      FontMetrics fm = g.getFontMetrics(DEFAULT_FONT);

      String str;
      int cursor;
      int dispStart;
      synchronized(data) {
        str = data.toString();
        cursor = data.getCursorPosition();
        if (!data.isDisplayValid()) data.updateDisplay(fm);
        dispStart = data.getDisplayStart();
      }

      int asc = fm.getAscent();
      int x = bds.getX() + 8;
      if (dispStart > 0) {
        x += fm.stringWidth(str.charAt(0) + "m");
        x += fm.stringWidth(str.substring(dispStart, cursor));
      } else if (cursor >= str.length()) {
        x += fm.stringWidth(str);
      } else {
        x += fm.stringWidth(str.substring(0, cursor));
      }
      int y = bds.getY() + (bds.getHeight() + asc) / 2;
      g.drawLine(x, y - asc, x, y);
    }
View Full Code Here

TOP

Related Classes of java.awt.FontMetrics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.