/*
   *
   * public int getAxisLength(Graphics g) {
   *
   * FontMetrics fm = g.getFontMetrics(font);
   *
   * int labelWidth=fm.getHeight();
   *
   *
   *
   * int visibleLab=0;
   *
   * for(int
   * i=1;i<visibleLabels.length-1;i++)if(visibleLabels[i])visibleLab++;
   *
   *
   *
   * //int labellenght=
   * labels[0].length*(labels.length-1)*labelWidth+((int)((labels.length-1)*(labelWidth*1.5)));
   *
   * int labellenght=
   * visibleLab*(labels.length-1)*labelWidth+((int)((labels.length-1)*(labelWidth*spaceBetween)));
   *
   *
   *
   * if(visibleLab==0 && spaceBetween>0.0) labellenght=minimumSize;
   *
   *
   *
   * int x0 = (int)(labellenght/labels.length-1);
   *
   * x0=x0*(labels.length-1);
   *
   *
   *
   * // int labellength =((int)((amax.x - amin.x)/(
   * labels[0].length)))*labels[0].length ;
   *
   * //labellenght+=(endLength(g));
   *
   * System.out.print("\n Set axislength: "+ x0);
   *
   * //return labellenght;
   *
   * //return x0;
   *
   *
   *
   * return x0;
   *
   * // return 40;
   *
   * }
   *
   */
  public int endLength() {

    if (visiblelabs == 0) {
      return 2;
    }

    AffineTransform aft = new AffineTransform();

    FontRenderContext fr = new FontRenderContext(aft, true, false);

    int additionalLength = Integer.MIN_VALUE;

    // FontMetrics fm = g.getFontMetrics(font);
    // int labelWidth=fm.getHeight();
    // System.out.print("\nLabelslength: "+labels[labels[0].length-1].length);
    for (int i = 0; i < labels[0].length; i++) {

      if (visibleLabels[i + 1]
          && (int) font.getStringBounds(labels[labels.length - 1][i], fr).getWidth()
              > additionalLength) {
        additionalLength = (int) font.getStringBounds(labels[labels.length - 1][i], fr).getWidth();
      }
    }

    double sin = (int) (additionalLength * Math.cos(DEG2RAD * rotation));

    sin += font.getStringBounds("sdf", fr).getHeight();

    return (int) sin;
  }
  public void cancelButton(boolean selected, Graphics2D g2, int x, int y) {

    Font f = Window.FONT;
    f = f.deriveFont(Font.PLAIN, 20);
    g2.setFont(f);

    Color color1 = new Color(115, 88, 167), color3 = NOT_SELECTED_OUT_LINE;

    if (selected) {
      color1 = SELECTED_UP;
      color3 = SELECTED_OUT_LINE;
    }

    g2.setColor(color3);
    g2.fill(new RoundRectangle2D.Double(x, y, WIDTH3, HEIGHT3, 50, 50));
    g2.setColor(color1);
    g2.fill(new RoundRectangle2D.Double(x + 5, y + 5, WIDTH3 - 10, HEIGHT3 - 10, 50, 50));
    g2.setColor(Color.WHITE);
    String str = "CANCEL";
    g2.drawString(
        str,
        (int)
            (x
                + WIDTH3 / 2
                - f.getStringBounds(str, new FontRenderContext(null, true, true)).getWidth() / 2),
        (int)
            (y
                + HEIGHT3 / 2
                + f.getStringBounds(str, new FontRenderContext(null, true, true)).getHeight() / 2
                - 8));
  }
  public void bigPkm(boolean selected, Graphics2D g2, Pokemon p) {

    if (p == null) return;

    Font f = Window.FONT;
    f = f.deriveFont(Font.PLAIN, 20);
    g2.setFont(f);

    Color color1 = NOT_SELECTED_UP, color2 = NOT_SELECTED_DOWN, color3 = NOT_SELECTED_OUT_LINE;

    if (selected) {
      color1 = SELECTED_UP;
      color2 = SELECTED_DOWN;
      color3 = SELECTED_OUT_LINE;
    }

    g2.setColor(color3);
    g2.fill(new RoundRectangle2D.Double(X_SHIFT - 5, Y_SHIFT - 5, WIDTH1 + 10, HEIGHT1 + 10, 5, 5));

    g2.setColor(color1);
    g2.fill(new Rectangle2D.Double(X_SHIFT, Y_SHIFT, WIDTH1, HEIGHT1));
    g2.setColor(color2);
    g2.fill(new Rectangle2D.Double(X_SHIFT, Y_SHIFT + HEIGHT1 * 2 / 3, WIDTH1, HEIGHT1 / 3));

    BattleFrontEnd.drawHpBar(
        g2,
        X_SHIFT + 40,
        Y_SHIFT + HEIGHT1 * 2 / 3,
        p.getCurrentHP(),
        p.getMaxHP(),
        p.getCurrentHP() / (double) p.getMaxHP());

    String hp = p.getCurrentHP() + "/" + p.getMaxHP();

    g2.setColor(Color.BLACK);
    g2.drawString(
        hp,
        X_SHIFT + 100,
        (int)
            (Y_SHIFT
                + HEIGHT1 * 2 / 3
                + f.getStringBounds(hp, new FontRenderContext(null, true, true)).getHeight()));
    String name = p.getName() + " Lvl: " + p.getLevel();
    g2.drawString(
        name,
        (int)
            (X_SHIFT
                + WIDTH1 / 2
                - f.getStringBounds(name, new FontRenderContext(null, true, true)).getWidth() / 2),
        (int)
            (Y_SHIFT
                + 30
                + f.getStringBounds(name, new FontRenderContext(null, true, true)).getHeight()));
    g2.drawImage(
        p.getFront().getScaledInstance(40, 40, Image.SCALE_DEFAULT),
        X_SHIFT + 5,
        Y_SHIFT + 5,
        null);
  }
 private void drawEnemyMessage(Graphics2D g2d) {
   Font messageFont = new Font("Arial", Font.BOLD, 15);
   g2d.setFont(messageFont);
   if (enemyMoveChosen) {
     String text = "";
     if (drawMoveApplication) {
       text = effectMessage;
     } else {
       text =
           enemy.getName()
               + " uses "
               + lastEnemyMove.getName()
               + " on "
               + MainCharacter.characterName
               + "!";
     }
     ArrayList<String> lines = new ArrayList<>();
     int width = (int) (messageFont.getStringBounds(text, g2d.getFontRenderContext()).getWidth());
     if (width > cardButton.getWidth() * 2 + 40) {
       String[] split = text.split("\\s+");
       int tempWidth = 0;
       int maxWidth = 0;
       String line = "";
       for (int i = 0; i < split.length; i++) {
         tempWidth +=
             (int)
                 (messageFont
                     .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                     .getWidth());
         if (tempWidth > cardButton.getWidth() * 2 + 40) {
           tempWidth =
               (int)
                   (messageFont
                       .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                       .getWidth());
           lines.add(line);
           line = split[i] + " ";
         } else {
           line = line + split[i] + " ";
         }
         if (tempWidth > maxWidth) {
           maxWidth = tempWidth;
         }
       }
       lines.add(line);
     } else {
       lines.add(text);
     }
     for (int i = 0; i < lines.size(); i++) {
       g2d.drawString(lines.get(i), cardButton.getX(), cardButton.getY() + 15 + 30 * i);
     }
   } else {
     g2d.drawString("The Enemy is deciding", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString("their move...", cardButton.getX(), cardButton.getY() + 15 + 30);
   }
 }
  public void smallPkm(boolean selected, Graphics2D g2, Pokemon p, int shift) {

    if (p == null) return;

    Font f = Window.FONT;
    f = f.deriveFont(Font.PLAIN, 20);
    g2.setFont(f);

    int y = Y_SHIFT2 + shift * (HEIGHT2 + 15);

    Color color1 = NOT_SELECTED_UP, color2 = NOT_SELECTED_DOWN, color3 = NOT_SELECTED_OUT_LINE;

    if (selected) {
      color1 = SELECTED_UP;
      color2 = SELECTED_DOWN;
      color3 = SELECTED_OUT_LINE;
    }

    g2.setColor(color3);
    g2.fill(new RoundRectangle2D.Double(X_SHIFT2 - 5, y - 5, WIDTH2 + 10, HEIGHT2 + 10, 5, 5));

    g2.setColor(color1);
    g2.fill(new Rectangle2D.Double(X_SHIFT2, y, WIDTH2, HEIGHT2));
    g2.setColor(color2);
    g2.fill(new Rectangle2D.Double(X_SHIFT2, y + HEIGHT2 * 2 / 3, WIDTH2, HEIGHT2 / 3));

    BattleFrontEnd.drawHpBar(
        g2,
        X_SHIFT2 + WIDTH2 * 2 / 3,
        y + 10,
        p.getCurrentHP(),
        p.getMaxHP(),
        p.getCurrentHP() / (double) p.getMaxHP());

    String hp = p.getCurrentHP() + "/" + p.getMaxHP();

    g2.setColor(Color.BLACK);
    g2.drawString(
        hp,
        X_SHIFT2 + WIDTH2 * 2 / 3 + 50,
        (int)
            (y
                + HEIGHT2 * 1 / 3
                + f.getStringBounds(hp, new FontRenderContext(null, true, true)).getHeight()));
    String name = p.getName() + " Lvl: " + p.getLevel();
    g2.drawString(
        name,
        (int) (X_SHIFT2 + WIDTH2 / 5),
        (int)
            (y - 5 + f.getStringBounds(name, new FontRenderContext(null, true, true)).getHeight()));
    g2.drawImage(
        p.getFront().getScaledInstance(40, 40, Image.SCALE_DEFAULT), X_SHIFT2 + 5, y + 5, null);
  }
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   int w = getWidth();
   int h = getHeight();
   // Draw ordinate.
   g2.draw(new Line2D.Double(Points, Points, Points, h - Points));
   // Draw abcissa.
   g2.draw(new Line2D.Double(Points, h - Points, w - Points, h - Points));
   // Draw labels.
   Font font = g2.getFont();
   FontRenderContext frc = g2.getFontRenderContext();
   LineMetrics lm = font.getLineMetrics("0", frc);
   float sh = lm.getAscent() + lm.getDescent();
   // Ordinate label.
   String s = "Strecke";
   float sy = Points + ((h - 2 * Points) - s.length() * sh) / 2 + lm.getAscent();
   for (int i = 0; i < s.length(); i++) {
     String letter = String.valueOf(s.charAt(i));
     float sw = (float) font.getStringBounds(letter, frc).getWidth();
     float sx = (Points - sw) / 2;
     g2.drawString(letter, sx, sy);
     sy += sh;
   }
   // Abcissa label.
   s = "Datum";
   sy = h - Points + (Points - sh) / 2 + lm.getAscent();
   float sw = (float) font.getStringBounds(s, frc).getWidth();
   float sx = (w - sw) / 2;
   g2.drawString(s, sx, sy);
   // Draw lines.
   double xInc = (double) (w - 2 * Points) / (data.length - 1);
   double scale = (double) (h - 2 * Points) / getMax();
   g2.setPaint(Color.green.darker());
   for (int i = 0; i < data.length - 1; i++) {
     double x1 = Points + i * xInc;
     double y1 = h - Points - scale * data[i];
     double x2 = Points + (i + 1) * xInc;
     double y2 = h - Points - scale * data[i + 1];
     g2.draw(new Line2D.Double(x1, y1, x2, y2));
   }
   // Mark data points.
   g2.setPaint(Color.red);
   for (int i = 0; i < data.length; i++) {
     double x = Points + i * xInc;
     double y = h - Points - scale * data[i];
     g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4));
   }
 }
