gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.buffer / org.gvsig.raster.lib.buffer.impl / src / main / java / org / gvsig / raster / lib / buffer / impl / DefaultBufferDimensions.java @ 8800
History | View | Annotate | Download (3.36 KB)
1 | 6677 | fdiaz | /* gvSIG. Desktop Geographic Information System.
|
---|---|---|---|
2 | *
|
||
3 | * Copyright ? 2007-2017 gvSIG Association
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
18 | * MA 02110-1301, USA.
|
||
19 | *
|
||
20 | * For any additional information, do not hesitate to contact us
|
||
21 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
22 | */
|
||
23 | package org.gvsig.raster.lib.buffer.impl; |
||
24 | |||
25 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
26 | import org.gvsig.raster.lib.buffer.api.BufferDimensions; |
||
27 | |||
28 | |||
29 | /**
|
||
30 | * @author fdiaz
|
||
31 | *
|
||
32 | */
|
||
33 | public class DefaultBufferDimensions implements BufferDimensions { |
||
34 | |||
35 | protected int rows; |
||
36 | protected int columns; |
||
37 | protected Envelope envelope;
|
||
38 | private Double pixelSizeX = null; |
||
39 | private Double pixelSizeY = null; |
||
40 | |||
41 | /**
|
||
42 | * @param rows
|
||
43 | * @param columns
|
||
44 | * @param envelope
|
||
45 | */
|
||
46 | public DefaultBufferDimensions(int rows, int columns, Envelope envelope) { |
||
47 | this.rows = rows;
|
||
48 | this.columns = columns;
|
||
49 | this.envelope = envelope;
|
||
50 | } |
||
51 | |||
52 | /* (non-Javadoc)
|
||
53 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#getRows()
|
||
54 | */
|
||
55 | @Override
|
||
56 | public int getRows() { |
||
57 | return this.rows; |
||
58 | } |
||
59 | |||
60 | /* (non-Javadoc)
|
||
61 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#getColumns()
|
||
62 | */
|
||
63 | @Override
|
||
64 | public int getColumns() { |
||
65 | return this.columns; |
||
66 | } |
||
67 | |||
68 | /* (non-Javadoc)
|
||
69 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#getPixelSizeX()
|
||
70 | */
|
||
71 | @Override
|
||
72 | public double getPixelSizeX(){ |
||
73 | if(pixelSizeX == null){ |
||
74 | pixelSizeX = this.getEnvelope().getLength(0)/this.getColumns(); |
||
75 | } |
||
76 | return pixelSizeX.doubleValue();
|
||
77 | } |
||
78 | |||
79 | /* (non-Javadoc)
|
||
80 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#getPixelSizeY()
|
||
81 | */
|
||
82 | @Override
|
||
83 | public double getPixelSizeY(){ |
||
84 | if(pixelSizeY == null){ |
||
85 | pixelSizeY = this.getEnvelope().getLength(1)/this.getRows(); |
||
86 | } |
||
87 | return pixelSizeY.doubleValue();
|
||
88 | } |
||
89 | |||
90 | /* (non-Javadoc)
|
||
91 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#getEnvelope()
|
||
92 | */
|
||
93 | @Override
|
||
94 | public Envelope getEnvelope() {
|
||
95 | return this.envelope; |
||
96 | } |
||
97 | |||
98 | /* (non-Javadoc)
|
||
99 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#setRows(int)
|
||
100 | */
|
||
101 | @Override
|
||
102 | public void setRows(int rows) { |
||
103 | this.rows = rows;
|
||
104 | } |
||
105 | |||
106 | /* (non-Javadoc)
|
||
107 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#setColumns(int)
|
||
108 | */
|
||
109 | @Override
|
||
110 | public void setColumns(int columns) { |
||
111 | this.columns = columns;
|
||
112 | } |
||
113 | |||
114 | /* (non-Javadoc)
|
||
115 | * @see org.gvsig.raster.lib.buffer.api.BufferDimensions#setEnvelope(org.gvsig.fmap.geom.primitive.Envelope)
|
||
116 | */
|
||
117 | @Override
|
||
118 | public void setEnvelope(Envelope envelope) { |
||
119 | this.envelope = envelope;
|
||
120 | } |
||
121 | |||
122 | } |