Java 类org.w3c.dom.svg.SVGMatrix 实例源码

项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the absolute distance between this value and the specified other
 * value.
 */
public float distanceTo(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE()) + Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA()) + Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's first component and the
 * specified other value's first component.
 */
public float distanceTo1(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's second component and the
 * specified other value's second component.
 */
public float distanceTo2(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
            return Math.abs(t1.getX() - t2.getX());
    }
    return 0f;
}
项目:elki    文件:BatikUtil.java   
/**
 * Get the relative coordinates of a point within the coordinate system of a
 * particular SVG Element.
 *
 * @param evt Event, needs to be a DOMMouseEvent
 * @param reference SVG Element the coordinate system is used of
 * @return Array containing the X and Y values
 */
public static double[] getRelativeCoordinates(Event evt, Element reference) {
  if(evt instanceof DOMMouseEvent && reference instanceof SVGLocatable && reference instanceof SVGElement) {
    // Get the screen (pixel!) coordinates
    DOMMouseEvent gnme = (DOMMouseEvent) evt;
    SVGMatrix mat = ((SVGLocatable) reference).getScreenCTM();
    SVGMatrix imat = mat.inverse();
    SVGPoint cPt = ((SVGElement) reference).getOwnerSVGElement().createSVGPoint();
    cPt.setX(gnme.getClientX());
    cPt.setY(gnme.getClientY());
    // Have Batik transform the screen (pixel!) coordinates into SVG element
    // coordinates
    cPt = cPt.matrixTransform(imat);

    return new double[] { cPt.getX(), cPt.getY() };
  }
  return null;
}
项目:elki    文件:SVGUtil.java   
/**
 * Convert the coordinates of an DOM Event from screen into element
 * coordinates.
 *
 * @param doc Document context
 * @param tag Element containing the coordinate system
 * @param evt Event to interpret
 * @return coordinates
 */
public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
  try {
    DOMMouseEvent gnme = (DOMMouseEvent) evt;
    SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
    SVGMatrix imat = mat.inverse();
    SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
    cPt.setX(gnme.getClientX());
    cPt.setY(gnme.getClientY());
    return cPt.matrixTransform(imat);
  }
  catch(Exception e) {
    LoggingUtil.warning("Error getting coordinates from SVG event.", e);
    return null;
  }
}
项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the absolute distance between this value and the specified other
 * value.
 */
public float distanceTo(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE()) + Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA()) + Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's first component and the
 * specified other value's first component.
 */
public float distanceTo1(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:Push2Display    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's second component and the
 * specified other value's second component.
 */
public float distanceTo2(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
            return Math.abs(t1.getX() - t2.getX());
    }
    return 0f;
}
项目:feathers-sdk    文件:AnimatableTransformListValue.java   
/**
 * Returns the absolute distance between this value and the specified other
 * value.
 */
public float distanceTo(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE()) + Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA()) + Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:feathers-sdk    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's first component and the
 * specified other value's first component.
 */
public float distanceTo1(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getE() - m2.getE());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getA() - m2.getA());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
        case SVGTransform.SVG_TRANSFORM_SKEWX:
        case SVGTransform.SVG_TRANSFORM_SKEWY:
            return Math.abs(t1.getAngle() - t2.getAngle());
    }
    return 0f;
}
项目:feathers-sdk    文件:AnimatableTransformListValue.java   
/**
 * Returns the distance between this value's second component and the
 * specified other value's second component.
 */
