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

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


    }

    public void quadratify(Point2D a, Point2D b, Point2D c, Point2D d)
            throws IOException {
        // find intersection between bezier arms
        Point2D s = intersect(a, b, c, d);
        if (s == null) return;
       
        // find distance between the midpoints
        double dx = (a.getX() + d.getX() + s.getX() * 4 - (b.getX() + c.getX()) * 3) * .125;
        double dy = (a.getY() + d.getY() + s.getY() * 4 - (b.getY() + c.getY()) * 3) * .125;
        // split curve if the quadratic isn't close enough
        if (dx * dx + dy * dy > resolutionSq) {
            Point2D p01 = midPoint(a, b);
            Point2D p12 = midPoint(b, c);
            Point2D p23 = midPoint(c, d);
            Point2D p02 = midPoint(p01, p12);
            Point2D p13 = midPoint(p12, p23);
            Point2D p03 = midPoint(p02, p13);
            // recursive call to subdivide curve
            quadratify(a, p01, p02, p03);
            quadratify(p03, p13, p23, d);
        } else {
            // end recursion by drawing quadratic bezier
View Full Code Here


        // ControlSets are written at the end
        Stack/*<ControlSet>*/ controls = new Stack/*<ControlSet>*/();

        // System.out.println("Cubic "+x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3);
        Point2D p0 = new Point2D.Double(currentX, currentY);
        Point2D p1 = new Point2D.Double(x1, y1);
        Point2D p2 = new Point2D.Double(x2, y2);
        Point2D p3 = new Point2D.Double(x3, y3);

        // ControlSets to create the controls
        Stack/*<ControlSet>*/ temps = new Stack/*<ControlSet>*/();
        temps.push(new ControlSet(p0, p1, p2, p3));

        while (!temps.empty()) {
            ControlSet control = (ControlSet) temps.pop();
            if (control.breadth() > resolution) {
                temps.push(control);
                temps.push(control.bisect());
            } else {
                controls.push(control);
            }
        }

        /*tempSet[l++] = new ControlSet(p0, p1, p2, p3);
        while (l > 0) {
            ControlSet control1 = tempSet[--l];
            double b = control1.breadth();
            if (b > resolution) {
                ControlSet control3 = control1.bisect();
                tempSet[l++] = control1;
                tempSet[l++] = control3;
            } else {
                controls.push(control1);
            }
        }*/

        // write out control sets
        // System.out.println(k);
        while (!controls.empty()) {
            Point2D p = ((ControlSet)controls.pop()).getPoint();
            line(p.getX(), p.getY());
            // System.out.println(control2.getPoint());
        }

        // store currentX and currentY
        super.cubic(x1, y1, x2, y2, x3, y3);
View Full Code Here

                return Math.max(f9, f11);
            }
        }

        public ControlSet bisect() {
            Point2D p0 = average(point0, point1);
            Point2D p1 = average(point1, point2);
            Point2D p2 = average(point2, point3);
            Point2D p3 = average(p0, p1);
            Point2D p4 = average(p1, p2);
            Point2D p5 = average(p3, p4);
            ControlSet controlset = new ControlSet(p5, p4, p2, point3);
            point1 = p0;
            point2 = p3;
            point3 = p5;
            return controlset;
View Full Code Here

        c2 = color2.getRGB();

        double px = point2.getX() - point1.getX();
        double py = point2.getY() - point1.getY();

        Point2D p = t.transform(point1, null);
        Point2D bx = new Point2D.Double(px, py);
        Point2D by = new Point2D.Double(py, -px);

        t.deltaTransform(bx, bx);
        t.deltaTransform(by, by);

        double vec = bx.getX() * by.getY() - bx.getY() * by.getX();

        if (Math.abs(vec) < ZERO) {
            dx = dy = delta = 0;
            table = new int[1];
            table[0] = c1;
        } else {
            double mult = LOOKUP_SIZE * 256 / vec;
            dx = (int)(by.getX() * mult);
            dy = (int)(by.getY() * mult);
            delta = (int)((p.getX() * by.getY() - p.getY() * by.getX()) * mult);
            createTable();
        }
    }
View Full Code Here

        m11 = (int)(t.getScaleY() * multW);
        m01 = (int)(t.getShearX() * multW);
        m00 = (int)(t.getScaleX() * multH);
        m10 = (int)(t.getShearY() * multH);
        Point2D p = t.transform(new Point2D.Double(anchor.getX(), anchor.getY()), null);
        px = (int)p.getX();
        py = (int)p.getY();

        hx = check2(m11, imgW);
        hy = check2(m10, imgH);

        srcRaster = img.getRaster();
