svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / FirstStrategy.java @ 337
History | View | Annotate | Download (2.09 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.iver.cit.gvsig.fmap.ViewPort; |
11 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
12 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
13 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
14 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
15 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
16 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
17 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
18 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
19 |
/**
|
20 |
* 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
|
21 |
*/
|
22 |
public class FirstStrategy extends DefaultStrategy { |
23 |
|
24 |
/**
|
25 |
* @param capa
|
26 |
*/
|
27 |
public FirstStrategy(FLyrVect capa) {
|
28 |
super(capa);
|
29 |
} |
30 |
|
31 |
/**
|
32 |
* Dibuja metiendo en una estructura de datos para cada geometr?a que se dibuja
|
33 |
* su boundingbox y su tipo
|
34 |
*/
|
35 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) |
36 |
throws DriverIOException {
|
37 |
VectorialAdapter adapter = getCapa().getSource(); |
38 |
adapter.start(); |
39 |
|
40 |
VectorialFileDriver driver = (VectorialFileDriver) adapter.getDriver(); |
41 |
int sc;
|
42 |
long t1 = System.currentTimeMillis(); |
43 |
Rectangle2D extent = viewPort.getAdjustedExtent();
|
44 |
AffineTransform at = viewPort.getAffineTransform();
|
45 |
|
46 |
sc = adapter.getShapeCount(); |
47 |
ShapeInfo shapeinfo=StrategyManager.createShapeInfo(adapter); |
48 |
|
49 |
for (int i = 0; i < sc; i++) { |
50 |
if (cancel.isCanceled()) break; |
51 |
IGeometry geom = adapter.getShape(i); |
52 |
VectorialLegend l = getCapa().getLegend(); |
53 |
|
54 |
if (geom.intersects(extent)) {
|
55 |
FStyle2D symbol = l.getSymbol(i); |
56 |
geom.draw(g, viewPort, symbol); |
57 |
shapeinfo.addShapeInfo(geom.getBounds2D(),geom.getGeometryType()); |
58 |
} |
59 |
} |
60 |
|
61 |
long t2 = System.currentTimeMillis(); |
62 |
adapter.stop(); |
63 |
|
64 |
System.out.println(t2 - t1);
|
65 |
} |
66 |
} |