Exemple #7
0
	/**
	 * @param g2
	 * @throws IOException
	 */
	private void drawNode(Map<String, Node> nodes, Graphics2D g2, Font font) throws IOException {
		for (Node node : nodes.values()) {
			String name = node.getName();
			if (nodeInfos.get(node.getType()) != null) {
				BufferedImage bi2 = ImageIO.read(getClass().getResourceAsStream(
						"icons/48/" + nodeInfos.get(node.getType())));
				g2.drawImage(bi2, node.getX(), node.getY(), null);
			} else {
				int x = node.getX();
				int y = node.getY();
				int w = node.getWitdth();
				int h = node.getHeight();
				g2.setColor(DEFAULT_FILL_COLOR);
				g2.fillRoundRect(x, y, w, h, RECT_ROUND, RECT_ROUND);
				g2.setColor(DEFAULT_STROKE_COLOR);
				g2.setStroke(DEFAULT_STROKE);
				g2.drawRoundRect(x, y, w, h, RECT_ROUND, RECT_ROUND);

				FontRenderContext frc = g2.getFontRenderContext();
				Rectangle2D r2 = font.getStringBounds(name, frc);
				int xLabel = (int) (node.getX() + ((node.getWitdth() - r2.getWidth()) / 2));
				int yLabel = (int) ((node.getY() + ((node.getHeight() - r2.getHeight()) / 2)) - r2.getY());
				g2.setStroke(DEFAULT_LINE_STROKE);
				g2.setColor(Color.black);
				g2.drawString(name, xLabel, yLabel);
			}
		}
	}