public float distanceTo2(AnimatableValue other) {
    AnimatableTransformListValue o = (AnimatableTransformListValue) other;
    if (transforms.isEmpty() || o.transforms.isEmpty()) {
        return 0f;
    }
    AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
    AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
    short type1 = t1.getType();
    if (type1 != t2.getType()) {
        return 0f;
    }
    SVGMatrix m1 = t1.getMatrix();
    SVGMatrix m2 = t2.getMatrix();
    switch (type1) {
        case SVGTransform.SVG_TRANSFORM_TRANSLATE:
            return Math.abs(m1.getF() - m2.getF());
        case SVGTransform.SVG_TRANSFORM_SCALE:
            return Math.abs(m1.getD() - m2.getD());
        case SVGTransform.SVG_TRANSFORM_ROTATE:
            return Math.abs(t1.getX() - t2.getX());
    }
    return 0f;
}
项目:visual-programming    文件:SvgObject.java   
public Rectangle2D.Float getBorderScreenPosition() {
    Rectangle2D.Float rect = getBorder();
    SVGElement eleBorder = getElement(SvgElementType.Border);

    SVGMatrix matrix = ((SVGLocatable) eleBorder).getScreenCTM();
    SVGPoint leftTopCoordinatePoint = new SVGOMPoint(rect.x, rect.y);
    SVGPoint leftTopScreenPoint = leftTopCoordinatePoint
            .matrixTransform(matrix);

    SVGPoint rightBottomCoordinatePoint = new SVGOMPoint(rect.x
            + rect.width, rect.y + rect.height);
    SVGPoint rightBottomScreenPoint = rightBottomCoordinatePoint
            .matrixTransform(matrix);

    Rectangle2D.Float result = new Rectangle2D.Float(
            leftTopScreenPoint.getX(), leftTopScreenPoint.getY(),
            rightBottomScreenPoint.getX() - leftTopScreenPoint.getX(),
            rightBottomScreenPoint.getY() - leftTopScreenPoint.getY());

    return result;
}
项目:visual-programming    文件:SvgTransformBox.java   
public void setScreenRect(Rectangle2D.Float rect) {
    this.screenRect = rect;

    SVGMatrix matrix = objectElement.getScreenCTM();

    SVGPoint leftTopScreenPoint = new SVGOMPoint(rect.x, rect.y);
    SVGPoint leftTopCoorindatePoint = leftTopScreenPoint
            .matrixTransform(matrix.inverse());

    SVGPoint rightBottomScreenPoint = new SVGOMPoint(rect.x + rect.width,
            rect.y + rect.height);
    SVGPoint rightBottomCoorindatePoint = rightBottomScreenPoint
            .matrixTransform(matrix.inverse());

    Rectangle2D.Float coordinateRect = new Rectangle2D.Float(
            leftTopCoorindatePoint.getX(), leftTopCoorindatePoint.getY(),
            rightBottomCoorindatePoint.getX()
                    - leftTopCoorindatePoint.getX(),
            rightBottomCoorindatePoint.getY()
                    - leftTopCoorindatePoint.getY());

    setCoordinateRectangle("", coordinateRect);

}
项目:visual-programming    文件:SVGMainWindow.java   
private Field addChildObjectToTree(_Object obj) {

        // add to tree
        // int index = obj.getOwner().getChildIndex(obj);
        Field f = obj.getOwnerField();

        Element background = diagramPanel.getScene().getDocument()
                .getElementById("background");
        SVGMatrix mat = ((SVGLocatable) background).getScreenCTM();
        Point screenPosition = diagramPanel.getPopupMenuPosition();

        SVGOMPoint elePosition = SVGUtils.screenToElement(mat, screenPosition);

        float startX = elePosition.getX() / ( f.svgScale);
        float startY =elePosition.getY() / ( f.svgScale); 
        f.setStartPosition(startX, startY);

        treeModel.insertNodeInto(new DefaultMutableTreeNode(f),
                getSelectedTreeNode(), getSelectedTreeNode().getChildCount());

        reloadDiagram();
        return f;
    }
项目:Push2Display    文件:SVGOMTransform.java   
/**
 * Creates a new, modifiable SVGMatrix.
 */
