Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java
FLyrVect.java | ||
---|---|---|
50 | 50 |
import java.io.File; |
51 | 51 |
import java.io.IOException; |
52 | 52 |
|
53 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
54 |
|
|
53 | 55 |
import org.apache.log4j.Logger; |
54 | 56 |
import org.cresques.cts.ICoordTrans; |
55 | 57 |
|
56 |
import com.hardcode.driverManager.Driver; |
|
57 | 58 |
import com.hardcode.driverManager.DriverLoadException; |
58 | 59 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
59 | 60 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
60 | 61 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
61 | 62 |
import com.iver.cit.gvsig.fmap.DriverException; |
63 |
import com.iver.cit.gvsig.fmap.DriverNotLoadedExceptionType; |
|
62 | 64 |
import com.iver.cit.gvsig.fmap.ViewPort; |
63 | 65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
66 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
|
64 | 67 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
65 | 68 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
66 | 69 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
... | ... | |
89 | 92 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
90 | 93 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager; |
91 | 94 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
95 |
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo; |
|
92 | 96 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
93 | 97 |
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
94 | 98 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
... | ... | |
143 | 147 |
private boolean bHasJoin = false; |
144 | 148 |
|
145 | 149 |
private XMLEntity orgXMLEntity = null; |
146 |
|
|
150 |
|
|
147 | 151 |
private XMLEntity loadSelection = null; |
148 | 152 |
private VectorialLegend loadLegend = null; |
149 |
|
|
150 | 153 |
|
154 |
|
|
151 | 155 |
/** |
152 | 156 |
* A?ade un SelectionListener a la lista de listeners. |
153 | 157 |
* |
... | ... | |
301 | 305 |
public Rectangle2D getFullExtent() throws DriverException { |
302 | 306 |
try { |
303 | 307 |
Rectangle2D rAux; |
304 |
logger.debug(getName() + "_source.start()"); |
|
308 |
// logger.debug(getName() + "_source.start()");
|
|
305 | 309 |
source.start(); |
306 | 310 |
rAux = (Rectangle2D)source.getFullExtent().clone(); |
307 |
logger.debug(getName() + "_source.stop()"); |
|
311 |
// logger.debug(getName() + "_source.stop()");
|
|
308 | 312 |
source.stop(); |
309 | 313 |
|
310 | 314 |
// Si existe reproyecci?n, reproyectar el extent |
... | ... | |
332 | 336 |
|
333 | 337 |
/** |
334 | 338 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, |
335 |
* java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
|
|
339 |
* java.awt.Graphics2D, ISymbol)
|
|
336 | 340 |
*/ |
337 | 341 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
338 | 342 |
Cancellable cancel, double scale) throws DriverException { |
... | ... | |
383 | 387 |
* com.iver.utiles.swing.threads.Cancellable) |
384 | 388 |
*/ |
385 | 389 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
386 |
double scale) throws DriverException { |
|
390 |
double scale, PrintRequestAttributeSet properties) throws DriverException {
|
|
387 | 391 |
if (isVisible() && isWithinScale(scale)) { |
388 | 392 |
Strategy strategy = StrategyManager.getStrategy(this); |
389 | 393 |
|
390 |
strategy.print(g, viewPort, cancel); |
|
394 |
strategy.print(g, viewPort, cancel, properties);
|
|
391 | 395 |
|
392 | 396 |
if (getLayerText() != null) { |
393 | 397 |
getLayerText().draw(null, g, viewPort, cancel, scale); |
... | ... | |
611 | 615 |
return s.queryByShape(g, relationship); |
612 | 616 |
} |
613 | 617 |
|
614 |
public XMLItem[] getInfo(Point p, double tolerance) throws DriverException { |
|
618 |
public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) throws DriverException {
|
|
615 | 619 |
Point2D pReal = this.getMapContext().getViewPort().toMapPoint(p); |
616 | 620 |
FBitSet bs = queryByPoint(pReal, tolerance); |
617 | 621 |
VectorialXMLItem[] item = new VectorialXMLItem[1]; |
... | ... | |
707 | 711 |
public int getShapeType() throws DriverException { |
708 | 712 |
if (typeShape == -1) { |
709 | 713 |
try { |
710 |
logger.debug("source.start()"); |
|
714 |
// logger.debug("source.start()");
|
|
711 | 715 |
getSource().start(); |
712 | 716 |
typeShape = getSource().getShapeType(); |
713 |
logger.debug("source.stop()"); |
|
717 |
// logger.debug("source.stop()");
|
|
714 | 718 |
getSource().stop(); |
715 | 719 |
} catch (DriverIOException e) { |
716 | 720 |
throw new DriverException(e); |
... | ... | |
890 | 894 |
PostProcessSupport.addToPostProcess(this, "setLegend", leg, 1); |
891 | 895 |
} else { |
892 | 896 |
/* |
893 |
JMVIVO
|
|
897 |
JMVIVO |
|
894 | 898 |
this.setLoadLegend(leg); |
895 | 899 |
*/ |
896 | 900 |
try { |
... | ... | |
923 | 927 |
VectorialLegend leg = LegendFactory.createFromXML(xml.getChild(0)); |
924 | 928 |
try { |
925 | 929 |
getRecordset().getSelectionSupport().setXMLEntity(xml.getChild(1)); |
926 |
|
|
930 |
|
|
927 | 931 |
this.setLoadSelection(xml.getChild(1)); |
928 | 932 |
/* |
929 | 933 |
// JMVIVO: Esto sirve para algo???? |
... | ... | |
940 | 944 |
recordsetName, DataSourceFactory.AUTOMATIC_OPENING)); |
941 | 945 |
// sds.setSelectionSupport(selectionSupport); |
942 | 946 |
// ((EditableAdapter)getSource()).setRecordSet(sds); |
943 |
|
|
944 | 947 |
|
948 |
|
|
945 | 949 |
} catch (NoSuchTableException e1) { |
946 | 950 |
this.setAvailable(false); |
947 | 951 |
throw new XMLException(e1); |
... | ... | |
963 | 967 |
setIsJoined(true); |
964 | 968 |
PostProcessSupport.addToPostProcess(this, "setLegend", leg, 1); |
965 | 969 |
} else { |
966 |
|
|
967 |
|
|
968 |
this.setLoadLegend(leg);
|
|
970 |
|
|
971 |
|
|
972 |
this.setLoadLegend(leg); |
|
969 | 973 |
/* |
970 | 974 |
try { |
971 | 975 |
// legend.setDataSource(getRecordset()); |
... | ... | |
990 | 994 |
|
991 | 995 |
|
992 | 996 |
} |
993 |
|
|
994 |
|
|
995 |
|
|
997 |
|
|
998 |
|
|
999 |
|
|
996 | 1000 |
/** |
997 | 1001 |
* A?ade un LegendListener a la lista de Listeners. |
998 | 1002 |
* |
... | ... | |
1121 | 1125 |
sds.setSelectionSupport(selectionSupport); |
1122 | 1126 |
|
1123 | 1127 |
} catch (DriverLoadException e) { |
1124 |
throw new DriverException(e); |
|
1128 |
DriverNotLoadedExceptionType exceptionType = |
|
1129 |
new DriverNotLoadedExceptionType(); |
|
1130 |
exceptionType.setDriverName(source.getDriver().getName()); |
|
1131 |
throw new DriverException(e, exceptionType); |
|
1125 | 1132 |
} |
1126 | 1133 |
} |
1127 | 1134 |
return sds; |
... | ... | |
1266 | 1273 |
public boolean isPropertiesMenuVisible(){ |
1267 | 1274 |
return true; |
1268 | 1275 |
} |
1269 |
|
|
1276 |
|
|
1270 | 1277 |
public void reload() throws DriverIOException { |
1271 | 1278 |
super.reload(); |
1272 | 1279 |
try { |
... | ... | |
1275 | 1282 |
if (this.getLegend() == null) { |
1276 | 1283 |
if (this.getRecordset().getDriver() instanceof WithDefaultLegend) { |
1277 | 1284 |
WithDefaultLegend aux = (WithDefaultLegend) this.getRecordset().getDriver(); |
1278 |
this.setLegend((VectorialLegend) aux.getDefaultLegend());
|
|
1285 |
this.setLegend((VectorialLegend) aux.getDefaultLegend()); |
|
1279 | 1286 |
} else { |
1280 | 1287 |
this.setLegend(LegendFactory.createSingleSymbolLegend( |
1281 | 1288 |
this.getShapeType())); |
1282 | 1289 |
} |
1283 | 1290 |
} |
1284 |
|
|
1291 |
|
|
1285 | 1292 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
1286 |
this.setAvailable(false);
|
|
1287 |
throw new DriverIOException(e);
|
|
1293 |
this.setAvailable(false); |
|
1294 |
throw new DriverIOException(e); |
|
1288 | 1295 |
} catch (IOException e) { |
1289 |
this.setAvailable(false);
|
|
1296 |
this.setAvailable(false); |
|
1290 | 1297 |
throw new DriverIOException(e); |
1291 | 1298 |
} catch (DriverException e) { |
1292 |
this.setAvailable(false);
|
|
1299 |
this.setAvailable(false); |
|
1293 | 1300 |
throw new DriverIOException(e); |
1294 | 1301 |
} catch (Exception e) { |
1295 |
this.setAvailable(false);
|
|
1302 |
this.setAvailable(false); |
|
1296 | 1303 |
throw new DriverIOException(e); |
1297 | 1304 |
} |
1298 |
|
|
1305 |
|
|
1299 | 1306 |
} |
1300 |
|
|
1307 |
|
|
1301 | 1308 |
protected void setLoadSelection(XMLEntity xml) { |
1302 | 1309 |
this.loadSelection = xml; |
1303 | 1310 |
} |
... | ... | |
1310 | 1317 |
if (this.loadSelection == null) return; |
1311 | 1318 |
try { |
1312 | 1319 |
this.getRecordset().getSelectionSupport().setXMLEntity(this.loadSelection); |
1313 |
} catch (DriverException e) {
|
|
1320 |
} catch (DriverException e) { |
|
1314 | 1321 |
throw new XMLException(e); |
1315 | 1322 |
} |
1316 |
this.loadSelection = null;
|
|
1317 |
|
|
1323 |
this.loadSelection = null; |
|
1324 |
|
|
1318 | 1325 |
} |
1319 | 1326 |
protected void putLoadLegend() throws FieldNotFoundException, DriverException { |
1320 | 1327 |
if (this.loadLegend == null) return; |
1321 |
|
|
1328 |
|
|
1322 | 1329 |
this.setLegend(this.loadLegend); |
1323 |
|
|
1324 |
this.loadLegend = null;
|
|
1325 |
|
|
1330 |
|
|
1331 |
this.loadLegend = null; |
|
1332 |
|
|
1326 | 1333 |
} |
1327 | 1334 |
|
1328 | 1335 |
protected void cleanLoadOptions() { |
1329 |
this.loadLegend = null;
|
|
1336 |
this.loadLegend = null; |
|
1330 | 1337 |
this.loadSelection = null; |
1331 | 1338 |
} |
1332 | 1339 |
|
1333 | 1340 |
public boolean isWritable() { |
1334 |
VectorialDriver drv = getSource().getDriver();
|
|
1341 |
VectorialDriver drv = getSource().getDriver(); |
|
1335 | 1342 |
if (!drv.isWritable()) |
1336 | 1343 |
return false; |
1337 | 1344 |
// VectorialEditableAdapter vea = (VectorialEditableAdapter) lyrVect |
... | ... | |
1349 | 1356 |
|
1350 | 1357 |
} |
1351 | 1358 |
|
1359 |
public void beforePrinting(PrintRequestAttributeSet properties) { |
|
1360 |
VectorialLegend vl=(VectorialLegend)getLegend(); |
|
1361 |
if (vl instanceof ClassifiedLegendInfo) { |
|
1362 |
ClassifiedLegendInfo clsfLegend = (ClassifiedLegendInfo) vl; |
|
1363 |
ISymbol[] symbols=clsfLegend.getSymbols(); |
|
1364 |
for (int i=0;i<symbols.length;i++) { |
|
1365 |
symbols[i].setPrintingProperties(properties); |
|
1366 |
} |
|
1367 |
} |
|
1368 |
if (vl.getDefaultSymbol()!=null) { |
|
1369 |
vl.getDefaultSymbol().setPrintingProperties(properties); |
|
1370 |
} |
|
1371 |
} |
|
1372 |
|
|
1373 |
public void afterPrinting() { |
|
1374 |
VectorialLegend vl=(VectorialLegend)getLegend(); |
|
1375 |
if (vl instanceof ClassifiedLegendInfo) { |
|
1376 |
ClassifiedLegendInfo clsfLegend = (ClassifiedLegendInfo) vl; |
|
1377 |
ISymbol[] symbols=clsfLegend.getSymbols(); |
|
1378 |
for (int i=0;i<symbols.length;i++) { |
|
1379 |
symbols[i].setPrintingProperties(null); |
|
1380 |
} |
|
1381 |
} |
|
1382 |
if (vl.getDefaultSymbol()!=null) { |
|
1383 |
vl.getDefaultSymbol().setPrintingProperties(null); |
|
1384 |
} |
|
1385 |
|
|
1386 |
} |
|
1387 |
|
|
1388 |
public FLayer cloneLayer() throws Exception { |
|
1389 |
FLyrVect clonedLayer = new FLyrVect(); |
|
1390 |
clonedLayer.setSource(getSource()); |
|
1391 |
clonedLayer.setVisible(isVisible()); |
|
1392 |
clonedLayer.setISpatialIndex(getISpatialIndex()); |
|
1393 |
clonedLayer.setName(getName()); |
|
1394 |
clonedLayer.setCoordTrans(getCoordTrans()); |
|
1395 |
|
|
1396 |
if (legend.getLabelField() != null) // Hay etiquetas |
|
1397 |
{ |
|
1398 |
FLyrText lyrText = getLayerText(); |
|
1399 |
String antLabelField = legend.getLabelField(); |
|
1400 |
VectorialLegend clonedLegend = (VectorialLegend) legend.cloneLegend(); |
|
1401 |
clonedLegend.setLabelField(null); |
|
1402 |
clonedLayer.setLegend(clonedLegend); |
|
1403 |
clonedLayer.setLayerText(lyrText); |
|
1404 |
clonedLegend.setLabelField(antLabelField); |
|
1405 |
|
|
1406 |
} |
|
1407 |
else |
|
1408 |
clonedLayer.setLegend((VectorialLegend)getLegend()); |
|
1409 |
return clonedLayer; |
|
1410 |
} |
|
1411 |
|
|
1352 | 1412 |
} |
Also available in: Unified diff