Examples of FontRenderContext


Examples of java.awt.font.FontRenderContext

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

Examples of java.awt.font.FontRenderContext

    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

Examples of java.awt.font.FontRenderContext

        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

Examples of java.awt.font.FontRenderContext

            xpt = constraints.getMaximumColumnValue();
       
        boolean paint = false;
       
        DecimalFormat df = c.getYDecimalFormat();
    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

Examples of java.awt.font.FontRenderContext

        Point2D p = new Point2D.Double(0.0, 0.0);
        Point2D v;
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
       
    DecimalFormat df = c.getXDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
       
    boolean paint = false;
   
        g.setFont(f);
View Full Code Here

Examples of java.awt.font.FontRenderContext

        Point2D oldv = null;
       
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
       
    DecimalFormat df = c.getXDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
       
        boolean paint = false;
        boolean paintLabels = c.isPaintLabels();
        g.setFont(f);
View Full Code Here

Examples of java.awt.font.FontRenderContext

        Point2D v;
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
        boolean paint = false;
       
        DecimalFormat df = c.getYDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
   
    Color backupColor = g.getColor();
        g.setFont(f);
        boolean paintLabels = c.isPaintLabels();
View Full Code Here

Examples of java.awt.font.FontRenderContext

            ((AlphaComposite)oldComposite).getAlpha() * 0.7f));
        } else {
          g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
        }
        g2D.setStroke(new BasicStroke(3 / planScale));
        FontRenderContext fontRenderContext = g2D.getFontRenderContext();
        TextLayout textLayout = new TextLayout(lengthText, font, fontRenderContext);
        g2D.draw(textLayout.getOutline(new AffineTransform()));
        g2D.setComposite(oldComposite);
        g2D.setPaint(foregroundColor);
      }
View Full Code Here

Examples of java.awt.font.FontRenderContext

     */
    public static BufferedImage createImageFromText(String text, Font font) {
        //You may want to change these setting, or make them parameters
        boolean isAntiAliased = true;
        boolean usesFractionalMetrics = false;
        FontRenderContext frc = new FontRenderContext(null, isAntiAliased, usesFractionalMetrics);
        TextLayout layout = new TextLayout(text, font, frc);
        Rectangle2D bounds = layout.getBounds();
        int w = (int) Math.ceil(bounds.getWidth());
        int h = (int) Math.ceil(bounds.getHeight()) + 2;
        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); //for example;
View Full Code Here

Examples of java.awt.font.FontRenderContext

    public void reflow(TextManager.Renderer renderer, int width, TextDataImpl text) {
        flowList.clear();
        int numLines = 0;
        TextRenderer joglRenderer = renderer.getJOGLRenderer();
        FontRenderContext frc = joglRenderer.getFontRenderContext();

        String paragraph = text.getLine().getText();
        Map attrs = new HashMap();
        attrs.put(TextAttribute.FONT, joglRenderer.getFont());
        AttributedString str = new AttributedString(paragraph, attrs);
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.