protected SVGMatrix createMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform getAffineTransform() {
            return SVGOMTransform.this.affineTransform;
        }
        public void setA(float a) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setA(a);
        }
        public void setB(float b) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setB(b);
        }
        public void setC(float c) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setC(c);
        }
        public void setD(float d) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setD(d);
        }
        public void setE(float e) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setE(e);
        }
        public void setF(float f) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setF(f);
        }
    };
}
项目:Push2Display    文件:SVGOMPoint.java   
/**
 * Transforms an {@link SVGPoint} by an {@link SVGMatrix} and returns
 * the new point.
 */
public static SVGPoint matrixTransform(SVGPoint point, SVGMatrix matrix) {
    float newX = matrix.getA() * point.getX() + matrix.getC() * point.getY()
        + matrix.getE();
    float newY = matrix.getB() * point.getX() + matrix.getD() * point.getY()
        + matrix.getF();
    return new SVGOMPoint(newX, newY);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#multiply(SVGMatrix)}.
 */
public SVGMatrix multiply(SVGMatrix secondMatrix) {
    AffineTransform at = new AffineTransform(secondMatrix.getA(),
                                             secondMatrix.getB(),
                                             secondMatrix.getC(),
                                             secondMatrix.getD(),
                                             secondMatrix.getE(),
                                             secondMatrix.getF());
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate(at);
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#inverse()}.
 */
public SVGMatrix inverse() throws SVGException {
    try {
        return new SVGOMMatrix(getAffineTransform().createInverse());
    } catch (NoninvertibleTransformException e) {
        throw new SVGOMException(SVGException.SVG_MATRIX_NOT_INVERTABLE,
                                 e.getMessage());
    }
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#rotateFromVector(float,float)}.
 */
public SVGMatrix rotateFromVector(float x, float y) throws SVGException {
    if (x == 0 || y == 0) {
        throw new SVGOMException(SVGException.SVG_INVALID_VALUE_ERR, "");
    }
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.rotate(Math.atan2(y, x));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#skewX(float)}.
 */
public SVGMatrix skewX(float angleDeg) {
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate
        (AffineTransform.getShearInstance( Math.tan( Math.toRadians( angleDeg )), 0));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#skewY(float)}.
 */
public SVGMatrix skewY(float angleDeg ) {
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate
        (AffineTransform.getShearInstance(0,  Math.tan( Math.toRadians( angleDeg ) ) ));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGTransformList.java   
/**
 * Creates the {@link SVGMatrix} used to store the transform.
 */
protected SVGMatrix createMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform getAffineTransform() {
            return SVGTransformItem.this.affineTransform;
        }
        public void setA(float a) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setA(a);
            SVGTransformItem.this.resetAttribute();
        }
        public void setB(float b) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setB(b);
            SVGTransformItem.this.resetAttribute();
        }
        public void setC(float c) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setC(c);
            SVGTransformItem.this.resetAttribute();
        }
        public void setD(float d) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setD(d);
            SVGTransformItem.this.resetAttribute();
        }
        public void setE(float e) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setE(e);
            SVGTransformItem.this.resetAttribute();
        }
        public void setF(float f) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setF(f);
            SVGTransformItem.this.resetAttribute();
        }
    };
}
项目:Push2Display    文件:AbstractSVGTransform.java   
/**
 * <b>DOM</b>: Implements {@link SVGTransform#setMatrix(SVGMatrix)}.
 */
public void setMatrix(SVGMatrix matrix) {
    type = SVG_TRANSFORM_MATRIX;
    affineTransform =
        new AffineTransform(matrix.getA(), matrix.getB(), matrix.getC(),
                            matrix.getD(), matrix.getE(), matrix.getF());
}
项目:Push2Display    文件:SVGOMSVGElement.java   
/**
 * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGMatrix()}.
 */
public SVGMatrix createSVGMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform at = new AffineTransform();
        protected AffineTransform getAffineTransform() {
            return at;
        }
    };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link org.w3c.dom.svg.SVGLocatable#getCTM()}.
 */
public static SVGMatrix getCTM(Element elt) {
    final SVGOMElement svgelt = (SVGOMElement)elt;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                return svgelt.getSVGContext().getCTM();
        }
    };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
 */
