Changeset 21995 in osm


Ignore:
Timestamp:
2010-06-24T22:08:15+02:00 (14 years ago)
Author:
bastik
Message:

minor improvements

Location:
applications/editors/josm/plugins/roadsigns
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/roadsigns/data/defaultroadsignpreset.xml

    r21967 r21995  
    33Preset file for road signs plugin.
    44
    5 Plugin is in early state of development (05-2010) and it is likely, the preset format will be changing.
     5The plugin is in early state of development (05-2010) and the format is likely to change.
     6
     7How to customize
     8================
     9
     10Add the following to your JOSM preference file
     11(or enter it in the advanced preferences tab in JOSM):
     12
     13plugin.roadsign.sources=/path/to/myroadsignpreset.xml
     14plugin.roadsign.icon.sources=/path/to/image/folder
     15
     16(The second one is only needed if you like to display your own icons.)
     17
     18
     19Preset format
     20=============
     21
    622Some values can contain parameters like $foo, that will be replaced by the value of the parameter named foo.
    723
     
    925    ref             Short official designation of the sign that can be used for the traffic_sign tag. (accepts parameters)
    1026    id              Unique identifier. (If missing, equals ref. Either id or ref must be present.)
    11     icon            Icon path. (If missing, id or ref is used as icon path. In this case ':' and '.' characters are converted to underscore '_'.)
     27    icon            Icon image name. (If missing, id or ref is used as image name. In this case ':' and '.' characters are converted to underscore '_'.)
    1228    name            Name of the sign. (required)
    13     long_name       Official name of the sign. (optional)
     29    long_name       Long (e.g. official) name of the sign.
    1430    help            Some notes to guide the user.
    1531    wiki            Page in the osm wiki
    16     deprecated      Set to "yes" if authorities have decided to no longer install signs of this kind. 
     32    deprecated      Set to "yes" if authorities have decided to no longer install signs of this kind.
    1733                    (But old signs may still be there and need to be recorded.)
    18    
     34
    1935tag:
     36    Some tags can be named (ident=*) and modified by other subsequent tags. If this finally results in an
     37    empty value (""), then the tag is skipped altogether. Note that the default value of a named tag is
     38    only used if there are no appending tags. E.g. access=no becomes access=delivery and not access=no;delivery.
     39
    2040    static tags:
    2141        key             The key text. (accepts parameters)
    2242        value           The value text. (accepts parameters)
    23    
    24     identified tags:
     43
     44    named tags:
    2545        key             The key text.
    2646        value           The default value text. If the final evaluation of the value results in an empty string, the tag is dropped.
    2747        ident           Name a tag so it can later be changed by other tags.
    28    
     48
    2949    modifying tags:
    30         tag_ref         Name of the tag to be changed.
    31         append_value    Append a string to the value of the tag. The default value of the identified tag is dropped (unless there is no
    32                         modifying tag appending a value).
    33            
     50        appending:
     51            tag_ref         Name of the tag to be changed.
     52            append_value    Append a string to the value of the tag. The default value of the identified tag is dropped (unless there is no
     53                            modifying tag appending a value).
     54        condition:
     55            tag_ref         Name of the tag to be changed.
     56            condition       The condition to add. (K=V becomes K:cond=V.)
     57
    3458parameter:
    3559    ident           identifier to get the value of this parameter (required)
     
    3963    field_width     for text fields: the width of the field (number of characters)
    4064    default         default value (required)
    41    
     65
    4266supplementary: (list of recommended additional signs)
    4367    id         the id of the supplementary sign
     
    4670<roadsignpreset country="DE">
    4771    <sign ref="DE:110" name="Incline" de.name="Steigung"
    48             help="Applies for the road section with steep incline. (Split the way at the ends of the steep section.) \
     72            help="Applies for the road section with steep incline. (Split the way at the ends of the steep section.)
    4973Positive values indicate movement upward in the direction of the (osm) way and negative values indicate movement downwards in the direction of the way."
    50             de.help="&lt;p&gt;Gilt für das Streckenstück mit hoher Steigung. (Weg am Anfang und Ende des steilen Abschnittes auftrennen.) \
    51 Positive Werte stehen für einen Anstieg in Richtung des ways und negative Werte für einen Abfall in Richtung des ways.&lt;/p&gt;\"
    52             wiki="Key:incline" 
     74            de.help="Gilt für das Streckenstück mit hoher Steigung. (Weg am Anfang und Ende des steilen Abschnittes auftrennen.)
     75Positive Werte stehen für einen Anstieg in Richtung des ways und negative Werte für einen Abfall in Richtung des ways."
     76            wiki="Key:incline"
    5377            de.wiki="DE:Key:incline">
    5478        <tag key="incline" value="$val%"/>
    5579        <parameter input="textfield" name="max. incline" de.name="Maximale Steigung" type="int" ident="val" default="12" suffix="%" field_width="3"/>
    5680    </sign>
    57    
     81
    5882    <sign ref="DE:215" name="Roundabout" de.name="Kreisverkehr"
    5983        wiki="Tag:junction=roundabout"
    60         de.wiki="DE:Tag:junction=roundabout"
    61         help=""
    62         de.help="">
     84        de.wiki="DE:Tag:junction=roundabout">
    6385        <tag key="junction" value="roundabout"/>
    6486    </sign>
    65    
     87
    6688    <sign id="oneway" icon="DE_220;DE_267" name="One-way road" de.name="Einbahnstraße">  <!--ref="DE:220;DE:267"-->
    6789        <tag key="oneway" value="yes"/>
     
    6991<!--        FIXME: lane->-->
    7092    </sign>
    71    
     93
    7294    <sign ref="DE:237" name="Bicycle path" de.name="Radweg">
    7395        <tag key="highway" value="path"/>
     
    87109        <supplementary id="DE:1026-38"/> <!-- Land- und forstwirtschaftlicher Verkehr frei -->
    88110    </sign>
    89    
     111
    90112    <sign ref="DE:239" name="Pedestrian path" de.name="Gehweg">
    91113        <tag key="highway" value="path"/>
     
    139161        <!-- Kraftfahrzeuge frei -->
    140162    </sign>
    141    
     163
    142164    <sign ref="DE:250" name="All vehicles prohibited" de.name="Verbot für Fahrzeuge aller Art">
    143165        <tag key="vehicle" value="no" ident="mode"/>
     
    154176        <supplementary id="DE:1026-38"/> <!-- Land- und forstwirtschaftlicher Verkehr frei -->
    155177    </sign>
    156    
     178
    157179    <sign ref="DE:251" name="Motorcars prohibited" de.name="Verbot für Kraftwagen"
    158             long_name="Motorcars and other multi-track motorized vehicles prohibited" 
     180            long_name="Motorcars and other multi-track motorized vehicles prohibited"
    159181            de.long_name="Verbot für Kraftwagen und sonstige mehrspurige Kraftfahrzeuge"
    160182            wiki="Key:motorcar"
     
    196218        <supplementary id="DE:1026-35"/> <!-- Lieferverkehr frei -->
    197219    </sign>
    198    
     220
    199221    <sign ref="DE:256" deprecated="yes" name="Mopeds prohibited" de.name="Verbot für Mofas">
    200222        <tag key="mofa" value="no" ident="mode"/>
     
    206228        <tag key="horse" value="no" ident="mode"/>
    207229    </sign>
    208    
     230
    209231    <sign ref="DE:259" name="Pedestrians prohibited" de.name="Verbot für Fußgänger">
    210232        <tag key="foot" value="no" ident="mode"/>
    211233        <supplementary id="DE:1020-30"/> <!-- Anlieger frei -->
    212234    </sign>
    213    
     235
    214236    <sign ref="DE:260" name="Motor vehicles prohibited" de.name="Verbot für Kraftfahrzeuge"
    215237        long_name="Motorcycles, also with sidecar, mopeds, mofas as well as motorcars and other multi-track motorized vehicles prohibited"
     
    226248    </sign>
    227249
    228     <sign ref="DE:261" name="Hazardous cargo prohibited" de.name="Verbot für kennzeichnungspflichtige Kraftfahrzeuge mit gefährlichen Gütern" wiki="Key:hazmat" de.wiki="DE:Key:hazmat">
    229         <tag key="hazmat" value="no" ident="mode"/>       
    230     </sign>
    231    
     250    <sign ref="DE:261" name="Hazardous cargo prohibited" de.name="Verbot für kennzeichnungspflichtige Kraftfahrzeuge mit gefährlichen Gütern"
     251            wiki="Key:hazmat"
     252            de.wiki="DE:Key:hazmat">
     253        <tag key="hazmat" value="no" ident="mode"/>
     254    </sign>
     255
    232256    <sign ref="DE:262[$val]" icon="DE_262" name="Weight limit" de.name="Tatsächliches Gewicht" wiki="Key:maxweight">
    233257        <tag key="maxweight" value="$val"/>
    234258        <parameter ident="val" input="textfield" default="5.5" suffix="t" field_width="3"/>
    235259    </sign>
    236    
     260
    237261    <sign ref="DE:263[$val]" icon="DE_263" name="Axle weight limit" de.name="Tatsächliche Achslast" wiki="Key:maxaxleload">
    238262        <tag key="maxaxleload" value="$val"/>
    239263        <parameter ident="val" input="textfield" default="8" suffix="t" field_width="3"/>
    240264    </sign>
    241    
     265
    242266    <sign ref="DE:264[$val]" icon="DE_264" name="Width limit" de.name="Tatsächliche Breite">
    243267        <tag key="maxwidth" value="$val"/>
    244268        <parameter ident="val" input="textfield" default="2" suffix="m" field_width="3"/>
    245269    </sign>
    246    
     270
    247271    <sign ref="DE:265[$val]" icon="DE_265" name="Height limit" de.name="Tatsächliche Höhe">
    248272        <tag key="maxheight" value="$val"/>
     
    250274    </sign>
    251275
    252     <sign ref="DE:266[$val]" icon="DE_266" name="Length limit" de.name="Tatsächliche Länge" 
     276    <sign ref="DE:266[$val]" icon="DE_266" name="Length limit" de.name="Tatsächliche Länge"
    253277            wiki="Key:maxlength">
    254278        <tag key="maxlength" value="$val"/>
    255279        <parameter ident="val" input="textfield" default="10" suffix="m" field_width="3"/>
    256280    </sign>
    257    
    258     <sign ref="DE:269" name="Water polluting cargo prohibited" de.name="Verbot für Fahrzeuge mit wassergefährdender Ladung" 
    259             wiki="Key:hazmat" 
     281
     282    <sign ref="DE:269" name="Water polluting cargo prohibited" de.name="Verbot für Fahrzeuge mit wassergefährdender Ladung"
     283            wiki="Key:hazmat"
    260284            de.wiki="DE:Key:hazmat">
    261285        <tag key="hazmat:water" value="no" ident="mode"/>
     
    268292        <supplementary id="DE:1048-12"/> <!-- nur LKW -->
    269293    </sign>
    270    
     294
    271295    <sign ref="DE:274.1[$val]" icon="DE_274_1" name="Speed limit zone" de.name="Zone mit zulässiger Höchstgeschwindigkeit">
    272296        <tag key="maxspeed" value="$val"/>
     
    274298        <parameter ident="val" type="int" input="combo" editable="yes" text="speed-limit" de.text="Höchstgeschwindigkeit" suffix="km/h" values="20,30" default="30" field_width="2"/>
    275299    </sign>
    276    
     300
    277301    <sign ref="DE:275[$val]" icon="DE_275" name="Minimum speed limit" de.name="Vorgeschriebene Mindestgeschwindigkeit" wiki="Key:minspeed">
    278302        <tag key="minspeed" value="$val"/>
     
    283307        <tag key="highway" value="living_street"/>
    284308    </sign>
    285    
     309
    286310    <sign ref="DE:327" name="Tunnel" de.name="Tunnel">
    287311        <tag key="tunnel" value="yes"/>
    288312    </sign>
    289    
     313
    290314    <sign ref="DE:1020-12" supplementary="yes" name="Bicyle and residents allowed" de.name="Radfahrer und Anlieger frei"> <!-- FIXME: bad translation into English -->
    291315        <tag key="bicycle" value="yes"/>
     
    331355        <tag tag_ref="mode" append_value="delivery"/>
    332356    </sign>
    333    
     357
    334358    <sign ref="DE:1026-36" supplementary="yes" name="Agricultural vehicles allowed" de.name="Landwirtschaftlicher Verkehr frei">
    335359        <tag tag_ref="mode" append_value="agricultural"/>
    336360    </sign>
    337    
     361
    338362    <sign ref="DE:1026-37" supplementary="yes" name="Forestry vehicles allowed" de.name="Forstwirtschaftlicher Verkehr frei">
    339363        <tag tag_ref="mode" append_value="forestry"/>
     
    344368        <tag tag_ref="mode" append_value="forestry"/>
    345369    </sign>
    346    
     370
    347371    <sign ref="DE:1048-12" supplementary="yes" name="Heavy goods vehicles only" de.name="nur LKW"
    348372            long_name="Vehicles with a permitted gross weight over 3.5 t including their trailers prohibited, except passenger cars and busses, only"
    349             de.long_name="nur Kraftfahrzeuge mit einem zulässigen Gesamtgewicht über 3,5 t, einschl. ihrer Anhänger, und Zugmaschinen, ausgenommen Personenkraftwagen und Kraftomnibusse">
     373            de.long_name="Nur Kraftfahrzeuge mit einem zulässigen Gesamtgewicht über 3,5 t, einschl. ihrer Anhänger, und Zugmaschinen, ausgenommen Personenkraftwagen und Kraftomnibusse">
    350374        <tag tag_ref="restriction" condition="hgv"/>
    351375    </sign>
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java

    r21967 r21995  
    3333import javax.swing.Scrollable;
    3434import javax.swing.SwingConstants;
     35import javax.swing.SwingUtilities;
    3536import javax.swing.border.Border;
    3637import javax.swing.border.EtchedBorder;
    3738import javax.swing.event.DocumentEvent;
    3839import javax.swing.event.DocumentListener;
     40import javax.swing.event.HyperlinkEvent;
     41import javax.swing.event.HyperlinkListener;
    3942import javax.swing.table.AbstractTableModel;
    4043
     
    4952import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter;
    5053import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag;
     54import org.openstreetmap.josm.tools.OpenBrowser;
    5155import org.openstreetmap.josm.tools.Pair;
    5256
     
    7478    private JPanel pnlPossibleSupplements;
    7579    private JEditorPane info;
     80    private JScrollPane scrollInfo;
    7681
    7782    public RoadSignInputDialog(List<Sign> signs) {
     
    126131        pnlSignSelection.setLayout(fLayout);
    127132
    128        
    129133        pnlPossibleSigns = new FixedWidthPanel();
    130134        pnlPossibleSupplements = new FixedWidthPanel();
     
    146150        info.setEditable(false);
    147151        info.setContentType("text/html");
    148         info.setText("");
     152        info.setText(" ");
    149153        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");
    152167
    153168        return multiSplitPane;
     
    162177        for (Sign s : signs) {
    163178            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);
    164186            s.label = lbl;
    165187            lbl.addMouseListener(new SignClickListener(s));
     
    621643        @Override
    622644        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            });
    623652            sel.add(sign);
    624653        }
    625654
    626         @Override
    627         public void mouseEntered(MouseEvent e) {
     655        private String longText() {
    628656            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);
    632658            String ref = sign.getDefaultRef();
    633659            if (ref != null) {
    634660                txt.append("  <i><small>("+ref+")</small></i>");
    635661            }
    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();
    646684        }
    647685    }
     
    660698        @Override
    661699        public void setBounds(int x, int y, int width, int height) {
    662                         super.setBounds(x, y, getParent().getWidth(), height);
    663                 }
     700            super.setBounds(x, y, getParent().getWidth(), height);
     701        }
    664702
    665703        @Override
    666                 public Dimension getPreferredSize() {
    667                         return new Dimension(getWidth(), getPreferredHeight());
    668                 }
    669 
    670                 public Dimension getPreferredScrollableViewportSize() {
    671                         return super.getPreferredSize();
    672                 }
    673 
    674                 public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) {
     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 ) {
    675713            final int FRAC = 20;
    676                         int inc = (orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth()) / FRAC;
    677                         return Math.max(inc, 1);
    678                 }
    679 
    680                 public int getScrollableBlockIncrement( Rectangle visibleRect, int orientation, int direction ) {
    681                         return orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth();
    682                 }
    683 
    684                 public boolean getScrollableTracksViewportWidth() {
    685                         return true;
    686                 }
    687 
    688                 public boolean getScrollableTracksViewportHeight() {
    689                         return false;
    690                 }
    691 
    692                 private int getPreferredHeight() {
    693                         int prefH = 0;
     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;
    694732            int num = getComponentCount();
    695                         for (int i = 0; i < num; ++i) {
    696                                 Rectangle rect = getComponent(i).getBounds();
    697                                 int h = rect.y + rect.height;
    698                                 if (h > prefH) {
    699                                         prefH = h;
    700                 }
    701                         }
    702                         prefH += ((FlowLayout) getLayout()).getVgap();
    703                         return prefH;
    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        }
    705743    }
    706744}
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java

    r21967 r21995  
    3131
    3232public class RoadSignsPlugin extends Plugin {
    33 
    3433    private static boolean presetsLoaded = false;
    3534    public static List<Sign> signs;
     35    static List<String> iconDirs;
    3636
    3737    public RoadSignsPlugin(PluginInformation info) {
     
    6868        presetsLoaded=true;
    6969        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
    7279        for (String source : files) {
    7380            try {
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java

    r21967 r21995  
    107107                    curSign.isSupplementing = true;
    108108                }
     109
     110                curSign.wiki = atts.getValue("wiki");
     111                curSign.loc_wiki = getLocalized(atts, "wiki");
     112
     113                curSign.help = getLocalized(atts, "help");
    109114
    110115            } else if (curSign != null && qname.equals("tag")) {
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java

    r21967 r21995  
    3030    public List<SignParameter> params = new ArrayList<SignParameter>();
    3131    public boolean isSupplementing;
     32    public String loc_wiki;
     33    public String wiki;
     34    public String help;
    3235
    3336    public JLabel label; // FIXME: don't put gui stuff here
     
    7881    public ImageIcon getIcon() {
    7982        if (icon == null) {
    80             icon = ImageProvider.get(iconURL);
     83            icon = ImageProvider.getIfAvailable(RoadSignsPlugin.iconDirs, "plugin.sign."+id, null, iconURL, null);
    8184        }
    8285        return icon;
Note: See TracChangeset for help on using the changeset viewer.