Package com.google.code.appengine.awt.geom

Examples of com.google.code.appengine.awt.geom.AffineTransform


            // the size of the design grid on which glyphs are laid out
            result.append("units-per-em=\"");
            result.append(SVGGraphics2D.fixedPrecision(SVGGlyph.FONT_SIZE));
            result.append("\" ");

            TextLayout tl = new TextLayout("By", font, new FontRenderContext(new AffineTransform(), true, true));

            // The maximum unaccented height of the font within the font coordinate system.
            // If the attribute is not specified, the effect is as if the attribute were set
            // to the difference between the units-per-em value and the vert-origin-y value
            // for the corresponding font.
View Full Code Here


            // care for Italic fonts too
            Math.max(tl.getAdvance(), bounds.getWidth()),
            bounds.getHeight());

        // add x and y
        AffineTransform at = AffineTransform.getTranslateInstance(x, y);

        // horizontal alignment
        if (horizontal == TEXT_RIGHT) {
            at.translate(- bounds.getWidth(), 0);
        } else if (horizontal == TEXT_CENTER) {
            at.translate(- bounds.getWidth() / 2, 0);
        }

        // vertical alignment
        if (vertical == TEXT_BASELINE) {
            // no translation needed
        } else if (vertical == TEXT_TOP) {
            at.translate(0, - bounds.getY());
        } else if (vertical == TEXT_CENTER) {
            // the following adds supersript ascent too,
            // so it does not work
            // at.translate(0, tl.getAscent() / 2);
            // this is nearly the same
            at.translate(0, tl.getDescent());
        } else if (vertical == TEXT_BOTTOM) {
            at.translate(0, - bounds.getHeight() - bounds.getY());
        }

        // transform the bounds
        bounds = at.createTransformedShape(bounds).getBounds2D();
        // create the result with the same transformation
        Point2D result = at.transform(new Point2D.Double(0, 0), new Point2D.Double());

        // space between string and border
        double adjustment = (getFont().getSize2D() * 2) / 10;

        // add the adjustment
View Full Code Here

     * @param path
     */
    public void setPath(GeneralPath path)
    {
        Rectangle2D bounds = path.getBounds2D();
        PathIterator it = path.getPathIterator(new AffineTransform());

        List<byte[]> segInfo = new ArrayList<byte[]>();
        List<Point2D.Double> pntInfo = new ArrayList<Point2D.Double>();
        boolean isClosed = false;
        while (!it.isDone()) {
View Full Code Here

    public com.google.code.appengine.awt.Shape getOutline(){
        GeneralPath path =  getPath();
        Rectangle2D anchor = getAnchor2D();
        Rectangle2D bounds = path.getBounds2D();
        AffineTransform at = new AffineTransform();
        at.translate(anchor.getX(), anchor.getY());
        at.scale(
                anchor.getWidth()/bounds.getWidth(),
                anchor.getHeight()/bounds.getHeight()
        );
        return at.createTransformedShape(path);
    }
View Full Code Here

    public void paint(Graphics2D g2) {
        this.g2 = g2;

        // store at leat clip and transformation
        Shape clip = g2.getClip();
        AffineTransform at = g2.getTransform();
        Map hints = g2.getRenderingHints();

        // some quality settings
        g2.setRenderingHint(
            RenderingHints.KEY_RENDERING,
View Full Code Here

    private void resetTransformation(Graphics2D g2) {
        // rest to device configuration
        if (initialTransform != null) {
            g2.setTransform(initialTransform);
        } else {
            g2.setTransform(new AffineTransform());
        }

        /* TODO mapModeTransform dows not work correctly
        if (mapModeTransform != null) {
            g2.transform(mapModeTransform);
View Full Code Here

            setDefaultSize();
        }
    }

    public void draw(Graphics2D graphics){
        AffineTransform at = graphics.getTransform();
        ShapePainter.paint(this, graphics);

        PictureData data = getPictureData();
        if(data != null) data.draw(graphics, this);
View Full Code Here


    public FontRenderContext(AffineTransform trans, boolean antiAliased,
            boolean usesFractionalMetrics) {
        if (trans != null){
            transform = new AffineTransform(trans);
        }
        fAntiAliased = antiAliased;
        fFractionalMetrics = usesFractionalMetrics;
    }
View Full Code Here

    }

    public AffineTransform getTransform() {
        if (transform != null){
            return new AffineTransform(transform);
        }
        return new AffineTransform();
    }
View Full Code Here

            while(top.getParent() != null) {
                top = top.getParent();
                lst.add(top);
            }

            AffineTransform tx = new AffineTransform();
            for(int i = lst.size() - 1; i >= 0; i--) {
                ShapeGroup prnt = (ShapeGroup)lst.get(i);
                Rectangle2D exterior = prnt.getAnchor2D();
                Rectangle2D interior = prnt.getCoordinates();

                double scaleX =  exterior.getWidth() / interior.getWidth();
                double scaleY = exterior.getHeight() / interior.getHeight();

                tx.translate(exterior.getX(), exterior.getY());
                tx.scale(scaleX, scaleY);
                tx.translate(-interior.getX(), -interior.getY());
            }
            anchor = tx.createTransformedShape(anchor).getBounds2D();
        }

        int angle = getRotation();
        if(angle != 0){
            double centerX = anchor.getX() + anchor.getWidth()/2;
            double centerY = anchor.getY() + anchor.getHeight()/2;

            AffineTransform trans = new AffineTransform();
            trans.translate(centerX, centerY);
            trans.rotate(Math.toRadians(angle));
            trans.translate(-centerX, -centerY);

            Rectangle2D rect = trans.createTransformedShape(anchor).getBounds2D();
            if((anchor.getWidth() < anchor.getHeight() && rect.getWidth() > rect.getHeight()) ||
                (anchor.getWidth() > anchor.getHeight() && rect.getWidth() < rect.getHeight())    ){
                trans = new AffineTransform();
                trans.translate(centerX, centerY);
                trans.rotate(Math.PI/2);
                trans.translate(-centerX, -centerY);
                anchor = trans.createTransformedShape(anchor).getBounds2D();
            }
        }
        return anchor;
    }
View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.geom.AffineTransform

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.