root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / ShpStrategy.java @ 228
History | View | Annotate | Download (2.04 KB)
1 |
/* Generated by Together */
|
---|---|
2 |
|
3 |
package com.iver.cit.gvsig.fmap.operations.strategies; |
4 |
|
5 |
import java.awt.Graphics2D; |
6 |
import java.awt.geom.AffineTransform; |
7 |
import java.awt.geom.Rectangle2D; |
8 |
import java.awt.image.BufferedImage; |
9 |
import java.io.IOException; |
10 |
|
11 |
import com.iver.cit.gvsig.fmap.ViewPort; |
12 |
import com.iver.cit.gvsig.fmap.core.FGeometry; |
13 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
14 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
15 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
16 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
17 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
18 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
19 |
|
20 |
|
21 |
/**
|
22 |
* Esta clase definir? las operaciones de la interfaz FLyrVect de la manera m?s ?ptima para los ficheros shp.
|
23 |
*/
|
24 |
public class ShpStrategy extends DefaultStrategy { |
25 |
|
26 |
/**
|
27 |
* @param capa
|
28 |
*/
|
29 |
public ShpStrategy(FLyrVect capa) {
|
30 |
super(capa);
|
31 |
} |
32 |
/**
|
33 |
* @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
|
34 |
*/
|
35 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort) |
36 |
throws DriverIOException {
|
37 |
VectorialAdapter adapter = getCapa().getSource(); |
38 |
BoundedShapes shapeBounds = (BoundedShapes) adapter.getDriver(); |
39 |
VectorialFileDriver driver = (VectorialFileDriver) adapter.getDriver(); |
40 |
|
41 |
adapter.start(); |
42 |
|
43 |
FGeometry geom = adapter.getShape(0);
|
44 |
Legend l = getCapa().getLegend(geom.getType()); |
45 |
Rectangle2D extent = viewPort.getAdjustedExtent();
|
46 |
AffineTransform at = viewPort.getAffineTransform();
|
47 |
|
48 |
int sc;
|
49 |
|
50 |
Rectangle2D bounds;
|
51 |
|
52 |
sc = adapter.getShapeCount(); |
53 |
long t1 = System.currentTimeMillis(); |
54 |
|
55 |
for (int i = 0; i < sc; i++){ |
56 |
try {
|
57 |
bounds = shapeBounds.getShapeBounds(i); |
58 |
if (extent.intersects(bounds)){
|
59 |
geom = driver.getShape(i); |
60 |
geom.draw(image, g, extent, at, null);
|
61 |
} |
62 |
} catch(IOException e) { |
63 |
throw new DriverIOException(e); |
64 |
} |
65 |
} |
66 |
|
67 |
|
68 |
long t2 = System.currentTimeMillis(); |
69 |
adapter.stop(); |
70 |
|
71 |
System.out.println(t2 - t1);
|
72 |
} |
73 |
} |