Changeset 21995 in osm for applications/editors/josm/plugins/roadsigns/src/org
- Timestamp:
- 2010-06-24T22:08:15+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java
r21967 r21995 33 33 import javax.swing.Scrollable; 34 34 import javax.swing.SwingConstants; 35 import javax.swing.SwingUtilities; 35 36 import javax.swing.border.Border; 36 37 import javax.swing.border.EtchedBorder; 37 38 import javax.swing.event.DocumentEvent; 38 39 import javax.swing.event.DocumentListener; 40 import javax.swing.event.HyperlinkEvent; 41 import javax.swing.event.HyperlinkListener; 39 42 import javax.swing.table.AbstractTableModel; 40 43 … … 49 52 import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter; 50 53 import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag; 54 import org.openstreetmap.josm.tools.OpenBrowser; 51 55 import org.openstreetmap.josm.tools.Pair; 52 56 … … 74 78 private JPanel pnlPossibleSupplements; 75 79 private JEditorPane info; 80 private JScrollPane scrollInfo; 76 81 77 82 public RoadSignInputDialog(List<Sign> signs) { … … 126 131 pnlSignSelection.setLayout(fLayout); 127 132 128 129 133 pnlPossibleSigns = new FixedWidthPanel(); 130 134 pnlPossibleSupplements = new FixedWidthPanel(); … … 146 150 info.setEditable(false); 147 151 info.setContentType("text/html"); 148 info.setText(""); 152 info.setText(" "); 149 153 info.setBackground(this.getBackground()); 150 JScrollPane scroll3 = new JScrollPane(info, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 151 multiSplitPane.add(scroll3, "bottom"); 154 info.addHyperlinkListener(new HyperlinkListener() { 155 public void hyperlinkUpdate(HyperlinkEvent e) { 156 if (e == null || e.getURL() == null) 157 return; 158 System.err.println(e.getURL()); 159 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 160 OpenBrowser.displayUrl(e.getURL().toString()); 161 } 162 } 163 }); 164 165 scrollInfo = new JScrollPane(info, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 166 multiSplitPane.add(scrollInfo, "bottom"); 152 167 153 168 return multiSplitPane; … … 162 177 for (Sign s : signs) { 163 178 JLabel lbl = new JLabel(s.getIcon()); 179 String tt = "<html>"+s.name; 180 String ref = s.getDefaultRef(); 181 if (ref != null) { 182 tt += " <i><small>("+ref+")</small></i>"; 183 } 184 tt += "</html>"; 185 lbl.setToolTipText(tt); 164 186 s.label = lbl; 165 187 lbl.addMouseListener(new SignClickListener(s)); … … 621 643 @Override 622 644 public void mouseClicked(MouseEvent e) { 645 info.setText(longText()); 646 /* scroll up again */ 647 SwingUtilities.invokeLater(new Runnable(){ 648 public void run() { 649 scrollInfo.getVerticalScrollBar().setValue(0); 650 } 651 }); 623 652 sel.add(sign); 624 653 } 625 654 626 @Override 627 public void mouseEntered(MouseEvent e) { 655 private String longText() { 628 656 StringBuilder txt = new StringBuilder(); 629 txt.append("<p><b><large>"); 630 txt.append(sign.name); 631 txt.append("</large></b>"); 657 txt.append(sign.long_name == null ? sign.name : sign.long_name); 632 658 String ref = sign.getDefaultRef(); 633 659 if (ref != null) { 634 660 txt.append(" <i><small>("+ref+")</small></i>"); 635 661 } 636 txt.append("</p>"); 637 // if (sign.long_name != null) { 638 // txt.append("<i><smaller>("+sign.long_name+")</smaller></i>"); 639 // } 640 info.setText(txt.toString()); 641 } 642 643 @Override 644 public void mouseExited(MouseEvent e) { 645 info.setText(""); 662 663 if (sign.help != null) { 664 txt.append("<p>"); 665 txt.append(sign.help); 666 txt.append("</p>"); 667 } 668 669 if (sign.wiki != null || sign.loc_wiki != null) { 670 String wikiPrefix = "http://wiki.openstreetmap.org/wiki/"; 671 txt.append("<p>"); 672 if (sign.loc_wiki != null) { 673 String link = wikiPrefix+sign.loc_wiki; 674 txt.append("<a href=\""+link+"\">"+link+"</a>"); 675 txt.append("<br>"); 676 } 677 if (sign.wiki != null && ! sign.wiki.equals(sign.loc_wiki)) { 678 String link = wikiPrefix+sign.wiki; 679 txt.append("<a href=\""+link+"\">"+link+"</a>"); 680 } 681 txt.append("</p>"); 682 } 683 return txt.toString(); 646 684 } 647 685 } … … 660 698 @Override 661 699 public void setBounds(int x, int y, int width, int height) { 662 663 700 super.setBounds(x, y, getParent().getWidth(), height); 701 } 664 702 665 703 @Override 666 667 668 669 670 671 672 673 674 704 public Dimension getPreferredSize() { 705 return new Dimension(getWidth(), getPreferredHeight()); 706 } 707 708 public Dimension getPreferredScrollableViewportSize() { 709 return super.getPreferredSize(); 710 } 711 712 public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) { 675 713 final int FRAC = 20; 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 714 int inc = (orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth()) / FRAC; 715 return Math.max(inc, 1); 716 } 717 718 public int getScrollableBlockIncrement( Rectangle visibleRect, int orientation, int direction ) { 719 return orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth(); 720 } 721 722 public boolean getScrollableTracksViewportWidth() { 723 return true; 724 } 725 726 public boolean getScrollableTracksViewportHeight() { 727 return false; 728 } 729 730 private int getPreferredHeight() { 731 int prefH = 0; 694 732 int num = getComponentCount(); 695 696 697 698 699 700 } 701 702 703 704 733 for (int i = 0; i < num; ++i) { 734 Rectangle rect = getComponent(i).getBounds(); 735 int h = rect.y + rect.height; 736 if (h > prefH) { 737 prefH = h; 738 } 739 } 740 prefH += ((FlowLayout) getLayout()).getVgap(); 741 return prefH; 742 } 705 743 } 706 744 } -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java
r21967 r21995 31 31 32 32 public class RoadSignsPlugin extends Plugin { 33 34 33 private static boolean presetsLoaded = false; 35 34 public static List<Sign> signs; 35 static List<String> iconDirs; 36 36 37 37 public RoadSignsPlugin(PluginInformation info) { … … 68 68 presetsLoaded=true; 69 69 List<String> files = new ArrayList<String>( 70 Main.pref.getCollection("plugin.roadsign.sources", 71 Collections.<String>singletonList("resource://data/defaultroadsignpreset.xml"))); 70 Main.pref.getCollection("plugin.roadsign.sources", 71 Collections.<String>singletonList("resource://data/defaultroadsignpreset.xml"))); 72 iconDirs = new ArrayList<String>( 73 Main.pref.getCollection("plugin.roadsign.icon.sources", Collections.<String>emptySet())); 74 75 if (Main.pref.getBoolean("plugin.roadsign.use_default_icon_source", true)) { 76 iconDirs.add("resource://images/"); 77 } 78 72 79 for (String source : files) { 73 80 try { -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java
r21967 r21995 107 107 curSign.isSupplementing = true; 108 108 } 109 110 curSign.wiki = atts.getValue("wiki"); 111 curSign.loc_wiki = getLocalized(atts, "wiki"); 112 113 curSign.help = getLocalized(atts, "help"); 109 114 110 115 } else if (curSign != null && qname.equals("tag")) { -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java
r21967 r21995 30 30 public List<SignParameter> params = new ArrayList<SignParameter>(); 31 31 public boolean isSupplementing; 32 public String loc_wiki; 33 public String wiki; 34 public String help; 32 35 33 36 public JLabel label; // FIXME: don't put gui stuff here … … 78 81 public ImageIcon getIcon() { 79 82 if (icon == null) { 80 icon = ImageProvider.get (iconURL);83 icon = ImageProvider.getIfAvailable(RoadSignsPlugin.iconDirs, "plugin.sign."+id, null, iconURL, null); 81 84 } 82 85 return icon;
Note:
See TracChangeset
for help on using the changeset viewer.