Ignore:
Timestamp:
2010-07-22T14:00:54+02:00 (15 years ago)
Author:
bastik
Message:

'added support for traffic_sign tag'

Location:
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/ParametrizedString.java

    r21967 r22420  
    1 //License: GPL (v2 or later)
     1// License: GPL (v2 or later)
    22package org.openstreetmap.josm.plugins.roadsigns;
    33
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java

    r21995 r22420  
    1111import java.awt.Rectangle;
    1212import java.awt.event.ActionEvent;
     13import java.awt.event.ActionListener;
    1314import java.awt.event.MouseAdapter;
    1415import java.awt.event.MouseEvent;
     
    2425
    2526import javax.swing.BorderFactory;
     27import javax.swing.JCheckBox;
    2628import javax.swing.JComponent;
    2729import javax.swing.JEditorPane;
     
    5254import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter;
    5355import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag;
     56import org.openstreetmap.josm.tools.GBC;
    5457import org.openstreetmap.josm.tools.OpenBrowser;
    5558import org.openstreetmap.josm.tools.Pair;
     
    6972 */
    7073class RoadSignInputDialog extends ExtendedDialog {
    71     private final SignSelection sel;
    72     private final List<Sign> signs;
    73     private JTable previewTable;
    74 
    75     private PreviewTableModel previewModel;
    76     private JPanel pnlSignSelection;
    77     private JPanel pnlPossibleSigns;
    78     private JPanel pnlPossibleSupplements;
    79     private JEditorPane info;
    80     private JScrollPane scrollInfo;
     74    protected final SignSelection sel;
     75    protected final List<Sign> signs;
     76    protected JTable previewTable;
     77    protected JCheckBox addTrafficSignTag;
     78
     79    protected PreviewTableModel previewModel;
     80    protected JPanel pnlSignSelection;
     81    protected JPanel pnlPossibleSigns;
     82    protected JPanel pnlPossibleSupplements;
     83    protected JEditorPane info;
     84    protected JScrollPane scrollInfo;
    8185
    8286    public RoadSignInputDialog(List<Sign> signs) {
     
    9397            Collection<OsmPrimitive> selPrim = Main.main.getCurrentDataSet().getSelected();
    9498            if (selPrim.size() != 0) {
     99                Main.pref.put("plugin.roadsigns.addTrafficSignTag", addTrafficSignTag.isSelected());
     100
    95101                Command cmd = createCommand(selPrim);
    96102                if (cmd != null) {
     
    464470
    465471    public JComponent buildPreviewPanel() {
     472        JPanel previewPanel = new JPanel(new GridBagLayout());
     473       
    466474        String[] columnNames = {tr("Key"), tr("Value")};
    467475        String[][] data = {{}};
    468         previewTable = new JTable(data, columnNames);
     476        previewTable = new JTable(data, columnNames) {
     477            public String getToolTipText(MouseEvent e) {
     478                int rowIndex = rowAtPoint(e.getPoint());
     479                int colIndex = columnAtPoint(e.getPoint());
     480                if (rowIndex == -1 || colIndex == -1)
     481                    return null;
     482                int realColumnIndex = convertColumnIndexToModel(colIndex);
     483                return (String) getValueAt(rowIndex, colIndex);
     484            }
     485        };
    469486        previewTable.setFillsViewportHeight(true);
    470487        previewTable.setRowSelectionAllowed(false);
     
    475492
    476493        JScrollPane scroll = new JScrollPane(previewTable);
    477         Dimension dim = new Dimension(236, 10);
     494        Dimension dim = new Dimension(336, 10);
    478495        scroll.setPreferredSize(dim);
    479496        scroll.setMinimumSize(dim); /* minimum size is relevant for multisplit layout */
    480         return scroll;
     497       
     498        addTrafficSignTag = new JCheckBox(tr("{0} tag", "traffic_sign"));
     499        addTrafficSignTag.setSelected(Main.pref.getBoolean("plugin.roadsigns.addTrafficSignTag"));
     500        addTrafficSignTag.addActionListener(new ActionListener() {
     501            public void actionPerformed(ActionEvent e) {
     502                previewModel.update();
     503            }
     504        });
     505       
     506        previewPanel.add(scroll, GBC.eol().fill());
     507        previewPanel.add(addTrafficSignTag, GBC.eol());
     508        return previewPanel;
    481509    }
    482510
     
    515543        public void update() {
    516544            final TreeMap<String, String> map= new TreeMap<String, String>();
     545            String traffic_sign = "";
     546           
    517547            for (SignCombination sc : sel.combos) {
    518548                final Map<String, String> env = new HashMap<String, String>();
     549                String combo_traffic_sign = "";
    519550
    520551                /**
     
    573604                    if (sw.sign.ref != null) {
    574605                        sw.signRef = sw.sign.ref.evaluate(env);
     606                        if (combo_traffic_sign.length() != 0) {
     607                            combo_traffic_sign += ",";
     608                        }
     609                        if (sw.sign.traffic_sign_tag != null) {
     610                            combo_traffic_sign += sw.sign.traffic_sign_tag.evaluate(env);
     611                        } else {
     612                            combo_traffic_sign += sw.signRef;
     613                        }
    575614                    }
    576615                    for (Tag t : sw.sign.tags) {
     
    615654                    map.putAll(result);
    616655                }
     656               
     657                if (combo_traffic_sign.length() != 0) {
     658                    if (traffic_sign.length() != 0) {
     659                        traffic_sign += ";";
     660                    }
     661                    traffic_sign += combo_traffic_sign;
     662                }
     663            }
     664            if (addTrafficSignTag.isSelected()) {
     665                map.put("traffic_sign", traffic_sign);
    617666            }
    618667
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java

    r21995 r22420  
    6868        presetsLoaded=true;
    6969        List<String> files = new ArrayList<String>(
    70                 Main.pref.getCollection("plugin.roadsign.sources",
     70                Main.pref.getCollection("plugin.roadsigns.sources",
    7171                    Collections.<String>singletonList("resource://data/defaultroadsignpreset.xml")));
    7272        iconDirs = new ArrayList<String>(
    73                 Main.pref.getCollection("plugin.roadsign.icon.sources", Collections.<String>emptySet()));
     73                Main.pref.getCollection("plugin.roadsigns.icon.sources", Collections.<String>emptySet()));
    7474
    75         if (Main.pref.getBoolean("plugin.roadsign.use_default_icon_source", true)) {
     75        if (Main.pref.getBoolean("plugin.roadsigns.use_default_icon_source", true)) {
    7676            iconDirs.add("resource://images/");
    7777        }
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java

    r21995 r22420  
    7777                try {
    7878                    curSign.ref = ParametrizedString.create(atts.getValue("ref"));
     79                    curSign.traffic_sign_tag = ParametrizedString.create(atts.getValue("traffic_sign_tag"));
    7980                } catch (ParseException ex) {
    8081                    throw new SAXException(ex);
     
    107108                    curSign.isSupplementing = true;
    108109                }
    109 
     110               
    110111                curSign.wiki = atts.getValue("wiki");
    111112                curSign.loc_wiki = getLocalized(atts, "wiki");
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java

    r21995 r22420  
    2121    public String id;
    2222    public ParametrizedString ref;
     23    public ParametrizedString traffic_sign_tag;
    2324    public String iconURL;
    2425    public ImageIcon icon;
     
    99100        r = r.replaceAll("\\[.*\\]", "");
    100101        if (r.startsWith("DE:")) {
    101             r=r.replaceFirst("DE:", "");
     102            r=r.replaceAll("DE:", "");
    102103            /* normal sign: starts with 3 digits, then a non-digit */
    103104            {
Note: See TracChangeset for help on using the changeset viewer.