Package java.awt.font

Examples of java.awt.font.FontRenderContext


  /**
   * Updates the labels path by drawing the labels of the X/Y-axis.
   */
  protected void updatePathLabels(final double gapx, final double gapy) {
    final FontRenderContext frc = new FontRenderContext(null, true, true);
    final PlottingStyle labelsDisplay = shape.getLabelsDisplayed();
    final PlottingStyle ticksDisplay = shape.getTicksDisplayed();
    final TicksStyle ticksStyle = shape.getTicksStyle();

    if(labelsDisplay.isX())
View Full Code Here


    private static float[] deriveTextBoundsAnchorOffsets(final Graphics2D g2,
            final String text, final TextAnchor anchor,
            final Rectangle2D textBounds) {

        final float[] result = new float[3];
        final FontRenderContext frc = g2.getFontRenderContext();
        final Font f = g2.getFont();
        final FontMetrics fm = g2.getFontMetrics(f);
        final Rectangle2D bounds = TextUtilities.getTextBounds(text, g2, fm);
        final LineMetrics metrics = f.getLineMetrics(text, frc);
        final float ascent = metrics.getAscent();
View Full Code Here

     */
    private static float[] deriveTextBoundsAnchorOffsets(final Graphics2D g2,
            final String text, final TextAnchor anchor) {

        final float[] result = new float[2];
        final FontRenderContext frc = g2.getFontRenderContext();
        final Font f = g2.getFont();
        final FontMetrics fm = g2.getFontMetrics(f);
        final Rectangle2D bounds = TextUtilities.getTextBounds(text, g2, fm);
        final LineMetrics metrics = f.getLineMetrics(text, frc);
        final float ascent = metrics.getAscent();
View Full Code Here

     */
    private static float[] deriveRotationAnchorOffsets(final Graphics2D g2,
            final String text, final TextAnchor anchor) {

        final float[] result = new float[2];
        final FontRenderContext frc = g2.getFontRenderContext();
        final LineMetrics metrics = g2.getFont().getLineMetrics(text, frc);
        final FontMetrics fm = g2.getFontMetrics();
        final Rectangle2D bounds = TextUtilities.getTextBounds(text, g2, fm);
        final float ascent = metrics.getAscent();
        final float halfAscent = ascent / 2.0f;
View Full Code Here

      int requiredHeight = req.getParam("height").compareTo("") != 0 ? Integer.parseInt(req.getParam("height").endsWith("px")?req.getParam("height").substring(0, req.getParam("height").length()-2):req.getParam("height")) : DEFAULT_HEIGHT;
      // This is the image we are making
      BufferedImage buffer = new BufferedImage(requiredWidth, requiredHeight, BufferedImage.TYPE_INT_RGB);
      Graphics2D g2 = buffer.createGraphics();
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      FontRenderContext fc = g2.getFontRenderContext();
      // We then specify the maximum font size that fits in the image
      // For this, we start at 1, and increase it, until it overflows. This-1 will be the font size
      float size = 1;
      g2.setFont(g2.getFont().deriveFont(size));
      int width = 0;
View Full Code Here

    private WrappedLines breakLines(Graphics2D g) {
      Dimension size = label.getSize();
      float maxWidth = size.width;
      AttributedString attributedText = new AttributedString(label.getText(), textAttributes());
      AttributedCharacterIterator textIterator = attributedText.getIterator();
      FontRenderContext fontRendering = g.getFontRenderContext();
      LineBreakMeasurer measurer = new LineBreakMeasurer(textIterator, fontRendering);
      WrappedLines lines = new WrappedLines();
      while(measurer.getPosition() < textIterator.getEndIndex()) {
        TextLayout layout = measurer.nextLayout(maxWidth);
        lines.add(layout);
View Full Code Here

    Graphics2D graphics = image.createGraphics();
    try {
      graphics.setFont(font);
      graphics.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_ON);
     
      FontRenderContext context = graphics.getFontRenderContext();
      TextLayout layout = new TextLayout(text, font, context);
      int x = width / 2 - (int) (layout.getAdvance() / 2f);
      int y = height / 2 + (int) (layout.getAscent() / 2f) - 1;
     
      graphics.setColor(Color.DARK_GRAY.darker());
View Full Code Here

          JTextArea consHelpTextArea = new JTextArea();
          consHelpFrame.setLocation(xloc, yloc);
          consHelpFrame.add(consHelpPanel);
          consHelpFrame.setVisible(true);
          Graphics2D gc = (Graphics2D) consHelpPanel.getGraphics();
         FontRenderContext context = gc.getFontRenderContext();
           Rectangle2D bounds = df.getStringBounds(" ", context);
          int mwidth =(int) bounds.getWidth()*150;
          int mheight =(int) bounds.getHeight()*20;
        
           consHelpFrame.setSize(mwidth, mheight);
View Full Code Here

  public TextConsole(int width, int height, int fontSize, String fontName) {
    font = new Font(fontName, Font.BOLD, fontSize);
    widthChars = width;
    heightChars = height;
    setFont(font);
    FontRenderContext fontRenderContext = new FontRenderContext(null, true,
        true);
    Rectangle2D stringBounds = font.getStringBounds(new char[] { 'l' }, 0,
        1, fontRenderContext);
    setPreferredSize(new Dimension(
        (int) ((widthChars + 1) * stringBounds.getWidth()),
View Full Code Here

      double shearX = rng.nextDouble() * 0.2;
      double shearY = rng.nextDouble() * 0.2;
      CharAttributes cf = new CharAttributes(ch, fontName, rotation, rise, shearX, shearY);
      charAttsList.add(cf);
      text = new TextLayout(ch + "", getFont(fontName), new FontRenderContext(null, false,
        false));
      textAt = new AffineTransform();
      textAt.rotate(rotation);
      textAt.shear(shearX, shearY);
      shape = text.getOutline(textAt);
View Full Code Here

TOP

Related Classes of java.awt.font.FontRenderContext

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.