View Full Code Here

                continue;
            }

            byte[] data = gl.getBitmap();
            if (data != null) {
                Point2D pos = glyphVector.getGlyphPosition(i);

                xSrcSurf = 0;//gl.bmp_left;
                ySrcSurf = 0;//gl.bmp_rows - gl.bmp_top;

                xDstSurf = x + (int)pos.getX() + (int) gl.getGlyphPointMetrics().getLSB();// + gl.bmp_left;
                yDstSurf = y - gl.bmp_top/*getPointHeight()*/  + (int) pos.getY();// - (gl.bmp_rows-gl.bmp_top);

                int textWidth = gl.bmp_width;
                int textHeight = gl.getPointHeight();

                // if Regions don't intersect
View Full Code Here

        if ((glyphIndex > vector.length) || (glyphIndex < 0)) {
            // awt.43=glyphIndex is out of vector's limits
            throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
        }
        int index = glyphIndex << 1;
        Point2D pos = new Point2D.Float(visualPositions[index], visualPositions[index+1]);

        // For last position we don't have to transform !!
        if(glyphIndex==vector.length){
            return pos;
        }

        AffineTransform at = getGlyphTransform(glyphIndex);
        if ((at == null) || (at.isIdentity())){
            return pos;
        }

        pos.setLocation(pos.getX() + at.getTranslateX(), pos.getY() + at.getTranslateY());

        return pos;
    }
View Full Code Here

                for (int i=firstGlyph; i<=lastGlyph; i++) {
                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[i];
                    currInfo = jInfos[gji.growPriority];
                    if (currInfo == null) {
                        // We still have to increment glyph position
                        Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                        glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                        getGlyphVector().setGlyphPosition(i, glyphPos);

                        continue;
                    }

                    if (currInfo.useLimits) {
                        glyphOffset += gji.growLeftLimit;
                        if (currInfo.absorb) {
                            sideIncrement = gji.weight * currInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else if (lastInfo != null && lastInfo.priority == currInfo.priority) {
                            sideIncrement = gji.weight * lastInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else {
                            positionIncrement = glyphOffset;
                        }
                        glyphOffset += gji.growRightLimit;
                    } else {
                        sideIncrement = gji.weight * currInfo.gapPerUnit;
                        glyphOffset += sideIncrement;
                        positionIncrement = glyphOffset;
                        glyphOffset += sideIncrement;
                    }

                    Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                    glyphPos.setLocation(glyphPos.getX() + positionIncrement, glyphPos.getY());
                    getGlyphVector().setGlyphPosition(i, glyphPos);
                }
            } else {
                for (int i=firstGlyph; i<=lastGlyph; i++) {
                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[i];
                    currInfo = jInfos[gji.shrinkPriority];
                    if (currInfo == null) {
                        // We still have to increment glyph position
                        Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                        glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                        getGlyphVector().setGlyphPosition(i, glyphPos);

                        continue;
                    }

                    if (currInfo.useLimits) {
                        glyphOffset -= gji.shrinkLeftLimit;
                        if (currInfo.absorb) {
                            sideIncrement = gji.weight * currInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else if (lastInfo != null && lastInfo.priority == currInfo.priority) {
                            sideIncrement = gji.weight * lastInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else {
                            positionIncrement = glyphOffset;
                        }
                        glyphOffset -= gji.shrinkRightLimit;
                    } else {
                        sideIncrement =  gji.weight * currInfo.gapPerUnit;
                        glyphOffset += sideIncrement;
                        positionIncrement = glyphOffset;
                        glyphOffset += sideIncrement;
                    }

                    Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                    glyphPos.setLocation(glyphPos.getX() + positionIncrement, glyphPos.getY());
                    getGlyphVector().setGlyphPosition(i, glyphPos);
                }
            }


            if (haveLast) {   // Don't add padding after last char
                lastGlyph++;

                GlyphJustificationInfo gji = getGlyphJustificationInfos()[lastGlyph];
                currInfo = jInfos[gji.growPriority];

                if (currInfo != null) {
                    if (currInfo.useLimits) {
                        glyphOffset += firstInfo.grow ? gji.growLeftLimit : -gji.shrinkLeftLimit;
                        if (currInfo.absorb) {
                            glyphOffset += gji.weight * currInfo.absorbedGapPerUnit;
                        } else if (lastInfo != null && lastInfo.priority == currInfo.priority) {
                            glyphOffset += gji.weight * lastInfo.absorbedGapPerUnit;
                        }
                    } else {
                        glyphOffset += gji.weight * currInfo.gapPerUnit;
                    }
                }

                // Ajust positions of all glyphs after last glyph
                for (int i=lastGlyph; i<getGlyphVector().getNumGlyphs()+1; i++) {
                    Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                    glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                    getGlyphVector().setGlyphPosition(i, glyphPos);
                }
            } else { // Update position after last glyph in glyph vector -
                // to get correct advance for it
                Point2D glyphPos = getGlyphVector().getGlyphPosition(lastGlyph+1);
                glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                getGlyphVector().setGlyphPosition(lastGlyph+1, glyphPos);
            }

            gjis = null; // We don't need justification infos any more
            // Also we have to reset cached bounds and metrics
View Full Code Here

                cb.setColorStroke(color);
            }
        }
        else if (paint instanceof GradientPaint) {
            GradientPaint gp = (GradientPaint)paint;
            Point2D p1 = gp.getPoint1();
            transform.transform(p1, p1);
            Point2D p2 = gp.getPoint2();
            transform.transform(p2, p2);
            Color c1 = gp.getColor1();
            Color c2 = gp.getColor2();
            PdfShading shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float)p1.getX(), normalizeY((float)p1.getY()), (float)p2.getX(), normalizeY((float)p2.getY()), c1, c2);
            PdfShadingPattern pat = new PdfShadingPattern(shading);
            if (fill)
                cb.setShadingFill(pat);
            else
                cb.setShadingStroke(pat);
View Full Code Here

TOP

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

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.