Package java.awt.font

Examples of java.awt.font.FontRenderContext


      // so that fonts were always rendered with FractionalMetrics enabled.
      // Since 1.4, fonts are always rendered with FractionalMetrics disabled.

      // On a 1.4 version, the aliasing has no influence on non-fractional metrics
      // aliasing has no influence on any version if fractional metrics are enabled.
      final FontRenderContext frcAlias = new FontRenderContext(null, true, false);
      final FontRenderContext frcNoAlias = new FontRenderContext(null, false, false);
      final Font font = new Font("Serif", Font.PLAIN, 10);
      final String myText = "A simple text with some characters to calculate the length.";

      final double wAlias = font.getStringBounds(myText, 0, myText.length(), frcAlias)
          .getWidth();
View Full Code Here


    {
      if (fontRenderContext == null)
      {
        if (isAliased())
        {
          fontRenderContext = new FontRenderContext(null, isAliased(), true);
        }
        else
        {
          // buggy is only important on non-aliased environments ...
          // dont use fractional metrics on buggy versions

          // use int_metrics wenn buggy ...
          fontRenderContext = new FontRenderContext(null, isAliased(), isBuggyVersion() == false);
        }
      }
      return fontRenderContext;
    }
View Full Code Here

            tableFilter.setTableHeader(getTableHeader());
            setModel(tableFilter);
            setRowSelectionAllowed(false);
      setColumnSelectionAllowed(false);
      Font f = getFont();
      fontRendererContext = new FontRenderContext(f.getTransform(), false, false);
      setRowHeight((int)f.getMaxCharBounds(fontRendererContext).getHeight());
      renderer=createTableRenderer(tableModel);
      addMouseListener(LoggingPanel.this);
    }
View Full Code Here

      Line2D lLine = new Line2D.Double(center_x, center_y, lX, lY );
          g.setColor(Color.black);
          g.draw(lLine);

          // draw the label
          lLabel = new TextLayout("" + model.getColumnValueAt(lCol), new Font("Courier", Font.BOLD, 9), new FontRenderContext(null, true, false));
          g.setColor(Color.black);
           
            // Move the labels in the lower half circle down a bit, so the upper left corner touches the axis
            if ((lRotation <= Math.PI / 2) && (lRotation >= -Math.PI / 2))
                lY += lLabel.getBounds().getHeight();
View Full Code Here

        else
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         0f),
                                        null);
        
        FontRenderContext columnTopfrc = null;
        LineMetrics lm = null;
        DecimalFormat df = null;
        Rectangle2D fontRec = null;
        String columnTop = null;
        if (barTopFormat != null) {
            g.setFont(barTopFont);
            columnTopfrc = new FontRenderContext(null, false, false);
        }
        /* We paint the values starting at x-value "0".
         * As we only render BarCharts for ChartDataModels with
         * non-numeric x-axis values we don't have to read those
         * values from the data model. You can look in
View Full Code Here

@Component
public class TextServiceImpl implements TextService {

  public Rectangle2D getStringBounds(String text, FontStyleInfo fontStyle) {
    Font font = getFont(fontStyle);
    return font.getStringBounds(text, 0, text.length(), new FontRenderContext(new AffineTransform(), true, true));
  }
View Full Code Here

     * @return a non-null Dimension object
     */
    public Dimension getPreferredSize() {
        Rectangle2D titleBounds =
            getFont().getStringBounds(getText(),
                                      new FontRenderContext(null, true, false));
       
        return new Dimension((int)titleBounds.getWidth(),
                             (int)titleBounds.getHeight());
    }   
View Full Code Here

    }
       
        // draw X-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutX = new TextLayout(getXAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
    layoutX.draw(g, (float)x.getX2() + (float)ARROWLENGTH / 3(float)x.getY2() + (float)layoutX.getBounds().getHeight() + 5);
       
        // draw Y-Axis Arrow
    if(shouldDrawArrows) {
      g.drawLine((int)y.getX1(), (int)y.getY1(), (int)y.getX1(), (int)y.getY1() - ARROWLENGTH);
      g.fillPolygon(new int[] {(int)(y.getX1() - 3),
            (int)(y.getX1() + 3),
            (int)(y.getX1())},
            new int[] {(int)(y.getY1() - ARROWLENGTH / 3.0),
            (int)(y.getY1() - ARROWLENGTH / 3.0),
            (int)y.getY1() - ARROWLENGTH},
            3);
    }

        // draw Y-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutY = new TextLayout(getYAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
        layoutY.draw(g, (float)y.getX1()-6-(float)layoutY.getBounds().getWidth(),
                        (float)y.getY1() - layoutX.getDescent() - 3);
       
        if(getSecondYAxis() != null) {
            Line2D y2 = c.getSecondYAxisLine2D();
View Full Code Here

    public static int getTextLength(Graphics g, String text) {
        if(text.length() == 0)
            return 0;
        Graphics2D g2 = (Graphics2D) g;
        FontRenderContext frc = g2.getFontRenderContext();
        Font font = g.getFont();
        TextLayout layout = new TextLayout(text, font, frc);
        Rectangle2D bounds = layout.getBounds();
        return (int) bounds.getWidth() + 1;
    }
View Full Code Here

        else if(constraints.getMaximumValue().doubleValue() < 0)
            ypt = constraints.getMaximumValue().doubleValue();
        boolean paint = false;
       
        DecimalFormat df = c.getXDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
       
        for(double d = min; d <= max; d += tick) {
            if(paint) {
                String sb = df.format(d);
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.