Changeset 13157 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-11-25T00:10:36+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r13128 r13157 25 25 import javax.swing.Icon; 26 26 import javax.swing.ImageIcon; 27 import javax.swing.JEditorPane; 27 28 import javax.swing.JWindow; 28 29 import javax.swing.SwingUtilities; 29 30 import javax.swing.UIManager; 31 import javax.swing.plaf.basic.BasicHTML; 32 import javax.swing.text.View; 30 33 31 34 import org.openstreetmap.josm.Main; … … 227 230 228 231 private void fixPanelSize(MapView mv, String text) { 229 Dimension d = displayedPanel.getPreferredSize(); 230 if (d.width > mv.getWidth() / 2) { 232 int maxWidth = mv.getWidth() * 2/3; 233 JEditorPane pane = displayedPanel.getEditorPane(); 234 if (pane.getPreferredSize().width > maxWidth && Config.getPref().getBoolean("note.text.break-on-sentence-mark", false)) { 231 235 // To make sure long notes are displayed correctly 232 236 displayedPanel.setText(insertLineBreaks(text)); 237 } 238 // If still too large, enforce maximum size 239 Dimension d = pane.getPreferredSize(); 240 if (d.width > maxWidth) { 241 View v = (View) pane.getClientProperty(BasicHTML.propertyKey); 242 if (v == null) { 243 BasicHTML.updateRenderer(pane, text); 244 v = (View) pane.getClientProperty(BasicHTML.propertyKey); 245 } 246 if (v != null) { 247 v.setSize(maxWidth, 0); 248 int w = (int) Math.ceil(v.getPreferredSpan(View.X_AXIS)) + 30; 249 int h = (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)) + 10; 250 pane.setPreferredSize(new Dimension(w, h)); 251 } 233 252 } 234 253 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java
r11452 r13157 46 46 */ 47 47 public JMultilineLabel(String text, boolean allBold) { 48 this(text, allBold, false); 49 } 50 51 /** 52 * Constructs a normal label but adds HTML tags if not already done so. 53 * Supports both newline characters (<code>\n</code>) as well as the HTML 54 * <code><br></code> to insert new lines. 55 * 56 * Use setMaxWidth to limit the width of the label. 57 * @param text The text to display 58 * @param allBold If {@code true}, makes all text to be displayed in bold 59 * @param focusable indicates whether this label is focusable 60 * @since 13157 61 */ 62 public JMultilineLabel(String text, boolean allBold, boolean focusable) { 48 63 JosmEditorPane.makeJLabelLike(this, allBold); 49 64 String html = text.trim().replaceAll("\n", "<br>"); … … 51 66 html = "<html>" + html + "</html>"; 52 67 } 53 setFocusable(f alse);68 setFocusable(focusable); 54 69 super.setText(html); 55 70 }
Note:
See TracChangeset
for help on using the changeset viewer.