Changeset 24654 in osm for applications/editors/josm
- Timestamp:
- 2010-12-08T15:53:35+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport/src/pdfimport
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r24214 r24654 137 137 private JCheckBox splitOnShapeClosedCheck; 138 138 private JCheckBox splitOnSingleSegmentCheck; 139 private JCheckBox splitOnOrthogonalCheck; 139 140 140 141 … … 254 255 this.splitOnShapeClosedCheck = new JCheckBox(tr("Shape closed")); 255 256 this.splitOnSingleSegmentCheck = new JCheckBox(tr("Single segments")); 257 this.splitOnOrthogonalCheck = new JCheckBox(tr("Orthogonal shapes")); 256 258 257 259 JPanel configPanel = new JPanel(new GridBagLayout()); … … 308 310 c.gridx = 1; c.gridy = 8; c.gridwidth = 1; 309 311 configPanel.add(this.splitOnColorChangeCheck, c); 312 c.gridx = 2; c.gridy = 8; c.gridwidth = 1; 313 configPanel.add(this.splitOnOrthogonalCheck, c); 310 314 311 315 … … 767 771 monitor.setTicks(95); 768 772 monitor.setCustomText(tr("Finalizing layers")); 769 data.splitLayersByPathKind(this.splitOnShapeClosedCheck.isSelected(), this.splitOnSingleSegmentCheck.isSelected() );773 data.splitLayersByPathKind(this.splitOnShapeClosedCheck.isSelected(), this.splitOnSingleSegmentCheck.isSelected(), this.splitOnOrthogonalCheck.isSelected()); 770 774 data.finish(); 771 775 -
applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java
r24214 r24654 164 164 } 165 165 166 public void splitLayersByPathKind(boolean closed, boolean single ) {166 public void splitLayersByPathKind(boolean closed, boolean single, boolean orthogonal) { 167 167 List<LayerContents> newLayers = new ArrayList<LayerContents>(); 168 168 for(LayerContents l: this.layers) { 169 List<LayerContents> splitResult = splitBySegmentKind(l, closed, single );169 List<LayerContents> splitResult = splitBySegmentKind(l, closed, single, orthogonal); 170 170 171 171 for(LayerContents ll: splitResult) { … … 583 583 } 584 584 585 private List<LayerContents> splitBySegmentKind(LayerContents layer, boolean closed, boolean single )585 private List<LayerContents> splitBySegmentKind(LayerContents layer, boolean closed, boolean single, boolean orthogonal) 586 586 { 587 587 if (!closed && !single) { 588 return Collections.singletonList(layer); 589 } 588 return Collections.singletonList(layer); 589 } 590 591 OrthogonalShapesFilter of = new OrthogonalShapesFilter(10); 590 592 591 593 List<PdfPath> singleSegmentPaths = new ArrayList<PdfPath>(); 592 594 List<PdfPath> multiSegmentPaths = new ArrayList<PdfPath>(); 593 595 List<PdfPath> closedPaths = new ArrayList<PdfPath>(); 596 List<PdfPath> orthogonalPaths = new ArrayList<PdfPath>(); 597 List<PdfPath> orthogonalClosedPaths = new ArrayList<PdfPath>(); 594 598 595 599 for(PdfPath path: layer.paths) { 596 if (path.points.size() <= 3 && single) { 600 boolean pathOrthgonal = orthogonal && of.isOrthogonal(path); 601 boolean pathUnclosed = !path.isClosed() && closed; 602 boolean pathSingleSegment = path.points.size() <= 3 && single; 603 604 if (pathSingleSegment) { 597 605 singleSegmentPaths.add(path); 598 606 } 599 else if (!path.isClosed() && closed) { 600 multiSegmentPaths.add(path); 607 else if (pathUnclosed) { 608 609 if (pathOrthgonal) { 610 orthogonalPaths.add(path); 611 } 612 else { 613 multiSegmentPaths.add(path); 614 } 601 615 } 602 616 else { 603 closedPaths.add(path); 617 if (pathOrthgonal) { 618 orthogonalClosedPaths.add(path); 619 } 620 else 621 { 622 closedPaths.add(path); 623 } 624 604 625 } 605 626 } … … 618 639 LayerContents l = new LayerContents(); 619 640 l.paths = singleSegmentPaths; 641 l.info = layer.info.copy(); 642 layers.add(l); 643 } 644 645 646 if (orthogonalPaths.size() > 0) { 647 LayerContents l = new LayerContents(); 648 l.paths = orthogonalPaths; 649 l.info = layer.info.copy(); 650 layers.add(l); 651 } 652 653 if (orthogonalClosedPaths.size() > 0) { 654 LayerContents l = new LayerContents(); 655 l.paths = orthogonalClosedPaths; 620 656 l.info = layer.info.copy(); 621 657 layers.add(l);
Note:
See TracChangeset
for help on using the changeset viewer.