Author: desruisseaux
Date: Fri Jun 27 18:37:30 2014
New Revision: 1606175
URL: http://svn.apache.org/r1606175
Log:
Merge from the JDK8 branch.
Added:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
- copied unchanged from r1606173,
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
Merged /sis/branches/JDK8:r1606120-1606173
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1606175&r1=1606174&r2=1606175&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] Fri Jun 27 18:37:30 2014
@@ -951,7 +951,7 @@ public abstract class AbstractMathTransf
* @see AbstractMathTransform2D#beforeFormat(List, int, boolean)
* @see ConcatenatedTransform#getPseudoSteps()
*/
- int beforeFormat(List<MathTransform> transforms, int index, boolean
inverse) {
+ int beforeFormat(List<Object> transforms, int index, boolean inverse) {
return index;
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java?rev=1606175&r1=1606174&r2=1606175&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
[UTF-8] Fri Jun 27 18:37:30 2014
@@ -26,7 +26,6 @@ import java.awt.geom.PathIterator;
import java.awt.geom.AffineTransform;
import java.awt.geom.IllegalPathStateException;
import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.NoninvertibleTransformException;
@@ -340,11 +339,52 @@ public abstract class AbstractMathTransf
}
/**
+ * Transforms the specified {@code ptSrc} and stores the result in
{@code ptDst}.
+ * The default implementation invokes {@link #transform(double[], int,
double[], int, boolean)}
+ * using a temporary array of doubles.
+ *
+ * @param ptSrc The coordinate point to be transformed.
+ * @param ptDst The coordinate point that stores the result of
transforming {@code ptSrc},
+ * or {@code null} if a new point shall be created.
+ * @return The coordinate point after transforming {@code ptSrc} and
storing the result in {@code ptDst},
+ * or in a new point if {@code ptDst} was null.
+ * @throws TransformException If the point can not be transformed.
+ *
+ * @see MathTransform2D#transform(Point2D, Point2D)
+ */
+ @Override
+ public Point2D transform(final Point2D ptSrc, final Point2D ptDst)
throws TransformException {
+ final double[] ord = new double[] {ptSrc.getX(), ptSrc.getY()};
+ transform(ord, 0, ord, 0, false);
+ if (ptDst != null) {
+ ptDst.setLocation(ord[0], ord[1]);
+ return ptDst;
+ } else {
+ return new Point2D.Double(ord[0], ord[1]);
+ }
+ }
+
+ /**
+ * Transforms the specified shape. The default implementation computes
quadratic curves
+ * using three points for each line segment in the shape. The returned
object is often
+ * a {@link Path2D}, but may also be a {@link Line2D} or a {@link
QuadCurve2D} if such
+ * simplification is possible.
+ *
+ * @param shape Shape to transform.
+ * @return Transformed shape, or {@code shape} if this transform is
the identity transform.
+ * @throws TransformException if a transform failed.
+ */
+ @Override
+ public Shape createTransformedShape(final Shape shape) throws
TransformException {
+ return isIdentity() ? shape :
AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false);
+ }
+
+ /**
* Same work than {@link AbstractMathTransform2D#beforeFormat(List,
int, boolean)}
* but with the knowledge that this transform is an inverse transform.
*/
@Override
- final int beforeFormat(final List<MathTransform> transforms, final int
index, final boolean inverse) {
+ final int beforeFormat(final List<Object> transforms, final int index,
final boolean inverse) {
return AbstractMathTransform2D.this.beforeFormat(transforms,
index, !inverse);
}
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1606175&r1=1606174&r2=1606175&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
[UTF-8] Fri Jun 27 18:37:30 2014
@@ -38,6 +38,7 @@ import org.apache.sis.util.ComparisonMod
import org.apache.sis.util.Utilities;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.util.resources.Errors;
@@ -409,11 +410,11 @@ class ConcatenatedTransform extends Abst
* (<var>normalize</var>, <var>unitary projection</var>,
<var>denormalize</var>) tuples are replaced by single
* (<var>projection</var>) elements, which does not need to be instances
of {@link MathTransform}.
*/
- private List<MathTransform> getPseudoSteps() {
- final List<MathTransform> transforms = new ArrayList<>();
+ private List<Object> getPseudoSteps() {
+ final List<Object> transforms = new ArrayList<>();
getSteps(transforms);
/*
- * Pre-process the transforms before to format. Some steps may be*
merged, or new
+ * Pre-process the transforms before to format. Some steps may be
merged, or new
* steps may be created. Do not move size() out of the loop, because
it may change.
*/
for (int i=0; i<transforms.size(); i++) {
@@ -430,7 +431,7 @@ class ConcatenatedTransform extends Abst
*
* @param transforms The list where to add concatenated transforms.
*/
- private void getSteps(final List<MathTransform> transforms) {
+ private void getSteps(final List<? super MathTransform> transforms) {
if (transform1 instanceof ConcatenatedTransform) {
((ConcatenatedTransform) transform1).getSteps(transforms);
} else {
@@ -468,7 +469,7 @@ class ConcatenatedTransform extends Abst
*/
private Parameterized getParameterised() {
Parameterized param = null;
- final List<MathTransform> transforms = getPseudoSteps();
+ final List<Object> transforms = getPseudoSteps();
if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
for (final Object candidate : transforms) {
if (!(candidate instanceof Parameterized)) {
@@ -888,7 +889,7 @@ class ConcatenatedTransform extends Abst
*/
@Override
public String formatTo(final Formatter formatter) {
- final List<MathTransform> transforms;
+ final List<? super MathTransform> transforms;
if (formatter.getConvention() == Convention.INTERNAL) {
transforms = getSteps();
} else {
@@ -902,9 +903,13 @@ class ConcatenatedTransform extends Abst
if (transforms.size() == 1) {
return formatter.delegateTo(transforms.get(0));
}
- for (final MathTransform step : transforms) {
+ for (final Object step : transforms) {
formatter.newLine();
- formatter.append(step);
+ if (step instanceof FormattableObject) {
+ formatter.append((FormattableObject) step); // May not
implement MathTransform.
+ } else {
+ formatter.append((MathTransform) step);
+ }
}
return "Concat_MT";
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PassThroughTransform.java?rev=1606175&r1=1606174&r2=1606175&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
[UTF-8] Fri Jun 27 18:37:30 2014
@@ -85,7 +85,7 @@ public class PassThroughTransform extend
* The sub-transform to apply on the {@linkplain #getModifiedCoordinates()
modified coordinates}.
* This is often the sub-transform specified at construction time, but not
necessarily.
*/
- protected final MathTransform subTransform;
+ final MathTransform subTransform;
/**
* The inverse transform. This field will be computed only when needed,
@@ -275,6 +275,16 @@ public class PassThroughTransform extend
}
/**
+ * Returns the sub-transform to apply on the {@linkplain
#getModifiedCoordinates() modified coordinates}.
+ * This is often the sub-transform specified at construction time, but not
necessarily.
+ *
+ * @return The sub-transform.
+ */
+ public final MathTransform getSubTransform() {
+ return subTransform;
+ }
+
+ /**
* Tests whether this transform does not move any points. A {@code
PassThroughTransform}
* is identity if the {@linkplain #subTransform sub-transform} is also
identity.
*
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1606175&r1=1606174&r2=1606175&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Jun 27 18:37:30 2014
@@ -48,6 +48,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.transform.ExponentialTransform1DTest.class,
org.apache.sis.referencing.operation.transform.CopyTransformTest.class,
org.apache.sis.referencing.operation.transform.PassThroughTransformTest.class,
+
org.apache.sis.referencing.operation.transform.ConcatenatedTransformTest.class,
org.apache.sis.referencing.operation.transform.TransferFunctionTest.class,
org.apache.sis.internal.referencing.FormulasTest.class,