Changeset 23861 in osm for applications/editors
- Timestamp:
- 2010-10-27T12:53:40+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/.classpath
r23702 r23861 5 5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 6 6 <classpathentry kind="lib" path="lib/PDFClown.jar"/> 7 <classpathentry kind="lib" path="lib/pdfbox.jar" sourcepath="D:/Projects/Community/OSM/josm/pdfimport/pdfbox-1.3.1/pdfbox/src/main/java"/> 7 8 <classpathentry kind="output" path="bin"/> 8 9 </classpath> -
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r23746 r23861 47 47 48 48 private String fileName; 49 private P DFStreamProcessor data;49 private PathOptimizer data; 50 50 private final OsmBuilder builder; 51 51 private OsmDataLayer layer; … … 411 411 } 412 412 413 private P DFStreamProcessor loadPDF(String fileName) {413 private PathOptimizer loadPDF(String fileName) { 414 414 File file; 415 415 … … 433 433 Page page = document.getPages().get(0); 434 434 435 436 PDFStreamProcessor processor = new PDFStreamProcessor(document); 437 processor.bounds = page.getBox(); 435 PathOptimizer data = new PathOptimizer(); 436 data.bounds = page.getBox(); 437 438 PDFStreamProcessor processor = new PDFStreamProcessor(data, document); 438 439 Contents c = page.getContents(); 439 440 processor.process(new ContentScanner(c)); … … 441 442 document.delete(); 442 443 443 return processor; 444 data.optimize(); 445 446 return data; 444 447 } 445 448 … … 483 486 } 484 487 485 DataSet data = builder.build(this.data , isFinal);488 DataSet data = builder.build(this.data.getLayers(), isFinal); 486 489 this.layer = new OsmDataLayer(data, name, null); 487 490 … … 506 509 507 510 private void saveLayer(java.io.File file) { 508 DataSet data = builder.build(this.data , true);511 DataSet data = builder.build(this.data.getLayers(), true); 509 512 OsmDataLayer layer = new OsmDataLayer(data, file.getName(), file); 510 513 -
applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java
r23746 r23861 50 50 51 51 52 public Bounds getWorldBounds(P DFStreamProcessor data) {52 public Bounds getWorldBounds(PathOptimizer data) { 53 53 LatLon min = tranformCoords(data.bounds.getMinX(), data.bounds.getMinY()); 54 54 LatLon max = tranformCoords(data.bounds.getMaxX(), data.bounds.getMaxY()); … … 56 56 } 57 57 58 public DataSet build( PDFStreamProcessordata, boolean full) {58 public DataSet build(List<LayerContents> data, boolean full) { 59 59 60 60 DataSet result = new DataSet(); 61 61 62 for (LayerContents layer: data .getResult()) {62 for (LayerContents layer: data) { 63 63 this.addLayer(result, layer, full); 64 64 } -
applications/editors/josm/plugins/pdfimport/src/pdfimport/PDFStreamProcessor.java
r23746 r23861 15 15 import it.stefanochizzolini.clown.documents.contents.objects.DrawRectangle; 16 16 import it.stefanochizzolini.clown.documents.contents.objects.EndPathNoOp; 17 import it.stefanochizzolini.clown.documents.contents.objects.Fill; 17 18 import it.stefanochizzolini.clown.documents.contents.objects.FillEvenOdd; 19 import it.stefanochizzolini.clown.documents.contents.objects.FillStroke; 18 20 import it.stefanochizzolini.clown.documents.contents.objects.FillStrokeEvenOdd; 19 21 import it.stefanochizzolini.clown.documents.contents.objects.GenericOperation; 22 import it.stefanochizzolini.clown.documents.contents.objects.ModifyClipPath; 20 23 import it.stefanochizzolini.clown.documents.contents.objects.Path; 21 24 import it.stefanochizzolini.clown.documents.contents.objects.Stroke; … … 27 30 import java.awt.Color; 28 31 import java.awt.geom.Point2D; 29 import java.awt.geom.Rectangle2D;30 32 import java.util.ArrayList; 31 33 import java.util.HashMap; … … 36 38 37 39 private final LayerInfo info; 38 public Rectangle2D bounds;39 40 int pathNo = 0; 40 41 41 PathOptimizer optimizer = new PathOptimizer();42 PathOptimizer optimizer; 42 43 Map<LayerInfo, LayerInfo> multipathLayers = new HashMap<LayerInfo, LayerInfo>(); 43 44 private GraphicsState state; … … 45 46 private DeviceGrayColorSpace graySpace; 46 47 47 public PDFStreamProcessor(Document doc) { 48 48 public PDFStreamProcessor(PathOptimizer target, Document doc) { 49 50 this.optimizer = target; 49 51 this.rgbSpace = new DeviceRGBColorSpace(doc); 50 52 this.graySpace = new DeviceGrayColorSpace(doc); 51 52 53 this.info = new LayerInfo(); 53 54 } … … 57 58 this.graySpace = null; 58 59 this.state = null; 59 this.optimizer.optimize();60 }61 62 public List<LayerContents> getResult() {63 return this.optimizer.getLayers();64 60 } 65 61 … … 201 197 } 202 198 } 203 else if (obj instanceof FillEvenOdd ) {199 else if (obj instanceof FillEvenOdd || obj instanceof Fill) { 204 200 this.info.fill = true; 205 201 this.info.stroke = false; 206 202 } 207 else if (obj instanceof FillStrokeEvenOdd ){203 else if (obj instanceof FillStrokeEvenOdd || obj instanceof FillStroke){ 208 204 this.info.fill = true; 209 205 this.info.stroke = true; … … 229 225 points = new ArrayList<Point2D>(2); 230 226 } 227 else if (obj instanceof ModifyClipPath) { 228 //nothign here 229 } 231 230 else { 232 231 int a = 10; … … 273 272 ColorSpace space = col.getColorSpace(); 274 273 275 if (space instanceof DeviceRGBColorSpace) { 274 if (space == null){ 275 return new Color( 276 (float)col.getComponents()[0], 277 (float)col.getComponents()[1], 278 (float)col.getComponents()[2]); 279 } 280 else if (space instanceof DeviceRGBColorSpace) { 276 281 return new Color( 277 282 (float)col.getComponents()[0], -
applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java
r23746 r23861 2 2 3 3 import java.awt.geom.Point2D; 4 import java.awt.geom.Rectangle2D; 4 5 import java.util.ArrayList; 5 6 import java.util.HashMap; … … 14 15 private final Map<LayerInfo, LayerContents> layerMap; 15 16 private List<LayerContents> layers; 17 public Rectangle2D bounds; 16 18 17 19 public PathOptimizer() … … 70 72 } 71 73 74 72 75 List<LayerContents> newLayers = new ArrayList<LayerContents>(); 73 76 int nr = 0;
Note:
See TracChangeset
for help on using the changeset viewer.