root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / FirstStrategy.java @ 470
History | View | Annotate | Download (2.46 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 |
|
10 |
import com.hardcode.driverManager.DriverLoadException; |
11 |
import com.hardcode.gdbms.engine.data.DataSource; |
12 |
import com.hardcode.gdbms.engine.data.DriverException; |
13 |
import com.iver.cit.gvsig.fmap.ViewPort; |
14 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
15 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
16 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
17 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
18 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
19 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
20 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
21 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
22 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
23 |
/**
|
24 |
* Estrategia empleada para las capas vectoriales, que dibuja y guarda en un fichero el bounding box de cada shape junto con su tipo. No se deber? de dibujar dos veces un adaptador con esta estrateg?a
|
25 |
*/
|
26 |
public class FirstStrategy extends DefaultStrategy { |
27 |
|
28 |
/**
|
29 |
* @param capa
|
30 |
*/
|
31 |
public FirstStrategy(FLyrVect capa) {
|
32 |
super(capa);
|
33 |
} |
34 |
|
35 |
/**
|
36 |
* Dibuja metiendo en una estructura de datos para cada geometr?a que se dibuja
|
37 |
* su boundingbox y su tipo
|
38 |
* @throws DriverLoadException
|
39 |
* @throws DriverException
|
40 |
*/
|
41 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) |
42 |
throws DriverIOException, DriverLoadException, DriverException {
|
43 |
VectorialAdapter adapter = getCapa().getSource(); |
44 |
DataSource ds = getCapa().getRecordset();
|
45 |
ds.start(); |
46 |
adapter.start(); |
47 |
|
48 |
VectorialFileDriver driver = (VectorialFileDriver) adapter.getDriver(); |
49 |
int sc;
|
50 |
long t1 = System.currentTimeMillis(); |
51 |
Rectangle2D extent = viewPort.getAdjustedExtent();
|
52 |
AffineTransform at = viewPort.getAffineTransform();
|
53 |
|
54 |
sc = adapter.getShapeCount(); |
55 |
ShapeInfo shapeinfo=StrategyManager.createShapeInfo(adapter); |
56 |
|
57 |
for (int i = 0; i < sc; i++) { |
58 |
if (cancel.isCanceled()) break; |
59 |
IGeometry geom = adapter.getShape(i); |
60 |
VectorialLegend l = getCapa().getLegend(); |
61 |
|
62 |
if (geom.intersects(extent)) {
|
63 |
FSymbol symbol = l.getSymbol(i); |
64 |
geom.draw(g, viewPort, symbol); |
65 |
shapeinfo.addShapeInfo(geom.getBounds2D(),geom.getGeometryType()); |
66 |
} |
67 |
} |
68 |
|
69 |
long t2 = System.currentTimeMillis(); |
70 |
adapter.stop(); |
71 |
ds.stop(); |
72 |
|
73 |
System.out.println(t2 - t1);
|
74 |
} |
75 |
} |