Exemple #8
0
  private static final void drawShadowedStringCentered(
      final Graphics2D g2d,
      final String str,
      final double x,
      final double y,
      final Font font,
      final Paint paint,
      final double shadowOffset,
      final Paint shadowPaint) {

    g2d.setFont(font);

    final FontRenderContext frc = g2d.getFontRenderContext();
    final Rectangle2D bounds = font.getStringBounds(str, frc);
    final LineMetrics metrics = font.getLineMetrics(str, frc);
    final double width = bounds.getWidth(); // The width of our text
    final float lineHeight = metrics.getHeight(); // Total line height
    final float ascent = metrics.getAscent(); // Top of text to baseline

    final double cx = (x + (0 - width) / 2);
    final double cy = (y + (0 - lineHeight) / 2 + ascent);

    if (shadowOffset > 0) {
      drawString(g2d, str, cx + shadowOffset, cy - shadowOffset, shadowPaint);
      drawString(g2d, str, cx + shadowOffset, cy + shadowOffset, shadowPaint);
      drawString(g2d, str, cx - shadowOffset, cy - shadowOffset, shadowPaint);
      drawString(g2d, str, cx - shadowOffset, cy + shadowOffset, shadowPaint);
    }
    drawString(g2d, str, cx, cy, paint);
  }
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String message = "Hello, World!";

    Font f = new Font("Serif", Font.BOLD, 36);
    g2.setFont(f);

    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D bounds = f.getStringBounds(message, context);

    double x = (getWidth() - bounds.getWidth()) / 2;
    double y = (getHeight() - bounds.getHeight()) / 2;

    double ascent = -bounds.getY();
    double baseY = y + ascent;

    g2.drawString(message, (int) x, (int) baseY);

    g2.setPaint(Color.LIGHT_GRAY);

    g2.draw(new Line2D.Double(x, baseY, x + bounds.getWidth(), baseY));
    Rectangle2D rect = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight());
    g2.draw(rect);
  }
    /**
     * @see org.jfree.chart.axis.Axis#refreshTicks(java.awt.Graphics2D, java.awt.geom.Rectangle2D,
     *     java.awt.geom.Rectangle2D, int)
     */
    public void refreshTicks(
        Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, int location) {

      // getTicks().clear();

      Font tickLabelFont = getTickLabelFont();
      g2.setFont(tickLabelFont);

      double size = getTickUnit().getSize();
      int count = calculateVisibleTickCount();
      double lowestTickValue = calculateLowestVisibleTickValue();

      if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
        for (int i = 0; i < count; i++) {
          double currentTickValue = lowestTickValue + (i * size);
          double yy = translateValueToJava2D(currentTickValue, dataArea, RectangleEdge.BOTTOM);
          String tickLabel;
          NumberFormat formatter = getNumberFormatOverride();
          if (formatter != null) {
            tickLabel = formatter.format(currentTickValue);
          } else {
            tickLabel = valueToString(currentTickValue);
          }
          FontRenderContext frc = g2.getFontRenderContext();
          Rectangle2D tickLabelBounds = tickLabelFont.getStringBounds(longestStr, frc);
          LineMetrics lm = tickLabelFont.getLineMetrics(tickLabel, frc);
          float x =
              (float) (dataArea.getX() - tickLabelBounds.getWidth() - getTickLabelInsets().right);
          float y = (float) (yy + (lm.getAscent() / 2));
          // Tick tick = new Tick(new Double(currentTickValue), tickLabel, x, y);
          // getTicks().add(tick);
        }
      }
    }
Exemple #11
0
  // -----------draws texts on screen-----------
  private void drawText(
      Graphics g, String text, int absoluteX, int absoluteY, Color textColor, int textsize) {

    Graphics2D g2 = (Graphics2D) g;
    Dimension size = getSize();

    FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();

    // set font
    Font font = new Font("Arial", Font.BOLD, textsize);
    g.setFont(font);

    // gets width and height of text
    Rectangle2D bounds = font.getStringBounds(text, frc);
    int wText = (int) bounds.getWidth();
    int hText = (int) bounds.getHeight();

    // changes absolute to relative values
    int x = (int) (((double) (size.width) / 100.0) * absoluteX); // takes
    int y = (int) (((double) (size.height) / 100.0) * absoluteY);

    g.setColor(getBackground());
    g2.fillRect(x, y, wText, hText);

    // draws string
    g.setColor(textColor);
    int xText = x - (int) bounds.getX();
    int yText = y - (int) bounds.getY();
    g.drawString(text, xText, yText);
  }
