svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / numeric / AffineTransformFunction.java @ 43939
History | View | Annotate | Download (1.97 KB)
1 |
package org.gvsig.expressionevaluator.impl.function.numeric; |
---|---|
2 |
|
3 |
import java.awt.geom.AffineTransform; |
4 |
import org.apache.commons.lang3.Range; |
5 |
import org.gvsig.expressionevaluator.Interpreter; |
6 |
import org.gvsig.expressionevaluator.spi.AbstractFunction; |
7 |
|
8 |
public class AffineTransformFunction extends AbstractFunction { |
9 |
|
10 |
public AffineTransformFunction() {
|
11 |
super(
|
12 |
"Numeric",
|
13 |
"AffineTransform",
|
14 |
Range.between(0, 6), |
15 |
"With 0 parameters create an AffineTransform representing the Identity transformation\n" +
|
16 |
"With 6 parameters create an AffineTransform with the 6 specifiable entries of the 3x3 transformation matrix.\n" +
|
17 |
"- m00 the X coordinate scaling element of the 3x3 matrix\n" +
|
18 |
"- m10 the Y coordinate shearing element of the 3x3 matrix\n" +
|
19 |
"- m01 the X coordinate shearing element of the 3x3 matrix\n" +
|
20 |
"- m11 the Y coordinate scaling element of the 3x3 matrix\n" +
|
21 |
"- m02 the X coordinate translation element of the 3x3 matrix\n" +
|
22 |
"- m12 the Y coordinate translation element of the 3x3 matrix",
|
23 |
"AffineTransform( m00, m10, m01, m11, m02, m12 )"
|
24 |
); |
25 |
} |
26 |
|
27 |
@Override
|
28 |
public Object call(Interpreter interpreter, Object[] args) { |
29 |
AffineTransform at;
|
30 |
switch(args.length) {
|
31 |
case 0: |
32 |
at = new AffineTransform(); |
33 |
return at;
|
34 |
case 6: |
35 |
double m00 = getDouble(args, 0); |
36 |
double m10 = getDouble(args, 0); |
37 |
double m01 = getDouble(args, 0); |
38 |
double m11 = getDouble(args, 0); |
39 |
double m02 = getDouble(args, 0); |
40 |
double m12 = getDouble(args, 0); |
41 |
at = new AffineTransform(m00, m10, m01, m11, m02, m12); |
42 |
return at;
|
43 |
default:
|
44 |
throw new IllegalArgumentException("The AffinaTransform function requires 0 or 6 parameters."); |
45 |
} |
46 |
} |
47 |
} |