Changeset 27316 in osm for applications/editors/josm
- Timestamp:
- 2011-12-24T15:53:42+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintDialog.java
r27282 r27316 172 172 final GBC std = GBC.std().insets(0,5,5,0); 173 173 std.fill = GBC.HORIZONTAL; 174 final GBC twocolumns = GBC.std().insets(0,5,5,0).span(2).fill(GBC.HORIZONTAL); 174 final GBC twoColumns = GBC.std().insets(0,5,5,0).span(2); 175 twoColumns.fill = GBC.HORIZONTAL; 176 final GBC threeColumns = GBC.std().insets(0,5,5,0).span(3); 177 threeColumns.fill = GBC.HORIZONTAL; 175 178 176 179 JLabel caption; … … 178 181 int row = 0; 179 182 caption = new JLabel(tr("Printer")+":"); 180 add(caption, std.grid(2, row));183 add(caption, twoColumns.grid(2, row)); 181 184 printerField = new JTextField(); 182 185 printerField.setEditable(false); 183 add(printerField, std.grid( 3, row));186 add(printerField, std.grid(GBC.RELATIVE, row)); 184 187 185 188 row++; 186 189 caption = new JLabel(tr("Media")+":"); 187 add(caption, std.grid(2, row));190 add(caption, twoColumns.grid(2, row)); 188 191 paperField = new JTextField(); 189 192 paperField.setEditable(false); 190 add(paperField, std.grid( 3, row));193 add(paperField, std.grid(GBC.RELATIVE, row)); 191 194 192 195 row++; 193 196 caption = new JLabel(tr("Orientation")+":"); 194 add(caption, std.grid(2, row));197 add(caption, twoColumns.grid(2, row)); 195 198 orientationField = new JTextField(); 196 199 orientationField.setEditable(false); 197 add(orientationField, std.grid( 3, row));200 add(orientationField, std.grid(GBC.RELATIVE, row)); 198 201 199 202 row++; … … 201 204 printerButton.setActionCommand("printer-dialog"); 202 205 printerButton.addActionListener(this); 203 add(printerButton, t wocolumns.grid(2, row));206 add(printerButton, threeColumns.grid(2, row)); 204 207 205 208 row++; … … 207 210 208 211 row++; 209 caption = new JLabel(tr("Scale")+": 1 :");212 caption = new JLabel(tr("Scale")+":"); 210 213 add(caption, std.grid(2, row)); 214 caption = new JLabel(" 1 :"); 215 add(caption, std.grid(GBC.RELATIVE, row)); 211 216 int mapScale = (int)Main.pref.getInteger("print.map-scale", PrintPlugin.DEF_MAP_SCALE); 212 217 mapView.setFixedMapScale(mapScale); … … 230 235 } 231 236 }); 232 add(scaleField, std.grid( 3, row));233 234 row++; 235 caption = new JLabel(tr("Resolution")+": (dpi)");237 add(scaleField, std.grid(GBC.RELATIVE, row)); 238 239 row++; 240 caption = new JLabel(tr("Resolution")+":"); 236 241 add(caption, std.grid(2, row)); 242 caption = new JLabel("ppi"); 243 add(caption, std.grid(GBC.RELATIVE, row)); 237 244 resolutionModel = new SpinnerNumberModel( 238 245 (int)Main.pref.getInteger("print.resolution.dpi", PrintPlugin.DEF_RESOLUTION_DPI), … … 255 262 } 256 263 }); 257 add(resolutionField, std.grid(3, row)); 258 259 row++; 260 caption = new JLabel(tr("Attribution")+":"); 261 add(caption, std.grid(2, row)); 262 263 row++; 264 final JTextField attributionField = new JTextField(); 265 attributionField.setText(Main.pref.get("print.attribution", PrintPlugin.DEF_ATTRIBUTION)); 266 attributionField.getDocument().addDocumentListener(new DocumentListener() { 264 add(resolutionField, std.grid(GBC.RELATIVE, row)); 265 266 row++; 267 caption = new JLabel(tr("Map information")+":"); 268 add(caption, threeColumns.grid(2, row)); 269 270 row++; 271 final javax.swing.JTextArea attributionText = new javax.swing.JTextArea(Main.pref.get("print.attribution", PrintPlugin.DEF_ATTRIBUTION)); 272 attributionText.setRows(10); 273 attributionText.setLineWrap(true); 274 attributionText.setWrapStyleWord(true); 275 attributionText.getDocument().addDocumentListener(new DocumentListener() { 267 276 public void insertUpdate(DocumentEvent evt) { 268 277 SwingUtilities.invokeLater(new Runnable() { 269 278 public void run() { 270 Main.pref.put("print.attribution", attribution Field.getText());279 Main.pref.put("print.attribution", attributionText.getText()); 271 280 printPreview.repaint(); 272 281 } … … 280 289 } 281 290 }); 282 add(attributionField, twocolumns.grid(2, row)); 291 JScrollPane attributionPane = new JScrollPane(attributionText); 292 add(attributionPane, GBC.std().insets(0,5,5,0).span(3).fill(GBC.BOTH).weight(0.0,1.0).grid(2, row)); 283 293 284 294 row++; … … 290 300 previewCheckBox.setActionCommand("toggle-preview"); 291 301 previewCheckBox.addActionListener(this); 292 add(previewCheckBox, t wocolumns.grid(2, row));302 add(previewCheckBox, threeColumns.grid(2, row)); 293 303 294 304 row++; … … 296 306 zoomInButton.setActionCommand("zoom-in"); 297 307 zoomInButton.addActionListener(this); 298 add(zoomInButton, t wocolumns.grid(2, row));308 add(zoomInButton, threeColumns.grid(2, row)); 299 309 300 310 row++; … … 302 312 zoomOutButton.setActionCommand("zoom-out"); 303 313 zoomOutButton.addActionListener(this); 304 add(zoomOutButton, t wocolumns.grid(2, row));314 add(zoomOutButton, threeColumns.grid(2, row)); 305 315 306 316 row++; … … 308 318 zoomToPageButton.setActionCommand("zoom-to-page"); 309 319 zoomToPageButton.addActionListener(this); 310 add(zoomToPageButton, t wocolumns.grid(2, row));320 add(zoomToPageButton, threeColumns.grid(2, row)); 311 321 312 322 row++; … … 314 324 zoomToActualSize.setActionCommand("zoom-to-actual-size"); 315 325 zoomToActualSize.addActionListener(this); 316 add(zoomToActualSize, t wocolumns.grid(2, row));326 add(zoomToActualSize, threeColumns.grid(2, row)); 317 327 318 328 printPreview = new PrintPreview(); -
applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintableMapView.java
r27313 r27316 340 340 public void paintMapAttribution(Graphics2D g2d, PageFormat pageFormat) { 341 341 String text = Main.pref.get("print.attribution", PrintPlugin.DEF_ATTRIBUTION); 342 if (text != null && text.length() > 0) { 343 text += " "; 344 345 Font attributionFont = new Font("Arial", Font.PLAIN, FONT_SIZE * 8 / 10); 346 g2d.setFont(attributionFont); 347 Rectangle2D bound = g2d.getFontMetrics().getStringBounds(text, g2d); 348 int x = (int)((pageFormat.getImageableWidth() - bound.getWidth())); 349 int y = FONT_SIZE * 3 / 2; 350 paintText(g2d, text, x, y); 342 343 if (text == null) { 344 return; 345 } 346 347 Font attributionFont = new Font("Arial", Font.PLAIN, FONT_SIZE * 8 / 10); 348 g2d.setFont(attributionFont); 349 350 text += "\n"; 351 int y = FONT_SIZE * 3 / 2; 352 int from = 0; 353 int to = text.indexOf("\n", from); 354 while (to >= from) { 355 String line = text.substring(from, to); 356 357 Rectangle2D bound = g2d.getFontMetrics().getStringBounds(line, g2d); 358 int x = (int)((pageFormat.getImageableWidth() - bound.getWidth()) - FONT_SIZE/2); 359 360 paintText(g2d, line, x, y); 361 362 y += FONT_SIZE * 5 / 4; 363 from = to + 1; 364 to = text.indexOf("\n", from); 351 365 } 352 366 }
Note:
See TracChangeset
for help on using the changeset viewer.