Examples of AffineTransform


Examples of java.awt.geom.AffineTransform

     */
    public static void drawAngledString(Graphics g, String text, int x, int y,
                                        double angle) {

        Graphics2D g2D = (Graphics2D) g;
        AffineTransform oldAt = g2D.getTransform();
        AffineTransform at = new AffineTransform(oldAt);
        at.rotate(angle, x, y);
        g2D.setTransform(at);
        g2D.drawString(text, x, y);
        g2D.setTransform(oldAt);
    }
View Full Code Here

Examples of java.awt.geom.AffineTransform

            return false;
        }

        GeneralPath gp, gp1, gp2;
        PathIterator pi;
        AffineTransform af = null;

        switch (renderType) {
        case RENDERTYPE_OFFSET:
            if (!proj.isPlotable(center)) {
                setNeedToRegenerate(true);//HMMM not the best flag
                return false;
            }
            Point p1 = proj.forward(center.radlat_,
                    center.radlon_,
                    new Point(),
                    true);
            x1 = p1.x + off_x;
            y1 = p1.y + off_y;

        case RENDERTYPE_XY:
            float fwidth = (float) width;
            float fheight = (float) height;
            float transx = (float) x1;
            float transy = (float) y1;
            float x = transx - fwidth / 2f;
            float y = transy - fheight / 2f;

            Shape arcShape = createArcShape(x, y, fwidth, fheight);

            if (rotationAngle != DEFAULT_ROTATIONANGLE) {
                af = new AffineTransform();
                af.rotate(rotationAngle, transx, transy);
            }
            pi = arcShape.getPathIterator(af);
            gp = new GeneralPath();
            gp.append(pi, false);
            // In X/Y or Offset RenderType, there is only one shape.
View Full Code Here

Examples of java.awt.geom.AffineTransform

      scale = (double) maxImageSize / (double) inImage.getWidth(null);
    }
    int scaledW = (int) (scale * inImage.getWidth(null));
    int scaledH = (int) (scale * inImage.getHeight(null));
    BufferedImage outImage = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
    AffineTransform tx = new AffineTransform();

    if (scale < 1.0d) {
      tx.scale(scale, scale);
    }

    Color bgColor = null;
    Graphics2D g2d = outImage.createGraphics();
    g2d.setColor(bgColor);
View Full Code Here

Examples of java.awt.geom.AffineTransform

                        + height + " image at " + point1.x + ", " + point1.y);
            }
            if (g instanceof Graphics2D && bitmap instanceof RenderedImage) {
                // Affine translation for placement...
                ((Graphics2D) g).drawRenderedImage((RenderedImage) bitmap,
                        new AffineTransform(1f, 0f, 0f, 1f, point1.x, point1.y));
                // Undo the affine translation for future graphics??  Apparently not...
//                ((Graphics2D) g).translate(-point1.x, -point1.y);
            } else {
                g.drawImage(bitmap, point1.x, point1.y, this);
            }
View Full Code Here

