Changeset 32170 in osm for applications/editors/josm/plugins
- Timestamp:
- 2016-05-12T00:36:30+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintDialog.java
r32144 r32170 130 130 * The printer job 131 131 */ 132 protected PrinterJob job; 132 protected transient PrinterJob job; 133 133 134 134 /** 135 135 * The custom printer job attributes 136 136 */ 137 PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); 137 transient PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); 138 138 139 139 /** … … 152 152 updateFields(); 153 153 pack(); 154 //setMinimumSize(getPreferredSize());155 154 setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); 156 155 } … … 241 240 final JSpinner scaleField = new JSpinner(scaleModel); 242 241 scaleField.addChangeListener(new ChangeListener() { 242 @Override 243 243 public void stateChanged(ChangeEvent evt) { 244 244 SwingUtilities.invokeLater(new Runnable() { 245 @Override 245 246 public void run() { 246 247 try { … … 249 250 mapView.setFixedMapScale(scaleModel.getNumber().intValue()); 250 251 printPreview.repaint(); 251 } 252 catch (ParseException pe) { 253 ; // NOP 252 } catch (ParseException pe) { 253 Main.error(pe); 254 254 } 255 255 } … … 269 269 final JSpinner resolutionField = new JSpinner(resolutionModel); 270 270 resolutionField.addChangeListener(new ChangeListener() { 271 @Override 271 272 public void stateChanged(ChangeEvent evt) { 272 273 SwingUtilities.invokeLater(new Runnable() { 274 @Override 273 275 public void run() { 274 276 try { … … 276 278 Main.pref.put("print.resolution.dpi",resolutionModel.getNumber().toString()); 277 279 printPreview.repaint(); 278 } 279 catch (ParseException pe) { 280 ; // NOP 280 } catch (ParseException pe) { 281 Main.error(pe); 281 282 } 282 283 } … … 296 297 attributionText.setWrapStyleWord(true); 297 298 attributionText.getDocument().addDocumentListener(new DocumentListener() { 299 @Override 298 300 public void insertUpdate(DocumentEvent evt) { 299 301 SwingUtilities.invokeLater(new Runnable() { 302 @Override 300 303 public void run() { 301 304 Main.pref.put("print.attribution", attributionText.getText()); … … 304 307 }); 305 308 } 309 @Override 306 310 public void removeUpdate(DocumentEvent evt) { 307 311 this.insertUpdate(evt); 308 312 } 313 @Override 309 314 public void changedUpdate(DocumentEvent evt) { 310 ;// NOP315 // NOP 311 316 } 312 317 }); … … 352 357 printPreview.setPrintable(mapView); 353 358 } 354 JScrollPane previewPane = new JScrollPane(printPreview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 359 JScrollPane previewPane = new JScrollPane(printPreview, 360 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 355 361 previewPane.setPreferredSize(Main.main != null ? Main.map.mapView.getSize() : new Dimension(210,297)); 356 362 add(previewPane, GBC.std(0,0).span(1, GBC.RELATIVE).fill().weight(5.0,5.0)); … … 378 384 paperField.setText("-"); 379 385 orientationField.setText("-"); 380 } 381 else { 386 } else { 382 387 printerField.setText(service.getName()); 383 388 if (! attrs.containsKey(Media.class)) { … … 398 403 PageFormat pf = job.defaultPage(); 399 404 attrs.add(new MediaPrintableArea( 400 (float)pf.getImageableX()/72,(float)pf.getImageableY()/72, 401 (float)pf.getImageableWidth()/72,(float)pf.getImageableHeight()/72, 405 (float)pf.getImageableX()/72f, 406 (float)pf.getImageableY()/72f, 407 (float)pf.getImageableWidth()/72f, 408 (float)pf.getImageableHeight()/72f, 402 409 MediaPrintableArea.INCH) ); 403 410 } … … 413 420 * @param e an ActionEvent with one of the known commands 414 421 */ 422 @Override 415 423 public void actionPerformed(ActionEvent e) { 416 424 String cmd = e.getActionCommand(); 417 if ( cmd.equals("printer-dialog")) {425 if ("printer-dialog".equals(cmd)) { 418 426 if (job.printDialog(attrs)) { 419 427 updateFields(); 420 428 savePrintSettings(); 421 429 } 422 } 423 else if (cmd.equals("toggle-preview")) { 430 } else if ("toggle-preview".equals(cmd)) { 424 431 Main.pref.put("print.preview.enabled", previewCheckBox.isSelected()); 425 if (previewCheckBox.isSelected() == true) {432 if (previewCheckBox.isSelected()) { 426 433 printPreview.setPrintable(mapView); 427 } 428 else { 434 } else { 429 435 printPreview.setPrintable(null); 430 436 } 431 } 432 else if (cmd.equals("zoom-in")) { 437 } else if ("zoom-in".equals(cmd)) { 433 438 printPreview.zoomIn(); 434 } 435 else if (cmd.equals("zoom-out")) { 439 } else if ("zoom-out".equals(cmd)) { 436 440 printPreview.zoomOut(); 437 } 438 else if (cmd.equals("zoom-to-page")) { 441 } else if ("zoom-to-page".equals(cmd)) { 439 442 printPreview.zoomToPage(); 440 } 441 else if (cmd.equals("zoom-to-actual-size")) { 443 } else if ("zoom-to-actual-size".equals(cmd)) { 442 444 printPreview.setZoom(1.0); 443 } 444 else if (cmd.equals("print")) { 445 } else if ("print".equals(cmd)) { 445 446 try { 446 447 job.print(attrs); 447 } 448 catch (PrinterAbortException ex) { 448 } catch (PrinterAbortException ex) { 449 449 String msg = ex.getLocalizedMessage(); 450 450 if (msg.length() == 0) { … … 454 454 tr("Printing stopped"), 455 455 JOptionPane.WARNING_MESSAGE); 456 } 457 catch (PrinterException ex) { 456 } catch (PrinterException ex) { 458 457 String msg = ex.getLocalizedMessage(); 459 458 if (msg == null || msg.length() == 0) { … … 465 464 } 466 465 dispose(); 467 } 468 else if (cmd.equals("cancel")) { 466 } else if ("cancel".equals(cmd)) { 469 467 dispose(); 470 468 } … … 512 510 @SuppressWarnings("unchecked") 513 511 protected Attribute unmarshallPrintSetting(Collection<String> setting) throws 514 IllegalArgumentException, ClassNotFoundException, SecurityException, NoSuchMethodException, 515 InstantiationException, IllegalAccessException, InvocationTargetException { 512 ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { 516 513 517 514 if (setting == null || setting.size() != 4) { … … 551 548 job.setPrintService(PrintServiceLookup.lookupPrintServices(null, new HashPrintServiceAttributeSet(a))[0]); 552 549 } 553 } catch (Exception e) { 550 } catch (PrinterException | ReflectiveOperationException e) { 554 551 Main.warn(e.getClass().getSimpleName()+": "+e.getMessage()); 555 552 } … … 558 555 try { 559 556 attrs.add(unmarshallPrintSetting(setting)); 560 } catch (Exception e) { 557 } catch (ReflectiveOperationException e) { 561 558 Main.warn(e.getClass().getSimpleName()+": "+e.getMessage()); 562 559 } … … 564 561 } 565 562 } 566
Note:
See TracChangeset
for help on using the changeset viewer.