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 / image / ImageWidthFunction.java @ 44376
History | View | Annotate | Download (996 Bytes)
1 | 44126 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.image; |
---|---|---|---|
2 | 43512 | jjdelcerro | |
3 | import org.apache.commons.lang3.Range; |
||
4 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Interpreter; |
5 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.spi.AbstractFunction; |
6 | |||
7 | 44126 | jjdelcerro | public class ImageWidthFunction extends AbstractFunction { |
8 | 43512 | jjdelcerro | |
9 | 44126 | jjdelcerro | public ImageWidthFunction() {
|
10 | 43512 | jjdelcerro | super(
|
11 | 44126 | jjdelcerro | "Image", "IMAGEWIDTH", Range.is(1), |
12 | "",
|
||
13 | "IMAGEWIDTH({{source}})",
|
||
14 | new String[]{ |
||
15 | "Value from which to load the image"
|
||
16 | }, |
||
17 | "Integer",
|
||
18 | false
|
||
19 | 43512 | jjdelcerro | ); |
20 | } |
||
21 | |||
22 | @Override
|
||
23 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
24 | return true; |
||
25 | } |
||
26 | 44126 | jjdelcerro | |
27 | 44009 | jjdelcerro | @Override
|
28 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) { |
29 | 44126 | jjdelcerro | Object arg0 = this.getObject(args, 0); |
30 | SimpleImage image = ImageReadFunction.createSimpleImage(arg0); |
||
31 | if( image.isEmpty() ) {
|
||
32 | return null; |
||
33 | } |
||
34 | return image.getWidth();
|
||
35 | 43512 | jjdelcerro | } |
36 | } |