Revision 6049 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/Tiling.java
Tiling.java | ||
---|---|---|
26 | 26 |
*/ |
27 | 27 |
|
28 | 28 |
public class Tiling { |
29 |
boolean debug = true; |
|
30 |
int tileMaxWidth, tileMaxHeight; |
|
31 |
int numRows, numCols; |
|
32 |
double [][] srcPts; |
|
33 |
Rectangle [] tile; |
|
34 |
double width = 500, height = 500; |
|
35 |
AffineTransform mat; |
|
36 |
ViewPort vp; |
|
29 |
private static final int MIN_SIZE = 50; //Tama?o m?nimo en pixeles del tile |
|
30 |
private boolean debug = true; |
|
31 |
private int tileMaxWidth, tileMaxHeight; |
|
32 |
private int numRows, numCols; |
|
33 |
private double[][] srcPts; |
|
34 |
private Rectangle[] tile; |
|
35 |
private double width = 500, height = 500; |
|
36 |
private AffineTransform mat; |
|
37 |
private ViewPort vp; |
|
38 |
|
|
39 |
public Tiling(){} |
|
37 | 40 |
|
38 | 41 |
public Tiling(int tileW, int tileH, Rectangle r) { |
39 |
tileMaxWidth = tileW; |
|
40 |
tileMaxHeight = tileH; |
|
42 |
int[] size = this.calcMaxTileSize(tileW, tileH, r); |
|
43 |
tileMaxWidth = size[0]; |
|
44 |
tileMaxHeight = size[1]; |
|
41 | 45 |
|
42 | 46 |
int stepX, stepY; |
43 | 47 |
int xProv, yProv; |
44 | 48 |
int altoAux, anchoAux; |
45 | 49 |
|
46 |
// Vamos a hacerlo en trozos de AxH
|
|
50 |
//Vamos a hacerlo en trozos de AxH |
|
47 | 51 |
numCols = 1+(int) (r.width) / tileMaxWidth; |
48 | 52 |
numRows = 1+(int) (r.height) / tileMaxHeight; |
49 | 53 |
|
... | ... | |
84 | 88 |
} |
85 | 89 |
} |
86 | 90 |
|
91 |
/** |
|
92 |
* Calcula el tama?o m?ximo de tile controlando que ning?n tile tenga menos de MIN_SIZE |
|
93 |
* pixeles |
|
94 |
* @param tileW Ancho del tile |
|
95 |
* @param tileH Alto del tile |
|
96 |
* @param r Rectangulo que define el area de la imagen |
|
97 |
*/ |
|
98 |
public int[] calcMaxTileSize(int tileW, int tileH, Rectangle r){ |
|
99 |
if(r.width < tileW || r.height < tileH){ |
|
100 |
int[] sizeTiles = {tileW, tileH}; |
|
101 |
return sizeTiles; |
|
102 |
} |
|
103 |
|
|
104 |
int wLastCol = 0; |
|
105 |
tileW += MIN_SIZE; |
|
106 |
do{ |
|
107 |
tileW -= MIN_SIZE; |
|
108 |
int numCols = (int) (r.width / tileW); |
|
109 |
int w = 0; |
|
110 |
for(int i = 0; i < numCols; i++) |
|
111 |
w += tileW; |
|
112 |
wLastCol = r.width - w; |
|
113 |
}while(wLastCol < MIN_SIZE && tileW > (MIN_SIZE * 2)); |
|
114 |
|
|
115 |
int hLastRow = 0; |
|
116 |
tileH += MIN_SIZE; |
|
117 |
do{ |
|
118 |
tileH -= MIN_SIZE; |
|
119 |
int numRows = (int) (r.height / tileH); |
|
120 |
int h = 0; |
|
121 |
for(int i = 0; i < numRows; i++) |
|
122 |
h += tileH; |
|
123 |
hLastRow = r.height - h; |
|
124 |
}while(hLastRow < MIN_SIZE && tileH > (MIN_SIZE * 2)); |
|
125 |
|
|
126 |
tileMaxWidth = tileW; |
|
127 |
tileMaxHeight = tileH; |
|
128 |
int[] sizeTiles = {tileMaxWidth, tileMaxHeight}; |
|
129 |
return sizeTiles; |
|
130 |
} |
|
131 |
|
|
87 | 132 |
public double [] getTilePts(int colNr, int rowNr) { |
88 | 133 |
return srcPts[rowNr*numCols+colNr]; |
89 | 134 |
} |
Also available in: Unified diff