Exemple #12
0
  /*
   * (non-Javadoc)
   *
   * @see org.math.plot.render.AbstractDrawer#drawStringRatio(java.lang.String,
   *      double[], double, double, double)
   */
  public void drawTextBase(String label, double... rC) {
    int[] sC = projection.screenProjectionBase(rC);

    // Corner offset adjustment : Text Offset is used Here
    FontRenderContext frc = comp2D.getFontRenderContext();
    Font font1 = comp2D.getFont();
    int x = sC[0];
    int y = sC[1];
    double w = font1.getStringBounds(label, frc).getWidth();
    double h = font1.getSize2D();
    x -= (int) (w * text_Eastoffset);
    y += (int) (h * text_Northoffset);

    int wc = (int) (w * FastMath.cos(text_angle) + h * FastMath.sin(text_angle));
    int hc = (int) (h * FastMath.cos(text_angle) + w * FastMath.sin(text_angle));
    if (!comp2D.hitClip(x, y, wc, hc)) {
      return;
    }

    if (text_angle != 0) {
      comp2D.rotate(text_angle, x + w / 2, y - h / 2);
    }

    String[] lines = label.split("\n");
    for (int i = 0; i < lines.length; i++) {
      comp2D.drawString(lines[i], x, y);
      y += h;
    }
    // comp2D.drawString(label, x, y);

    if (text_angle != 0) {
      comp2D.rotate(-text_angle, x + w / 2, y - h / 2);
    }
  }
  /**
   * Draw a string with given reference point and rotation angle. (0.5, 0.5) is center, (0, 0) is
   * lower left, (1, 0) is upper left, etc. The angle of rotation is in radians. The logical are
   * proportional to the base coordinates.
   */
  public void drawTextBaseRatio(
      String label,
      double horizontalReference,
      double verticalReference,
      double rotation,
      double[] coord) {
    int[] sc = projection.screenProjectionBaseRatio(coord);
    int x = sc[0];
    int y = sc[1];

    AffineTransform transform = g2d.getTransform();

    // Corner offset adjustment : Text Offset is used Here
    FontRenderContext frc = g2d.getFontRenderContext();
    Font font = g2d.getFont();
    double w = font.getStringBounds(label, frc).getWidth();
    double h = font.getSize2D();

    if (rotation != 0) {
      g2d.rotate(rotation, x, y);
    }

    x -= (int) (w * horizontalReference);
    y += (int) (h * verticalReference);

    g2d.drawString(label, x, y);

    g2d.setTransform(transform);
  }
Exemple #14
0
  private void resizeLabels() {
    // adjust size of labels so they right-align
    int w = 0;
    Font font = nameLabel.getFont();
    FontRenderContext frc = new FontRenderContext(null, false, false);
    Rectangle2D rect = font.getStringBounds(nameLabel.getText() + " ", frc); // $NON-NLS-1$
    w = Math.max(w, (int) rect.getWidth() + 4);
    rect = font.getStringBounds(pathLabel.getText() + " ", frc); // $NON-NLS-1$
    w = Math.max(w, (int) rect.getWidth() + 4);

    Dimension labelSize = new Dimension(w, 20);
    nameLabel.setPreferredSize(labelSize);
    nameLabel.setMinimumSize(labelSize);
    pathLabel.setPreferredSize(labelSize);
    pathLabel.setMinimumSize(labelSize);
  }
Exemple #15
0
  protected void refreshCacheTab() {
    // refresh list of cache hosts
    cacheBox.removeAll();
    ArrayList<JLabel> labels = new ArrayList<JLabel>();
    File cache = ResourceLoader.getOSPCache();
    File[] hosts = cache == null ? new File[0] : cache.listFiles(ResourceLoader.OSP_CACHE_FILTER);
    clearCacheButton.setEnabled(hosts.length > 0);

    if (hosts.length == 0) {
      JLabel label = new JLabel(ToolsRes.getString("LibraryManager.Cache.IsEmpty")); // $NON-NLS-1$
      label.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
      Box box = Box.createHorizontalBox();
      box.add(label);
      box.add(Box.createHorizontalGlue());
      cacheBox.add(box);
      return;
    }

    for (File hostFile : hosts) {
      // eliminate the "osp-" that starts all cache host filenames
      String hostText = hostFile.getName().substring(4).replace('_', '.');
      long bytes = getFileSize(hostFile);
      long size = bytes / (1024 * 1024);
      if (bytes > 0) {
        if (size > 0) hostText += " (" + size + " MB)"; // $NON-NLS-1$ //$NON-NLS-2$
        else hostText += " (" + bytes / 1024 + " kB)"; // $NON-NLS-1$ //$NON-NLS-2$
      }
      JLabel label = new JLabel(hostText);
      label.setToolTipText(hostFile.getAbsolutePath());
      labels.add(label);

      ClearHostButton button = new ClearHostButton(hostFile);

      Box bar = Box.createHorizontalBox();
      bar.add(label);
      bar.add(button);
      bar.add(Box.createHorizontalGlue());

      cacheBox.add(bar);
      FontSizer.setFonts(cacheBox, FontSizer.getLevel());
    }

    // set label sizes
    FontRenderContext frc = new FontRenderContext(null, false, false);
    Font font = labels.get(0).getFont();
    int w = 0;
    for (JLabel next : labels) {
      Rectangle2D rect = font.getStringBounds(next.getText(), frc);
      w = Math.max(w, (int) rect.getWidth());
    }
    Dimension labelSize = new Dimension(w + 48, 20);
    for (JLabel next : labels) {
      next.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
      next.setPreferredSize(labelSize);
    }
  }
Exemple #16
0
 /**
  * Gets the page count of this section.
  *
  * @param g2 the graphics context
  * @param pf the page format
  * @return the number of pages needed
  */
 public int getPageCount(Graphics2D g2, PageFormat pf) {
   if (message.equals("")) return 0;
   FontRenderContext context = g2.getFontRenderContext();
   Font f = new Font("Serif", Font.PLAIN, 72);
   Rectangle2D bounds = f.getStringBounds(message, context);
   scale = pf.getImageableHeight() / bounds.getHeight();
   double width = scale * bounds.getWidth();
   int pages = (int) Math.ceil(width / pf.getImageableWidth());
   return pages;
 }
