Examples of FontRenderContext


Examples of java.awt.font.FontRenderContext

                    shearY = ran.nextDouble() * config.getTextShear();
                }
                CharAttributes cf = new CharAttributes(chars[i], fontName, dRotation, rise, shearX, shearY);
                charAttsList.add(cf);
                text = new TextLayout(chars[i] + "", getFont(fontName),
                        new FontRenderContext(null, config.isFontAntialiasing(), false));
                textAt = new AffineTransform();
                if (config.getTextRotation() > 0)
                    textAt.rotate(dRotation);
                if (config.getTextShear() > 0.0)
                    textAt.shear(shearX, shearY);               
View Full Code Here

Examples of java.awt.font.FontRenderContext

        Graphics2D gfx = (Graphics2D) this.image.getGraphics();
        if (config.isFontAntialiasing())
            gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        int curWidth = config.getTextMarginLeft();
        FontRenderContext ctx = new FontRenderContext(null, config.isFontAntialiasing(), false);       
        for (int i = 0; i < charAttsList.size(); i++)
        {
            CharAttributes cf = (CharAttributes) charAttsList.get(i);
            TextLayout text = new TextLayout(cf.getChar() + "", getFont(cf.getName()), ctx); //gfx.getFontRenderContext());
            AffineTransform textAt = new AffineTransform();
View Full Code Here

Examples of java.awt.font.FontRenderContext

    final double xorig     = posX+(origX-minX)*xStep;
    final double yorig     = isSouth  ? posY-yStep*(origY-minY)+labelHeight : posY-yStep*(origY-minY)-2;
    final double width     = shape.getGridWidth()/2.;
    final double tmp     = isSouth ? width : -width;
    final Font font     = fontMetrics.getFont();
    final FontRenderContext frc = new FontRenderContext(null, true, true);
    double i;
    double j;
    String label;
    float x;
    final float yPos = (float)(yorig+tmp);
View Full Code Here

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

Examples of java.awt.font.FontRenderContext

    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

Examples of java.awt.font.FontRenderContext

     */
    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

Examples of java.awt.font.FontRenderContext

     */
    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

Examples of java.awt.font.FontRenderContext

      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

Examples of java.awt.font.FontRenderContext

    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

Examples of java.awt.font.FontRenderContext

    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
TOP
Copyright © 2018 www.massapi.com. 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.