Examples of java.awt.geom.AffineTransform

                        / (double) clipRect.width;
                // Calc height adjustment
                double heightAdj = (double) iRect.height
                        / (double) clipRect.height;
                // Create the transform
                AffineTransform xform = new AffineTransform();
                // Specify scaling
                xform.setToScale(widthAdj, heightAdj);

                // Create the transform op.
                AffineTransformOp xformOp = new AffineTransformOp(xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
                // Scale clip area -> newImage
                // extract sub-image
View Full Code Here

Examples of java.awt.geom.AffineTransform

        Graphics2D g2d = (Graphics2D) g;
        if (selected)
            g2d.setPaint(selectPaint);
        else
            g2d.setPaint(linePaint);
        AffineTransform saveAT = g2d.getTransform();
        // Perform transformation
        g2d.transform(at);
        // Render
        g2d.drawGlyphVector(gv, 0, 0);
        g.setColor(Color.blue);
View Full Code Here

Examples of java.awt.geom.AffineTransform

    void compute() {
        float lt1;
        float ln1;
        float lt2;
        float ln2;
        FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true);
        gv = font.createGlyphVector(frc, str);
        Rectangle2D r = gv.getLogicalBounds();
        w = r.getWidth();
        angle = 0;
        int nseg = llpoints.length / 2 - 1;
        lt1 = llpoints[0];
        ln1 = llpoints[1];
        llp1.setLatLon(lt1, ln1, true);
        lt2 = llpoints[2 * nseg];
        ln2 = llpoints[2 * nseg + 1];
        llp2.setLatLon(lt2, ln2, true);
        distance = GreatCircle.spherical_distance(lt1, ln1, lt2, ln2)
                * Planet.wgs84_earthEquatorialRadiusMeters;
        //System.out.println(nseg+" "+llp1+" "+llp2);
        setNeedToRegenerate(true);
        visible = false;

        float[] ds = new float[nseg];
        float[] az = new float[nseg];
        float[] cs = new float[nseg];
        int j = 2;
        float s = 0;
        float corr = 0;
        float dz;
        float az0 = 0;
        for (int i = 0; i < nseg; i++) {
            //if(j>llpoints.length-2){System.out.println(j+" "+i+"
            // "+nseg);nseg=1;break;}
            lt2 = (float) llpoints[j++];
            ln2 = (float) llpoints[j++];
            if (lt2 == lt1 && ln2 == ln1) {
                // suppress null segments
                i--;
                nseg--;
            } else {
                s += GreatCircle.spherical_distance(lt1, ln1, lt2, ln2);
                ds[i] = s;
                az[i] = GreatCircle.spherical_azimuth(lt1, ln1, lt2, ln2);
                if (i > 0) {
                    dz = (float) Math.tan((az[i] - az0) / 2);
                    if (dz < 0) {
                        cs[i - 1] = -dz;
                        corr -= 2 * dz;
                    }
                }
                az0 = az[i];
                lt1 = lt2;
                ln1 = ln2;
            }
        }
        if (nseg <= 1)
            return;
        // now try to play with little boxes
        // rotate them either on upper left corner or lower lef corner
        // probably can be simplified ...
        visible = true;
        LineMetrics lm = font.getLineMetrics("MM", frc);
        if (lm == null) {
            System.out.println("null metrics");
            return;
        }
        float h = (float) lm.getAscent();
        //System.out.println("ascent:" + h + " w:" + w + " s:" + s +
        // " corr:" + corr + " wc:" + (w - corr * h) + " " + str);
        corr = 0f;
        w -= corr * h;
        float sc = (float) (w / s);
        for (int i = 0; i < nseg; i++)
            ds[i] *= sc;
        int m = gv.getNumGlyphs();
        float[] gp = gv.getGlyphPositions(0, m, null);
        if (gp == null)
            System.out.println("gp null");
        //path = new GeneralPath();
        AffineTransform at;
        double dx;
        double dy;
        double x = 0;
        double y = 0;
        double xa;
        double ya;
        double s0 = 0;
        double ps;
        double s1;
        double s2;
        double theta;
        double theta2;
        double thetai;
        double dtheta;
        double ch0 = 0;
        double cos1;
        double sin1;
        double cos2;
        double sin2;
        j = 0;
        for (int i = 0; i < m; i++) {
            s = (i == m - 1) ? (float) w : gp[2 * i + 2];
            ps = s - s0;
            theta = az[j];
            cos1 = Math.cos(theta);
            sin1 = Math.sin(theta);
            float ch = (float) (cs[j] * h);
            if (s + ch0 < ds[j] - ch || j == nseg - 1) {
                xa = x;
                ya = y;
                x += ps * cos1;
                y += ps * sin1;
            } else {
                theta2 = az[j + 1];
                cos2 = Math.cos(theta2);
                sin2 = Math.sin(theta2);
                dtheta = theta2 - theta;
                s1 = ds[j] - ch - ch0 - s0;
                s2 = s1 * Math.sin(dtheta);
                s2 = ps * ps - s2 * s2;
                s2 = Math.sqrt(s2) - s1 * Math.cos(dtheta);
                dx = s1 * cos1 + s2 * cos2;
                dy = s1 * sin1 + s2 * sin2;
                thetai = Math.atan2(dy, dx);
                if (ch == 0) {
                    xa = x;
                    ya = y;
                } else {
                    dx += ch * cos1 + ch * cos2;
                    dy += ch * sin1 + ch * sin2;
                    xa = x + h * sin1 - h * Math.sin(thetai);
                    ya = y - h * cos1 + h * Math.cos(thetai);
                }
                x += dx;
                y += dy;
                j++;
                ch0 = ch;
                theta = thetai;
            }

            gv.setGlyphPosition(i, new Point2D.Double(xa, ya));
            if (theta != 0) {
                at = new AffineTransform();
                at.rotate(theta);
                gv.setGlyphTransform(i, at);
            }
            s0 = s;
            /*
             * path.moveTo((float) xa, (float) ya); xa += ps *
 
View Full Code Here

Examples of java.awt.geom.AffineTransform

                    // Gets reset by JComponent
                    g.setClip(0, 0, proj.getWidth(), proj.getHeight());
                }

                ((Graphics2D) g).drawRenderedImage((BufferedImage) bufferedImage,
                        new AffineTransform());
                if (DEBUG) {
                    Debug.output("RenderingPolicy:" + layer.getName()
                            + ": rendering buffer");
                }
View Full Code Here

Examples of java.awt.geom.AffineTransform

                        break;
                    case JUSTIFY_RIGHT:
                        woffset = rw;
                    }

                    AffineTransform at = new AffineTransform();
                    at.rotate(rotationAngle, rx + woffset, pt.y);
                    PathIterator pi = shape.getPathIterator(at);
                    GeneralPath gp = new GeneralPath();
                    gp.append(pi, false);
                    shape = gp;
                }
View Full Code Here

Examples of java.awt.geom.AffineTransform

                Shape shape = graphic.getShape();
                if (shape == null)
                    continue;

                PathIterator path = shape.getPathIterator(new AffineTransform());
                int segment = 0;
                int itemsInPath = 0;
                boolean pathValid = true;

                for (; !path.isDone() && pathValid; path.next()) {
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.