Exemple #17
0
 public static CGSize sizeWithFont(String text, UIFont font) {
   Graphics2D graphicsContext = CGContext.UICurrentContext().xmlvmGetGraphics2D();
   Font savedFont = graphicsContext.getFont();
   Font awtFont = font.xmlvmGetFont();
   graphicsContext.setFont(awtFont);
   Rectangle2D size = awtFont.getStringBounds(text, graphicsContext.getFontRenderContext());
   graphicsContext.setFont(savedFont);
   return new CGSize(
       (float) size.getWidth(),
       text != null && text.length() > 0 ? (float) size.getHeight() : 0.0f);
 }
Exemple #18
0
  public void drawEndArrowText(
      ChartMargins chart,
      StylingBox style,
      PresetChartOptions options,
      double x,
      double y,
      String[] ids,
      AncesBoxParent box,
      OpgSession session,
      Font font) {
    ArrayList<String> lines = new ArrayList<String>();
    double xOffset =
        ((style.isIntruding && options.isAllowIntrusion())
            ? style.intrudeWidth
            : style.getBoxWidth());

    if (options.getArrowStyle() == PresetChartOptions.EndLineArrowStyle.GENERATIONS) {
      if ((box.getIndi().father != null) && (box.getIndi().mother == null))
        lines.add("G: " + box.father.maxGensInTree);
      else if ((box.mother != null) && (box.father == null))
        lines.add("G: " + box.mother.maxGensInTree);
      else lines.add("G: " + Math.max(box.mother.maxGensInTree, box.father.maxGensInTree));

      lines.add("I: " + box.getIndi().numberOfAncestors);
    } else if (options.getArrowStyle() == PresetChartOptions.EndLineArrowStyle.PARENTS) {
      if (box.getIndi().father != null && box.getIndi().mother != null) {
        lines.add("F: " + ids[0]);
        lines.add("M: " + ids[1]);
      } else if (box.getIndi().father != null) lines.add("F: " + ids[0]);
      else if (box.getIndi().mother != null) lines.add("M: " + ids[0]);

    } else if (options.getArrowStyle() == PresetChartOptions.EndLineArrowStyle.SELF) {
      lines.add("Pg: " + ids[0]);
    }

    double fontHeight = 0.0;
    for (int i = 0; i < lines.size(); i++) {
      double size;
      if ((size = font.getStringBounds(lines.get(i), NameAbbreviator.frc).getHeight()) > fontHeight)
        fontHeight = size;
    }

    double yPos = y - fontHeight / 4.0 + ((fontHeight / 2.0) * (lines.size() - 1));
    for (int i = 0; i < lines.size(); i++) {
      chart.addDrawCommand(new DrawCmdMoveTo(chart.xOffset(x + xOffset), chart.xOffset(yPos)));
      chart.addDrawCommand(new DrawCmdText(lines.get(i)));

      yPos -= fontHeight;
    }
  }
    @Override
    public void paintComponent(Graphics g) {

      super.paintComponent(g);
      if (coverScreenData != null) {
        Graphics2D g2d = (Graphics2D) g;
        if (coverScreenData.getImageURL() != null && (!coverScreenData.getImageURL().equals(""))) {

          try {
            g2d.drawImage(
                img,
                (getWidth() / 2) - (img.getWidth(null) / 2),
                (getHeight() / 2) - (img.getHeight(null) / 2),
                this);
          } catch (Exception ex) {
            Logger.getLogger(CoverScreen.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        Image img =
            new ImageIcon(
                    getClass()
                        .getResource(
                            "/org/jdesktop/wonderland/modules/placemarks/client/resources/loading.gif"))
                .getImage();

        g2d.drawImage(
            img,
            (getWidth() / 2) - (img.getWidth(null) / 2),
            (getHeight() / 2) - (img.getHeight(null) / 2),
            this);
        float[] comps = coverScreenData.getTextColor().getColorArray();
        g2d.setColor(new Color(comps[0], comps[1], comps[2]));
        Font font = new Font("Arial", Font.BOLD, 20);
        FontRenderContext frc1 = new FontRenderContext(null, true, true);
        Rectangle2D rec = font.getStringBounds(coverScreenData.getMessage(), frc1);
        int w = (int) (rec.getWidth());
        int h = (int) (rec.getHeight());
        g2d.setFont(font);
        g2d.drawString(
            coverScreenData.getMessage(), (getWidth() / 2) - (w / 2), getHeight() - (h) + 10);
      }
      Insets insets = getInsets();
      Dimension size = closeIcon.getPreferredSize();
      closeIcon.setBounds(
          (int) (getWidth() - size.width) + insets.left, insets.top, size.width, size.height);
    }
Exemple #20
0
  public void paintComponent(Graphics g) {
    // необходиом чтобы текст коректно отрисовывался в окне
    super.paintComponent(g);
    // рисуем текст в окне
    Graphics2D g2 = (Graphics2D) g;
    AffineTransform t = g2.getTransform();
    g.drawString("It is text", 5, 5);
    // создание шрифта
    Font f = new Font("SanasSerif", Font.ITALIC, 20);
    g2.setFont(f);
    g2.drawString("It is new text", 5, 33);
    String[] fontNames =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    for (int i = 5; i < 20; i++) {
      g2.rotate(-0.05);
      g2.setColor(
          new Color(
              (int) (Math.random() * 255),
              (int) (Math.random() * 255),
              (int) (Math.random() * 255)));
      Font f1 = new Font(fontNames[i], Font.BOLD, 20);
      g2.setFont(f1);
      g2.drawString(fontNames[i], 5, 20 * i);
    }
    // текст в центре

    g2.setTransform(t); // возращение к кординатам, которые запонилив начале
    Font f2 = new Font("SanasSerif", Font.ITALIC, 20);
    g2.setFont(f2);
    String s = "It is center!";
    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D r = f2.getStringBounds(s, context);
    double x1 = (getWidth() - r.getWidth()) / 2;
    double y1 = (getHeight() - r.getHeight()) / 2;
    double ascent = -r.getY(); // узнаем высоту текста
    double y2 = y1 + ascent;
    Rectangle2D rect = new Rectangle2D.Double(x1, y1, r.getWidth(), r.getHeight());
    g2.setColor(Color.YELLOW);
    g2.fill(rect);
    g2.setColor(Color.red);
    g2.drawString(s, (int) x1, (int) y2);
    g2.setColor(Color.blue);
    g2.draw(new Line2D.Double(x1, y2, x1 + r.getWidth(), y2));

    g2.draw(rect);
  }
Exemple #21
0
  public void drawShadowedText(String label, float alpha, double... pC) {
    int[] sC = projection.screenProjection(pC);

    // Corner offset adjustment : Text Offset is used Here
    FontRenderContext frc = comp2D.getFontRenderContext();
    Font font1 = comp2D.getFont();
    int x = sC[0];
    int y = sC[1];
    double w = font1.getStringBounds(label, frc).getWidth();
    double h = font1.getSize2D();
    x -= (int) (w * text_Eastoffset);
    y += (int) (h * text_Northoffset);

    int wc = (int) (w * FastMath.cos(text_angle) + h * FastMath.sin(text_angle));
    int hc = (int) (h * FastMath.cos(text_angle) + w * FastMath.sin(text_angle));
    if (!comp2D.hitClip(x, y, wc, hc)) {
      return;
    }

    if (text_angle != 0) {
      comp2D.rotate(text_angle, x + w / 2, y - h / 2);
    }

    Composite cs = comp2D.getComposite();
    Color c = comp2D.getColor();

    String[] lines = label.split("\n");
    for (int i = 0; i < lines.length; i++) {

      comp2D.setColor(Color.white);
      comp2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      comp2D.fillRect(x, y - (int) h, (int) w, (int) h);
      comp2D.setComposite(cs);
      comp2D.setColor(c);

      comp2D.drawString(lines[i], x, y);
      y += h;
    }

    if (text_angle != 0) {
      comp2D.rotate(-text_angle, x + w / 2, y - h / 2);
    }
  }
Exemple #22
0
  protected void refreshSearchTab() {
    // refresh list of cached search targets
    searchBox.removeAll();
    checkboxes.clear();
    ArrayList<JLabel> labels = new ArrayList<JLabel>();
    for (LibraryResource next : browser.getSearchCacheTargets()) {
      String path = next.collectionPath;
      if (path == null) continue;

      String name = next.toString();
      JLabel label = new JLabel(name);
      label.setToolTipText(path);
      labels.add(label);

      SearchCheckBox checkbox = new SearchCheckBox(path);
      checkboxes.add(checkbox);
      JButton button = new DeleteButton(path);

      Box bar = Box.createHorizontalBox();
      bar.add(label);
      bar.add(checkbox);
      bar.add(button);
      bar.add(Box.createHorizontalGlue());

      searchBox.add(bar);
      FontSizer.setFonts(searchBox, FontSizer.getLevel());
    }
    if (labels.isEmpty()) return;

    // set label sizes
    FontRenderContext frc = new FontRenderContext(null, false, false);
    Font font = labels.get(0).getFont();
    int w = 0;
    for (JLabel next : labels) {
      Rectangle2D rect = font.getStringBounds(next.getText(), frc);
      w = Math.max(w, (int) rect.getWidth());
    }
    Dimension labelSize = new Dimension(w + 48, 20);
    for (JLabel next : labels) {
      next.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
      next.setPreferredSize(labelSize);
    }
  }
  public int predictLength() {

    AffineTransform aft = new AffineTransform();

    FontRenderContext fr = new FontRenderContext(aft, true, false);

    int labelWidth = (int) font.getStringBounds("tTSM", fr).getHeight();

    int visibleLab = 0;

    for (int i = 1; i < visibleLabels.length - 1; i++) {
      if (visibleLabels[i]) {
        visibleLab++;
      }
    }

    int labellenght =
        visibleLab * (labels.length - 1) * labelWidth
            + ((int) ((labels.length - 1) * (labelWidth * spaceBetween)));

    labellenght = Math.max(labellenght, minimumSize);

    // int additionalLength=Integer.MIN_VALUE;
    int x0 = (int) (labellenght / labels.length - 1);

    labellenght = x0 * (labels.length - 1);

    // System.out.print("\n"+(labellenght));

    /*
     *
     * double sin = 0;
     *
     * if(additionalLength>0)
     * sin=(int)(additionalLength*Math.cos(DEG2RAD*rotation))+(labelWidth);
     *
     * labellenght+=sin;
     *
     */
    // System.out.print("\n"+(labels.length*2));
    // System.out.print("\n"+(labellenght));
    return Math.max(labels.length * 2, labellenght);
  }
 public void paintIcon(Component c, Graphics graphics, int x, int y) {
   Font font = UIManager.getFont("TextField.font");
   Graphics2D g = (Graphics2D) graphics.create(x, y, getIconWidth(), getIconHeight());
   g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   g.setFont(font.deriveFont(Font.BOLD, getIconWidth() * 3 / 4));
   g.setColor(Color.green.darker());
   final int SW = Math.max(getIconWidth() / 10, 4);
   g.setStroke(new BasicStroke(SW));
   g.drawArc(SW / 2, SW / 2, getIconWidth() - SW - 1, getIconHeight() - SW - 1, 0, 360);
   Rectangle2D bounds = font.getStringBounds("i", g.getFontRenderContext());
   g.drawString(
       "i",
       Math.round((getIconWidth() - bounds.getWidth()) / 2 - getIconWidth() / 12),
       SW / 2
           + Math.round(
               (getIconHeight() - bounds.getHeight()) / 2
                   - bounds.getY()
                   + getIconHeight() / 8));
   g.dispose();
 }
Exemple #25
0
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String message = "Hello, World!";

    Font f = new Font("Serif", Font.BOLD, 36);
    g2.setFont(f);

    // measure the size of the message

    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D bounds = f.getStringBounds(message, context);

    // set (x,y) = top left corner of text

    double x = (getWidth() - bounds.getWidth()) / 2;
    double y = (getHeight() - bounds.getHeight()) / 2;

    // add ascent to y to reach the baseline

    double ascent = -bounds.getY();
    double baseY = y + ascent;

    // draw the message

    g2.drawString(message, (int) x, (int) baseY);

    g2.setPaint(Color.LIGHT_GRAY);

    // draw the baseline

    g2.draw(new Line2D.Double(x, baseY, x + bounds.getWidth(), baseY));

    // draw the enclosing rectangle

    Rectangle2D rect = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight());
    g2.draw(rect);
  }
Exemple #26
0
 public static int getStringHeight(Font f, String s) {
   AffineTransform affinetransform = new AffineTransform();
   FontRenderContext frc = new FontRenderContext(affinetransform, true, true);
   return (int) (f.getStringBounds(s, frc).getHeight());
 }
  @Override
  public Image createNewImage(int parentWidth, int parentHeight) {
    Image image = createEmptyImage(parentWidth, parentHeight);
    try {
      File temp = ResourceHelper.getResource("APPDATA_DIRECTORY");
      int width = image.getWidth(null);
      int height = image.getHeight(null);
      Graphics2D g2d = (Graphics2D) image.getGraphics();
      float opacity = (float) getOpacity() / 100;
      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));

      // Create image
      if (geocodeResult == null) {
        retrieveLocation();
      }
      DailyWeatherForecast dwf = new DailyWeatherForecast();
      DailyForecastResponse resp = dwf.forecast(latitude, longitude, 6);
      DayForecast currDay = resp.getForecasts().get(0);
      DayWeather currWeather = currDay.getWeather().get(0);

      // Create image
      {
        int py = 0, ny = 10, gap = 2, pad = 10, nw = 10;
        int w = 300;
        int h =
            pad
                + (locationIncluded ? 27 : 0)
                + ((iconIncluded || descriptionIncluded) ? 32 : 0)
                + ((temperatureIncluded || windSpeedIncluded || humidityIncluded) ? 34 : 0)
                + (forecastIncluded ? 40 : 0)
                + pad;
        Image tempImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = (Graphics2D) tempImage.getGraphics();
        Rectangle2D rect;
        FontRenderContext frc = g.getFontRenderContext();
        Font addressFont = new Font("Ebrima", Font.PLAIN, 18);
        Font normFont = new Font("Ebrima", Font.PLAIN, 18);
        Font smallFont = new Font("Ebrima", Font.PLAIN, 10);
        g.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        Color txtClr = Color.BLACK;
        Color addrBarClr = Color.GRAY;
        Color col1 = Color.BLACK;
        Color col2 = Color.GRAY;
        Color col3 = Color.WHITE;

        if (isRectangular) {
          g.setPaint(
              new GradientPaint(new Point(0, 0), col2, new Point(0, height), backgroundColor));
          g.fillRoundRect(0, 0, w, h, 20, 20);
        }

        if (locationIncluded) {
          g.setFont(addressFont);
          rect = addressFont.getStringBounds(location, frc);
          g.setPaint(
              new GradientPaint(
                  new Point(pad, ny), col2, new Point(pad, (int) (ny + rect.getHeight())), col3));
          g.fillRoundRect(pad, ny, w - pad * 2, (int) rect.getHeight(), 10, 10);
          g.setColor(txtClr);
          g.drawString(location, (int) ((w - rect.getWidth()) / 2), (int) (ny - rect.getY()));
          py = ny;
          ny += rect.getHeight() + gap;
        }

        if (iconIncluded || descriptionIncluded) {

          g.setPaint(new GradientPaint(new Point(pad, ny), col2, new Point(pad, ny + 30), col3));
          g.fillRoundRect(pad, ny, w - pad * 2, 30, 10, 10);

          if (iconIncluded) {
            String iconStr = currWeather.getIcon();
            File iconFile = new File(temp, iconStr + "_info.png");
            Image icon = ResourceHelper.getImageObject(iconFile);
            if (icon == null) {
              icon =
                  ResourceHelper.getImageObject(
                      new URL("http://openweathermap.org/img/w/" + iconStr + ".png"));
              ImageIO.write((RenderedImage) icon, "png", iconFile);
            }
            g.drawImage(icon, pad, ny - 9, null);
          }

          if (isDescriptionIncluded()) {
            g.setFont(normFont);
            g.setColor(txtClr);
            rect = normFont.getStringBounds(currWeather.getDescription(), frc);
            g.drawString(
                currWeather.getDescription(),
                (int) (pad + 20 + (w - pad - 20 - rect.getWidth()) / 2),
                (int) (ny - rect.getY()));
          }

          py = ny;
          ny += 30 + gap;
        }

        if (temperatureIncluded || windSpeedIncluded || humidityIncluded) {
          g.setPaint(new GradientPaint(new Point(pad, ny), col2, new Point(pad, ny + 32), col3));
          g.fillRoundRect(pad, ny, w - pad * 2, 32, 10, 10);
          g.setColor(txtClr);

          int x = pad + gap + 5;
          if (temperatureIncluded) {
            DayTemperature dTemp = currDay.getTemp();
            String min = String.format("%.1f%cC", dTemp.getMinTemp(), DayWeather.DEGREE);
            rect = normFont.getStringBounds(min, frc);
            g.setFont(normFont);
            g.drawString(min, x, (int) (ny - rect.getY()));
            g.setFont(smallFont);
            g.drawString("min", x + 5, (int) (ny + 5 + rect.getHeight()));
            x += gap + 60;
            String max = String.format("%.1f%cC", dTemp.getMaxTemp(), DayWeather.DEGREE);
            rect = normFont.getStringBounds(max, frc);
            g.setFont(normFont);
            g.drawString(max, x, (int) (ny - rect.getY()));
            g.setFont(smallFont);
            g.drawString("max", x + 5, (int) (ny + 5 + rect.getHeight()));
            x += gap + 60;
          }

          if (windSpeedIncluded) {
            String speed = String.format("%2.1fm/s", currDay.getWindSpeed());
            rect = normFont.getStringBounds(speed, frc);
            g.setFont(normFont);
            g.drawString(speed, x + 5, (int) (ny - rect.getY()));
            g.setFont(smallFont);
            g.drawString("wind", x + 15, (int) (ny + 5 + rect.getHeight()));
            x += gap + 80;
          }

          if (humidityIncluded) {
            String humidity = String.format("%2d%%", currDay.getHumidity());
            rect = normFont.getStringBounds(humidity, frc);
            g.setFont(normFont);
            g.drawString(humidity, x + 5, (int) (ny - rect.getY()));
            g.setFont(smallFont);
            g.drawString("humidity", x + 5, (int) (ny + 5 + rect.getHeight()));
          }
          py = ny;
          ny += 32 + gap;
        }

        if (forecastIncluded) {
          g.setPaint(new GradientPaint(new Point(pad, ny), col2, new Point(pad, ny + 40), col3));
          g.fillRoundRect(pad, ny, w - pad * 2, 40, 10, 10);
          g.setColor(txtClr);
          g.setFont(smallFont);
          List<DayForecast> forecasts = resp.getForecasts();
          int x = pad;
          for (int i = 1; i < 5; i++) {
            DayWeather weather = forecasts.get(i).getWeather().get(0);
            String iconStr = weather.getIcon();
            File iconFile = new File(temp, iconStr + "_info.png");
            Image icon = ResourceHelper.getImageObject(iconFile);
            if (icon == null) {
              icon =
                  ResourceHelper.getImageObject(
                      new URL("http://openweathermap.org/img/w/" + iconStr + ".png"));
              ImageIO.write((RenderedImage) icon, "png", iconFile);
            }
            g.drawImage(icon, x, ny - 9, null);
            g.drawString(weather.getMain(), x + 10, ny + 35);
            x += 70;
          }
        }

        g.dispose();

        float s1 = (float) width / w;
        float s2 = (float) height / h;
        float s = s1 < s2 ? s1 : s2;
        int newWidth = (int) (s * w);
        tempImage = tempImage.getScaledInstance(newWidth, -1, Image.SCALE_SMOOTH);
        w = tempImage.getWidth(null);
        h = tempImage.getHeight(null);
        int locx, locy;
        locx = (width - w) / 2;
        locy = (height - h) / 2;
        g2d.drawImage(tempImage, locx, locy, null);
      }

      g2d.dispose();
    } catch (Exception ex) {
      ResourceHelper.errLog("EmbedTypeWeatherInfo > createNewImage(...) > Error : " + ex);
    }
    embedTypeImage = image;
    return image;
  }
