1 |
1 |
package org.gvsig.app.project.documents.layout.report;
|
2 |
2 |
|
|
3 |
import java.awt.Color;
|
3 |
4 |
import java.awt.Dimension;
|
4 |
5 |
import java.awt.event.ActionEvent;
|
5 |
6 |
import java.awt.geom.Point2D;
|
... | ... | |
58 |
59 |
import org.gvsig.pdf.swing.api.PDFSwingLocator;
|
59 |
60 |
import org.gvsig.pdf.swing.api.PDFSwingManager;
|
60 |
61 |
import org.gvsig.pdf.swing.api.PDFViewer;
|
|
62 |
import org.gvsig.symbology.SymbologyLocator;
|
|
63 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.ISimpleTextSymbol;
|
61 |
64 |
import org.gvsig.tools.ToolsLocator;
|
62 |
65 |
import org.gvsig.tools.dispose.DisposeUtils;
|
63 |
66 |
import org.gvsig.tools.exception.BaseException;
|
... | ... | |
278 |
281 |
|
279 |
282 |
File pdfFile = null;
|
280 |
283 |
Object previous_report = document.getProperty("$REPORT");
|
|
284 |
I18nManager i18n = ToolsLocator.getI18nManager();
|
281 |
285 |
try {
|
282 |
286 |
document.setProperty("$REPORT", this);
|
283 |
287 |
/*
|
... | ... | |
308 |
312 |
mapContext = mapContextCandidate;
|
309 |
313 |
};
|
310 |
314 |
|
311 |
|
FeatureStore storeInLayout = this.store;
|
312 |
315 |
if (mapContext != null) {
|
313 |
316 |
mapContext.setPrintGraphicsLayer(this.parameters.isHighlightRecord());
|
314 |
317 |
ICoordTrans ct = null;
|
... | ... | |
317 |
320 |
FeatureStore layerStore = ((FLyrVect) layer).getFeatureStore();
|
318 |
321 |
if (layerStore != null) {
|
319 |
322 |
if (layerStore.getParameters().isTheSameStore(this.store.getParameters())) {
|
320 |
|
storeInLayout = layerStore;
|
321 |
323 |
ct = ((FLyrVect) layer).getCoordTrans();
|
322 |
324 |
break;
|
323 |
325 |
}
|
... | ... | |
356 |
358 |
//Do nothing, is the default behavior
|
357 |
359 |
}
|
358 |
360 |
if(this.parameters.isApplySymbolToEverythingExceptRecord()){
|
359 |
|
geom = mapContext.getViewPort().getAdjustedEnvelope().getGeometry().difference(geom);
|
|
361 |
Geometry viewPortGeom = mapContext.getViewPort().getAdjustedEnvelope().getGeometry();
|
|
362 |
if(geom.isValid()) {
|
|
363 |
geom = viewPortGeom.difference(geom);
|
|
364 |
} else {
|
|
365 |
Geometry geom2 = geom.fix();
|
|
366 |
if(geom2 != null){
|
|
367 |
geom = viewPortGeom.difference(geom2);
|
|
368 |
} else {
|
|
369 |
geom = viewPortGeom;
|
|
370 |
ISimpleTextSymbol textSymbol = SymbologyLocator.getSymbologyManager().createSimpleTextSymbol();
|
|
371 |
textSymbol.setTextColor(Color.RED.darker());
|
|
372 |
textSymbol.setHaloColor(Color.WHITE);
|
|
373 |
textSymbol.setDrawWithHalo(true);
|
|
374 |
|
|
375 |
int idPointSymbol = graphicsLayer.addSymbol(textSymbol);
|
|
376 |
graphicsLayer.addGraphic("LayourReport", geom.centroid(), idPointSymbol, i18n.getTranslation("_Invalid_geometry"));
|
|
377 |
}
|
|
378 |
}
|
360 |
379 |
}
|
361 |
|
graphicsLayer.addGraphic("", geom, idSymbol);
|
|
380 |
graphicsLayer.addGraphic("LayourReport", geom, idSymbol);
|
362 |
381 |
}
|
363 |
382 |
}
|
364 |
383 |
}
|
... | ... | |
368 |
387 |
|
369 |
388 |
pdfFile = ToolsLocator.getFoldersManager().getUniqueTemporaryFile("report.pdf");
|
370 |
389 |
layout.layoutToPDF(pdfFile);
|
|
390 |
} catch (Throwable th) {
|
|
391 |
LOGGER.warn("Can't print report.", th);
|
|
392 |
this.getStatus().message(i18n.getTranslation("_Cant_print_report")+"\n\n"+th.getMessage());
|
|
393 |
throw th;
|
371 |
394 |
} finally {
|
372 |
395 |
document.setProperty("$REPORT", previous_report);
|
373 |
396 |
}
|