001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.dom.svg;
020:
021: import org.w3c.dom.DOMException;
022: import org.w3c.dom.svg.SVGMatrix;
023: import org.w3c.dom.svg.SVGPoint;
024:
025: /**
026: * An implementation of {@link SVGPoint} that is not associated with any
027: * attribute.
028: *
029: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
030: * @version $Id: SVGOMPoint.java 475477 2006-11-15 22:44:28Z cam $
031: */
032: public class SVGOMPoint implements SVGPoint {
033:
034: /**
035: * The x coordinate.
036: */
037: protected float x;
038:
039: /**
040: * The y coordinate.
041: */
042: protected float y;
043:
044: /**
045: * Creates a new SVGOMPoint with coordinates set to <code>0</code>.
046: */
047: public SVGOMPoint() {
048: }
049:
050: /**
051: * Creates a new SVGOMPoint with coordinates set to the specified values.
052: */
053: public SVGOMPoint(float x, float y) {
054: this .x = x;
055: this .y = y;
056: }
057:
058: /**
059: * <b>DOM</b>: Implements {@link SVGPoint#getX()}.
060: */
061: public float getX() {
062: return x;
063: }
064:
065: /**
066: * <b>DOM</b>: Implements {@link SVGPoint#setX(float)}.
067: */
068: public void setX(float x) throws DOMException {
069: this .x = x;
070: }
071:
072: /**
073: * <b>DOM</b>: Implements {@link SVGPoint#getY()}.
074: */
075: public float getY() {
076: return y;
077: }
078:
079: /**
080: * <b>DOM</b>: Implements {@link SVGPoint#setY(float)}.
081: */
082: public void setY(float y) throws DOMException {
083: this .y = y;
084: }
085:
086: /**
087: * <b>DOM</b>: Implements {@link SVGPoint#matrixTransform(SVGMatrix)}.
088: */
089: public SVGPoint matrixTransform(SVGMatrix matrix) {
090: return matrixTransform(this , matrix);
091: }
092:
093: /**
094: * Transforms an {@link SVGPoint} by an {@link SVGMatrix} and returns
095: * the new point.
096: */
097: public static SVGPoint matrixTransform(SVGPoint point,
098: SVGMatrix matrix) {
099: float newX = matrix.getA() * point.getX() + matrix.getC()
100: * point.getY() + matrix.getE();
101: float newY = matrix.getB() * point.getX() + matrix.getD()
102: * point.getY() + matrix.getF();
103: return new SVGOMPoint(newX, newY);
104: }
105: }
|