Exemple #28
0
 public static float getWidth(String text, Font font, FontRenderContext frc) {
   return (float) font.getStringBounds(text, frc).getWidth();
 }
Exemple #29
0
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int w = getWidth();
    int h = getHeight();
    double xScale = (w - 2 * PAD) / (xMax - xMin);
    double yScale = (h - 2 * PAD) / (yMax - yMin);
    if (firstTime) System.out.printf("xScale = %.1f  yScale = %.1f%n", xScale, yScale);
    Point2D.Double origin = new Point2D.Double(); // Axes origin.
    Point2D.Double offset = new Point2D.Double(); // Locate data.
    if (xMax < 0) {
      origin.x = w - PAD;
      offset.x = origin.x - xScale * xMax;
    } else if (xMin < 0) {
      origin.x = PAD - xScale * xMin;
      offset.x = origin.x;
    } else {
      origin.x = PAD;
      offset.x = PAD - xScale * xMin;
    }
    if (yMax < 0) {
      origin.y = h - PAD;
      offset.y = origin.y - yScale * yMax;
    } else if (yMin < 0) {
      origin.y = PAD - yScale * yMin;
      offset.y = origin.y;
    } else {
      origin.y = PAD;
      offset.y = PAD - yScale * yMin;
    }
    if (firstTime) {
      System.out.printf("origin = [%6.1f, %6.1f]%n", origin.x, origin.y);
      System.out.printf("offset = [%6.1f, %6.1f]%n", offset.x, offset.y);
    }

    // Draw abcissa.
    g2.draw(new Line2D.Double(PAD, origin.y, w - PAD, origin.y));
    // Draw ordinate.
    g2.draw(new Line2D.Double(origin.x, PAD, origin.x, h - PAD));
    g2.setPaint(Color.red);
    // Mark origin.
    g2.fill(new Ellipse2D.Double(origin.x - 2, origin.y - 2, 4, 4));

    // Plot data.
    g2.setPaint(Color.blue);
    for (int i = 0; i < x.length; i++) {
      double x1 = offset.x + xScale * x[i];
      double y1 = offset.y + yScale * y[i];
      if (firstTime) System.out.printf("i = %d  x1 = %6.1f  y1 = %.1f%n", i, x1, y1);
      g2.fill(new Ellipse2D.Double(x1 - 2, y1 - 2, 4, 4));
      g2.drawString(String.valueOf(i), (float) x1 + 3, (float) y1 - 3);
    }

    // Draw extreme data values.
    g2.setPaint(Color.black);
    Font font = g2.getFont();
    FontRenderContext frc = g2.getFontRenderContext();
    LineMetrics lm = font.getLineMetrics("0", frc);
    String s = String.format("%.1f", xMin);
    float width = (float) font.getStringBounds(s, frc).getWidth();
    double x = offset.x + xScale * xMin;
    g2.drawString(s, (float) x, (float) origin.y + lm.getAscent());
    s = String.format("%.1f", xMax);
    width = (float) font.getStringBounds(s, frc).getWidth();
    x = offset.x + xScale * xMax;
    g2.drawString(s, (float) x - width, (float) origin.y + lm.getAscent());
    s = String.format("%.1f", yMin);
    width = (float) font.getStringBounds(s, frc).getWidth();
    double y = offset.y + yScale * yMin;
    g2.drawString(s, (float) origin.x + 1, (float) y + lm.getAscent());
    s = String.format("%.1f", yMax);
    width = (float) font.getStringBounds(s, frc).getWidth();
    y = offset.y + yScale * yMax;
    g2.drawString(s, (float) origin.x + 1, (float) y);
    if (firstTime) System.out.println("------------------------------");
    firstTime = false;
  }
Exemple #30
0
 protected int textWidth(String text, Graphics2D g2d) {
   return (int) font.getStringBounds(text, g2d.getFontRenderContext()).getWidth();
 }