Changeset 24191 in osm
- Timestamp:
- 2010-11-11T13:54:26+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/FilePlacement.java
r24189 r24191 142 142 } 143 143 } else { 144 return tr("Transform error: Unsupported variant.");144 //all fine 145 145 } 146 146 … … 154 154 (this.maxNorth - this.minNorth) / (this.maxY - this.minY)); 155 155 this.transform.translate(-this.minX, -this.minY); 156 } else if (this.minEast < this.maxEast && this.minNorth >this.maxNorth) {156 } else if (this.minEast > this.maxEast && this.minNorth < this.maxNorth) { 157 157 //need to rotate 90 degrees counterclockwise 158 158 this.transform = new AffineTransform(); 159 159 //transform to 0..1, 0..1 range 160 160 this.transform.preConcatenate(AffineTransform.getTranslateInstance(-this.minX, -this.minY)); 161 this.transform.preConcatenate(AffineTransform.getScaleInstance(1/(this.maxX - this.minX), 1/(this.m inY - this.maxY)));162 163 //rotate -90 degs around center164 this.transform.preConcatenate(AffineTransform.getQuadrantRotateInstance( -1, 0.5, 0.5));161 this.transform.preConcatenate(AffineTransform.getScaleInstance(1/(this.maxX - this.minX), 1/(this.maxY - this.minY))); 162 163 //rotate -90 degs around min 164 this.transform.preConcatenate(AffineTransform.getQuadrantRotateInstance(1, 0, 0)); 165 165 166 166 //transform back to target range 167 167 this.transform.preConcatenate(AffineTransform.getScaleInstance( 168 (this.m axEast - this.minEast),169 (this.m inNorth - this.maxNorth)));170 this.transform.preConcatenate(AffineTransform.getTranslateInstance(this.minEast, this.m axNorth));171 } else if (this.minEast > this.maxEast && this.minNorth <this.maxNorth) {168 (this.minEast - this.maxEast), 169 (this.maxNorth - this.minNorth))); 170 this.transform.preConcatenate(AffineTransform.getTranslateInstance(this.minEast, this.minNorth)); 171 } else if (this.minEast < this.maxEast && this.minNorth > this.maxNorth) { 172 172 //need to rotate 90 degrees clockwise 173 173 this.transform = new AffineTransform(); … … 176 176 this.transform.preConcatenate(AffineTransform.getScaleInstance(1/(this.maxX - this.minX), 1/(this.maxY - this.minY))); 177 177 178 //rotate 90 degs around center179 this.transform.preConcatenate(AffineTransform.getQuadrantRotateInstance( 1, 0.5, 0.5));178 //rotate 90 degs around min 179 this.transform.preConcatenate(AffineTransform.getQuadrantRotateInstance(-1, 0, 0)); 180 180 181 181 //transform back to target range 182 182 this.transform.preConcatenate(AffineTransform.getScaleInstance( 183 (this.m inEast - this.maxEast),184 (this.m axNorth - this.minNorth)));185 this.transform.preConcatenate(AffineTransform.getTranslateInstance(this.m axEast, this.minNorth));183 (this.maxEast - this.minEast), 184 (this.minNorth - this.maxNorth))); 185 this.transform.preConcatenate(AffineTransform.getTranslateInstance(this.minEast, this.minNorth)); 186 186 } 187 187 else -
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r24189 r24191 132 132 133 133 private LoadProgressRenderer progressRenderer; 134 private JCheckBox limitPathCountCheck; 135 private JTextField limitPathCount; 134 136 135 137 … … 243 245 this.removeParallelSegmentsTolerance = new JTextField("3"); 244 246 247 this.limitPathCountCheck = new JCheckBox(tr("Take only first X paths")); 248 this.limitPathCount = new JTextField("10000"); 245 249 246 250 JPanel configPanel = new JPanel(new GridBagLayout()); … … 274 278 configPanel.add(this.removeParallelSegmentsTolerance, c); 275 279 276 c.gridx = 0; c.gridy = 4; c.gridwidth = 1; 280 281 c.gridx = 0; c.gridy = 4; c.gridwidth = 2; 282 configPanel.add(this.limitPathCountCheck, c); 283 c.gridx = 2; c.gridy = 4; c.gridwidth = 1; 284 configPanel.add(this.limitPathCount, c); 285 286 c.gridx = 0; c.gridy = 5; c.gridwidth = 1; 277 287 configPanel.add(this.colorFilterCheck, c); 278 c.gridx = 2; c.gridy = 4; c.gridwidth = 1;288 c.gridx = 2; c.gridy = 5; c.gridwidth = 1; 279 289 configPanel.add(this.colorFilterColor, c); 280 290 281 c.gridx = 0; c.gridy = 5; c.gridwidth = 2;291 c.gridx = 0; c.gridy = 6; c.gridwidth = 2; 282 292 configPanel.add(this.debugModeCheck, c); 283 293 … … 615 625 double nodesTolerance = 0.0; 616 626 Color color = null; 627 int maxPaths = Integer.MAX_VALUE; 617 628 618 629 if (this.mergeCloseNodesCheck.isSelected()) { … … 643 654 } 644 655 656 if (this.limitPathCountCheck.isSelected()) { 657 try { 658 maxPaths = Integer.parseInt(this.limitPathCount.getText()); 659 } 660 catch (Exception e) { 661 JOptionPane 662 .showMessageDialog( 663 Main.parent, 664 tr("Could not parse max path count")); 665 return null; 666 } 667 } 668 645 669 646 670 monitor.setTicks(10); … … 651 675 try { 652 676 PdfBoxParser parser = new PdfBoxParser(data); 653 parser.parse(fileName, m onitor.createSubTaskMonitor(80, false));677 parser.parse(fileName, maxPaths, monitor.createSubTaskMonitor(80, false)); 654 678 655 679 } catch (FileNotFoundException e1) { -
applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java
r24189 r24191 22 22 23 23 public PathOptimizer target; 24 private Shape clipShape;24 private Shape clipShape; 25 25 private List<PdfPath> clipPath; 26 26 private final LayerInfo info = new LayerInfo(); … … 31 31 private final AffineTransform transform; 32 32 private final ProgressMonitor monitor; 33 34 public GraphicsProcessor(PathOptimizer target, int rotation, ProgressMonitor monitor) 33 private final int maxPaths; 34 35 36 public GraphicsProcessor(PathOptimizer target, int rotation, int maxPaths, ProgressMonitor monitor) 35 37 { 38 this.maxPaths = maxPaths; 36 39 this.target = target; 37 40 this.transform = new AffineTransform(); … … 44 47 45 48 private void addPath(Shape s, boolean closed) { 49 pathNo ++; 50 this.monitor.setCustomText(tr(" {0} objects so far", pathNo)); 51 52 if (pathNo >= maxPaths) { 53 return; 54 } 55 46 56 List<PdfPath> paths = this.parsePath(s, closed); 47 57 … … 50 60 } 51 61 52 pathNo ++;53 62 54 63 if (paths.size() > 1) { … … 60 69 } 61 70 62 this.monitor.setCustomText(tr(" {0} objects so far", pathNo));63 71 } 64 72 … … 179 187 180 188 181 public void setClip(Shape clip) {182 if (this. clipShape == clip)189 public void setClip(Shape clip) { 190 if (this.shapesEqual(this.clipShape,clip)) 183 191 return; 184 192 … … 203 211 204 212 213 private boolean shapesEqual(Shape shape1, Shape shape2) { 214 215 if (shape1== null || shape2 == null){ 216 return false; 217 } 218 219 return shape1.getBounds2D().equals(shape2.getBounds2D()); 220 } 221 222 205 223 public void setStroke(Stroke s) { 206 224 BasicStroke stroke = (BasicStroke) s; -
applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java
r24189 r24191 23 23 24 24 @SuppressWarnings("unchecked") 25 public void parse(File file, ProgressMonitor monitor) throws Exception25 public void parse(File file, int maxPaths, ProgressMonitor monitor) throws Exception 26 26 { 27 27 monitor.beginTask(tr("Parsing PDF", 1)); … … 47 47 } 48 48 49 GraphicsProcessor p = new GraphicsProcessor(target, rotation, m onitor);49 GraphicsProcessor p = new GraphicsProcessor(target, rotation, maxPaths, monitor); 50 50 PageDrawer drawer = new PageDrawer(); 51 51 drawer.drawPage(p, page);
Note:
See TracChangeset
for help on using the changeset viewer.