Changeset 24214 in osm
- Timestamp:
- 2010-11-13T15:12:19+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport/src/pdfimport
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r24191 r24214 134 134 private JCheckBox limitPathCountCheck; 135 135 private JTextField limitPathCount; 136 private JCheckBox splitOnColorChangeCheck; 137 private JCheckBox splitOnShapeClosedCheck; 138 private JCheckBox splitOnSingleSegmentCheck; 136 139 137 140 … … 247 250 this.limitPathCountCheck = new JCheckBox(tr("Take only first X paths")); 248 251 this.limitPathCount = new JTextField("10000"); 252 253 this.splitOnColorChangeCheck = new JCheckBox(tr("Color/width change")); 254 this.splitOnShapeClosedCheck = new JCheckBox(tr("Shape closed")); 255 this.splitOnSingleSegmentCheck = new JCheckBox(tr("Single segments")); 249 256 250 257 JPanel configPanel = new JPanel(new GridBagLayout()); … … 293 300 294 301 295 JPanel selectFilePanel = new JPanel(new GridBagLayout()); 296 selectFilePanel.setBorder(BorderFactory.createTitledBorder(tr("Load file"))); 297 c.gridx = 0; c.gridy = 0; c.gridwidth = 1; 298 selectFilePanel.add(this.loadFileButton, c); 302 c.gridx = 0; c.gridy = 7; c.gridwidth = 1; 303 configPanel.add(new JLabel(tr("Introduce separate layers for:")), c); 304 c.gridx = 1; c.gridy = 7; c.gridwidth = 1; 305 configPanel.add(this.splitOnShapeClosedCheck, c); 306 c.gridx = 2; c.gridy = 7; c.gridwidth = 1; 307 configPanel.add(this.splitOnSingleSegmentCheck, c); 308 c.gridx = 1; c.gridy = 8; c.gridwidth = 1; 309 configPanel.add(this.splitOnColorChangeCheck, c); 310 299 311 300 312 JPanel projectionPanel = new JPanel(new GridBagLayout()); … … 353 365 panel.add(configPanel, c); 354 366 c.gridx = 0; c.gridy = 1; c.gridwidth = 1; 355 panel.add( selectFilePanel, c);367 panel.add(loadFileButton, c); 356 368 c.gridx = 0; c.gridy = 2; c.gridwidth = 1; 357 369 panel.add(projectionPanel, c); … … 552 564 fc.setAcceptAllFileFilterUsed(false); 553 565 fc.setMultiSelectionEnabled(false); 566 fc.setSelectedFile(this.fileName); 554 567 fc.setFileFilter(new FileFilter(){ 555 568 @Override … … 671 684 monitor.setCustomText(tr("Parsing file")); 672 685 673 PathOptimizer data = new PathOptimizer(nodesTolerance, color );686 PathOptimizer data = new PathOptimizer(nodesTolerance, color, this.splitOnColorChangeCheck.isSelected()); 674 687 675 688 try { … … 709 722 } 710 723 724 if (nodesTolerance > 0.0) { 725 monitor.setTicks(83); 726 monitor.setCustomText(tr("Joining nodes")); 727 data.mergeNodes(); 728 } 729 711 730 monitor.setTicks(85); 712 731 monitor.setCustomText(tr("Joining adjacent segments")); … … 748 767 monitor.setTicks(95); 749 768 monitor.setCustomText(tr("Finalizing layers")); 750 data.splitLayersByPathKind( );769 data.splitLayersByPathKind(this.splitOnShapeClosedCheck.isSelected(), this.splitOnSingleSegmentCheck.isSelected()); 751 770 data.finish(); 752 771 -
applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java
r24189 r24214 122 122 private Way insertWay(PdfPath path, Map<Point2D, Node> point2Node, int multipathId, boolean multipolygon) { 123 123 124 monitor.setExtraText(tr(" "+this.monitorPos+"/"+this.monitorTotal)); 125 monitor.setTicks(this.monitorPos); 124 if (this.monitorPos % 100 == 0) { 125 monitor.setExtraText(tr(" "+this.monitorPos+"/"+this.monitorTotal)); 126 monitor.setTicks(this.monitorPos); 127 } 126 128 this.monitorPos ++; 127 129 … … 185 187 } 186 188 187 String s = Integer.toHexString(col.getRGB() );189 String s = Integer.toHexString(col.getRGB() & 0xffffff); 188 190 while (s.length() < 6) { 189 191 s = "0" + s; -
applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java
r24189 r24214 21 21 private final double pointsTolerance; 22 22 private final Color color; 23 24 public PathOptimizer(double _pointsTolerance, Color _color) 23 boolean splitOnColorChange; 24 25 LayerContents prevLayer = null; 26 27 public PathOptimizer(double _pointsTolerance, Color _color, boolean _splitOnColorChange) 25 28 { 26 27 29 uniquePointMap = new HashMap<Point2D, Point2D>(); 28 30 uniquePoints = new ArrayList<Point2D>(); … … 31 33 pointsTolerance = _pointsTolerance; 32 34 color = _color; 35 splitOnColorChange = _splitOnColorChange; 33 36 } 34 37 … … 161 164 } 162 165 163 public void splitLayersByPathKind( ) {166 public void splitLayersByPathKind(boolean closed, boolean single) { 164 167 List<LayerContents> newLayers = new ArrayList<LayerContents>(); 165 168 for(LayerContents l: this.layers) { 166 List<LayerContents> splitResult = splitBySegmentKind(l );169 List<LayerContents> splitResult = splitBySegmentKind(l, closed, single); 167 170 168 171 for(LayerContents ll: splitResult) { … … 186 189 187 190 private LayerContents getLayer(LayerInfo info) { 188 LayerContents layer; 191 192 LayerContents layer = null; 189 193 190 194 if (this.layerMap.containsKey(info)) 191 195 { 192 196 layer = this.layerMap.get(info); 193 } 194 else 197 198 if (layer != this.prevLayer && this.splitOnColorChange) { 199 layer = null; 200 } 201 } 202 203 if (layer == null) 195 204 { 196 205 layer = new LayerContents(); … … 201 210 } 202 211 212 this.prevLayer = layer; 203 213 return layer; 204 214 } … … 573 583 } 574 584 575 private List<LayerContents> splitBySegmentKind(LayerContents layer )585 private List<LayerContents> splitBySegmentKind(LayerContents layer, boolean closed, boolean single) 576 586 { 587 if (!closed && !single) { 588 return Collections.singletonList(layer); 589 } 590 577 591 List<PdfPath> singleSegmentPaths = new ArrayList<PdfPath>(); 578 592 List<PdfPath> multiSegmentPaths = new ArrayList<PdfPath>(); … … 580 594 581 595 for(PdfPath path: layer.paths) { 582 if (path.points.size() <= 3 ) {596 if (path.points.size() <= 3 && single) { 583 597 singleSegmentPaths.add(path); 584 598 } 585 else if (path.isClosed()) { 599 else if (!path.isClosed() && closed) { 600 multiSegmentPaths.add(path); 601 } 602 else { 586 603 closedPaths.add(path); 587 }588 else {589 multiSegmentPaths.add(path);590 604 } 591 605 } -
applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java
r24191 r24214 48 48 private void addPath(Shape s, boolean closed) { 49 49 pathNo ++; 50 this.monitor.setCustomText(tr(" {0} objects so far", pathNo)); 50 51 if (pathNo % 100 == 0) { 52 this.monitor.setCustomText(tr(" {0} objects so far", pathNo)); 53 } 51 54 52 55 if (pathNo >= maxPaths) {
Note:
See TracChangeset
for help on using the changeset viewer.