Package java.awt.geom

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


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

                        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

                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

     */
    public BasicIconPart(Shape shape, AffineTransform transform, DrawingAttributes da) {
        geometry = shape;

        if (transform == null) {
            transform = new AffineTransform();
        }

        baseTransform = transform;
        setRenderingAttributes(da);
    }
View Full Code Here

     *        drawing attributes if they want/should. May be null.
     */
    public void render(Graphics g, int width, int height,
                       DrawingAttributes appDA) {

        AffineTransform transform = AffineTransform.getScaleInstance((double) width / 100,
                (double) height / 100);
        transform.concatenate(baseTransform);

        // Handle clip area in Graphics, first
        Shape clip = getClip();
        if (clip != null) {
            g.setClip(new GeneralPath(clip).createTransformedShape(transform));
View Full Code Here

   * @see Graphics2D#getFontRenderContext()
   */
  public FontRenderContext getFontRenderContext() {
      boolean antialias = RenderingHints.VALUE_TEXT_ANTIALIAS_ON.equals(getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
      boolean fractions = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS));
      return new FontRenderContext(new AffineTransform(), antialias, fractions);
  }
View Full Code Here

  /**
   * @see Graphics2D#getTransform()
   */
  public AffineTransform getTransform() {
      return new AffineTransform(oTransform);
  }
View Full Code Here

    paint = Color.black;
    // possible: if parent.color is not black, then force black?
    // must check to see what AWT does?
   
    // Original User Space Transform (identity)
    oTransform = new AffineTransform();
   
    // Transform from Java Space to PDF Space
  pTransform = new AffineTransform();
  pTransform.translate(0, pf.getHeight());
  pTransform.scale(1d, -1d);

  // Combined Transform User->Java->PDF
  transform = new AffineTransform(oTransform);
  transform.concatenate(pTransform);

    // Set the line width
    setStroke(DEF_STROKE);
  }
View Full Code Here

   */
  public void setTransform(AffineTransform t) {
    // Save copy of original transform.
      oTransform = t;
      // Working copy of transform
      transform = new AffineTransform(t);
      // Concatenate Java Space to PDF Space transform
      transform.concatenate(pTransform);
      this.stroke = transformStroke(originalStroke);
  }
View Full Code Here

TOP

Related Classes of java.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.