public static SVGMatrix getScreenCTM(Element elt) {
    final SVGOMElement svgelt  = (SVGOMElement)elt;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                SVGContext context = svgelt.getSVGContext();
                AffineTransform ret = context.getGlobalTransform();
                AffineTransform scrnTrans = context.getScreenTransform();
                if (scrnTrans != null)
                    ret.preConcatenate(scrnTrans);
                return ret;
            }
        };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link
 * org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
 */
public static SVGMatrix getTransformToElement(Element elt,
                                              SVGElement element)
    throws SVGException {
    final SVGOMElement currentElt = (SVGOMElement)elt;
    final SVGOMElement targetElt = (SVGOMElement)element;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                AffineTransform cat = 
                    currentElt.getSVGContext().getGlobalTransform();
                if (cat == null) {
                    cat = new AffineTransform();
                }
                AffineTransform tat = 
                    targetElt.getSVGContext().getGlobalTransform();
                if (tat == null) {
                    tat = new AffineTransform();
                }
                AffineTransform at = new AffineTransform(cat);
                try {
                    at.preConcatenate(tat.createInverse());
                    return at;
                } catch (NoninvertibleTransformException ex) {
                    throw currentElt.createSVGException
                        (SVGException.SVG_MATRIX_NOT_INVERTABLE,
                         "noninvertiblematrix",
                         null);
                }
            }
        };
}
项目:Push2Display    文件:SVGOMTransform.java   
/**
 * Creates a new, modifiable SVGMatrix.
 */
protected SVGMatrix createMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform getAffineTransform() {
            return SVGOMTransform.this.affineTransform;
        }
        public void setA(float a) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setA(a);
        }
        public void setB(float b) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setB(b);
        }
        public void setC(float c) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setC(c);
        }
        public void setD(float d) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setD(d);
        }
        public void setE(float e) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setE(e);
        }
        public void setF(float f) throws DOMException {
            SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
            super.setF(f);
        }
    };
}
项目:Push2Display    文件:SVGOMPoint.java   
/**
 * Transforms an {@link SVGPoint} by an {@link SVGMatrix} and returns
 * the new point.
 */
public static SVGPoint matrixTransform(SVGPoint point, SVGMatrix matrix) {
    float newX = matrix.getA() * point.getX() + matrix.getC() * point.getY()
        + matrix.getE();
    float newY = matrix.getB() * point.getX() + matrix.getD() * point.getY()
        + matrix.getF();
    return new SVGOMPoint(newX, newY);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#multiply(SVGMatrix)}.
 */
public SVGMatrix multiply(SVGMatrix secondMatrix) {
    AffineTransform at = new AffineTransform(secondMatrix.getA(),
                                             secondMatrix.getB(),
                                             secondMatrix.getC(),
                                             secondMatrix.getD(),
                                             secondMatrix.getE(),
                                             secondMatrix.getF());
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate(at);
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#inverse()}.
 */
public SVGMatrix inverse() throws SVGException {
    try {
        return new SVGOMMatrix(getAffineTransform().createInverse());
    } catch (NoninvertibleTransformException e) {
        throw new SVGOMException(SVGException.SVG_MATRIX_NOT_INVERTABLE,
                                 e.getMessage());
    }
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#rotateFromVector(float,float)}.
 */
public SVGMatrix rotateFromVector(float x, float y) throws SVGException {
    if (x == 0 || y == 0) {
        throw new SVGOMException(SVGException.SVG_INVALID_VALUE_ERR, "");
    }
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.rotate(Math.atan2(y, x));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#skewX(float)}.
 */
public SVGMatrix skewX(float angleDeg) {
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate
        (AffineTransform.getShearInstance( Math.tan( Math.toRadians( angleDeg )), 0));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGMatrix.java   
/**
 * Implements {@link SVGMatrix#skewY(float)}.
 */
public SVGMatrix skewY(float angleDeg ) {
    AffineTransform tr = (AffineTransform)getAffineTransform().clone();
    tr.concatenate
        (AffineTransform.getShearInstance(0,  Math.tan( Math.toRadians( angleDeg ) ) ));
    return new SVGOMMatrix(tr);
}
项目:Push2Display    文件:AbstractSVGTransformList.java   
/**
 * Creates the {@link SVGMatrix} used to store the transform.
 */
protected SVGMatrix createMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform getAffineTransform() {
            return SVGTransformItem.this.affineTransform;
        }
        public void setA(float a) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setA(a);
            SVGTransformItem.this.resetAttribute();
        }
        public void setB(float b) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setB(b);
            SVGTransformItem.this.resetAttribute();
        }
        public void setC(float c) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setC(c);
            SVGTransformItem.this.resetAttribute();
        }
        public void setD(float d) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setD(d);
            SVGTransformItem.this.resetAttribute();
        }
        public void setE(float e) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setE(e);
            SVGTransformItem.this.resetAttribute();
        }
        public void setF(float f) throws DOMException {
            SVGTransformItem.this.type = SVGTransform.SVG_TRANSFORM_MATRIX;
            super.setF(f);
            SVGTransformItem.this.resetAttribute();
        }
    };
}
项目:Push2Display    文件:AbstractSVGTransform.java   
/**
 * <b>DOM</b>: Implements {@link SVGTransform#setMatrix(SVGMatrix)}.
 */
public void setMatrix(SVGMatrix matrix) {
    type = SVG_TRANSFORM_MATRIX;
    affineTransform =
        new AffineTransform(matrix.getA(), matrix.getB(), matrix.getC(),
                            matrix.getD(), matrix.getE(), matrix.getF());
}
项目:Push2Display    文件:SVGOMSVGElement.java   
/**
 * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGMatrix()}.
 */
public SVGMatrix createSVGMatrix() {
    return new AbstractSVGMatrix() {
        protected AffineTransform at = new AffineTransform();
        protected AffineTransform getAffineTransform() {
            return at;
        }
    };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link org.w3c.dom.svg.SVGLocatable#getCTM()}.
 */
public static SVGMatrix getCTM(Element elt) {
    final SVGOMElement svgelt = (SVGOMElement)elt;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                return svgelt.getSVGContext().getCTM();
        }
    };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
 */
public static SVGMatrix getScreenCTM(Element elt) {
    final SVGOMElement svgelt  = (SVGOMElement)elt;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                SVGContext context = svgelt.getSVGContext();
                AffineTransform ret = context.getGlobalTransform();
                AffineTransform scrnTrans = context.getScreenTransform();
                if (scrnTrans != null)
                    ret.preConcatenate(scrnTrans);
                return ret;
            }
        };
}
项目:Push2Display    文件:SVGLocatableSupport.java   
/**
 * To implement {@link
 * org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
 */
public static SVGMatrix getTransformToElement(Element elt,
                                              SVGElement element)
    throws SVGException {
    final SVGOMElement currentElt = (SVGOMElement)elt;
    final SVGOMElement targetElt = (SVGOMElement)element;
    return new AbstractSVGMatrix() {
            protected AffineTransform getAffineTransform() {
                AffineTransform cat = 
                    currentElt.getSVGContext().getGlobalTransform();
                if (cat == null) {
                    cat = new AffineTransform();
                }
                AffineTransform tat = 
                    targetElt.getSVGContext().getGlobalTransform();
                if (tat == null) {
                    tat = new AffineTransform();
                }
                AffineTransform at = new AffineTransform(cat);
                try {
                    at.preConcatenate(tat.createInverse());
                    return at;
                } catch (NoninvertibleTransformException ex) {
                    throw currentElt.createSVGException
                        (SVGException.SVG_MATRIX_NOT_INVERTABLE,
                         "noninvertiblematrix",
                         null);
                }
            }
        };
}