Ignore:
Timestamp:
2014-12-19T17:12:01+01:00 (10 years ago)
Author:
donvip
Message:

[josm_cadastre-fr] replace calls to System.out/err by calls to Main.info/warn/error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java

    r30737 r30859  
    4343
    4444import org.openstreetmap.josm.Main;
     45import org.openstreetmap.josm.actions.mapmode.MapMode;
    4546import org.openstreetmap.josm.command.AddCommand;
    4647import org.openstreetmap.josm.command.ChangeCommand;
     
    4849import org.openstreetmap.josm.command.Command;
    4950import org.openstreetmap.josm.command.SequenceCommand;
    50 import org.openstreetmap.josm.actions.mapmode.MapMode;
    5151import org.openstreetmap.josm.data.coor.EastNorth;
    5252import org.openstreetmap.josm.data.osm.Node;
     
    6565public class Address extends MapMode implements MouseListener, MouseMotionListener, ActionListener {
    6666    private static final long serialVersionUID = 1L;
    67    
     67
    6868    // perhaps make all these tags configurable in the future
    6969    private String tagHighway = "highway";
     
    7676    private String relationAddrStreetRole = "street";
    7777    private String relationMemberHouse = "house";
    78    
     78
    7979    private JRadioButton plus_one = new JRadioButton("+1", false);
    8080    private JRadioButton plus_two = new JRadioButton("+2", true); // enable this by default
     
    9393
    9494    public Address(MapFrame mapFrame) {
    95         super(tr("Add address"), "buildings", 
     95        super(tr("Add address"), "buildings",
    9696                tr("Helping tool for tag address"),
    9797                Shortcut.registerShortcut("mapmode:cadastre-fr-buildings", tr("Mode: {0}", tr("CadastreFR - Buildings")), KeyEvent.VK_E, Shortcut.DIRECT),
     
    153153                    try {
    154154                        // add new address
    155                         Integer.parseInt(num); 
     155                        Integer.parseInt(num);
    156156                        inputNumber.setText(num);
    157157                        applyInputNumberChange();
    158158                    } catch (NumberFormatException en) {
    159                         System.out.println("Unable to parse house number \"" + num + "\"");
     159                        Main.warn("Unable to parse house number \"" + num + "\"");
    160160                    }
    161161                }
     
    202202                setNewSelection(mouseOnExistingWays.get(0));
    203203            } else if (mouseOnExistingWays.size() == 0) {
    204                 // clicked a non highway and not a node => add the new address 
     204                // clicked a non highway and not a node => add the new address
    205205                if (inputStreet.getText().equals("") || inputNumber.getText().equals("")) {
    206206                    Toolkit.getDefaultToolkit().beep();
     
    221221
    222222    }
    223    
     223
    224224    private Way findWayInRelationAddr(Node n) {
    225225        List<OsmPrimitive> l = n.getReferrers();
     
    238238        return null;
    239239    }
    240    
     240
    241241    private void addAddrToPolygon(List<Way> mouseOnExistingBuildingWays, Collection<Command> cmds) {
    242242        for (Way w:mouseOnExistingBuildingWays) {
     
    244244        }
    245245    }
    246    
     246
    247247    private void addAddrToPrimitive(OsmPrimitive osm, Collection<Command> cmds) {
    248248        // add the current tag addr:housenumber in node and member in relation (if so configured)
     
    251251                revertInputNumberChange();
    252252            } catch (NumberFormatException en) {
    253                 System.out.println("Unable to parse house number \"" + inputNumber.getText() + "\"");
     253                Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
    254254            }
    255255
     
    263263            setNewSelection(osm);
    264264        } catch (NumberFormatException en) {
    265             System.out.println("Unable to parse house number \"" + inputNumber.getText() + "\"");
    266         }
    267     }
    268    
     265                Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
     266        }
     267    }
     268
    269269    private Relation findRelationAddr(Way w) {
    270270        List<OsmPrimitive> l = w.getReferrers();
     
    276276        return null;
    277277    }
    278    
     278
    279279    private void addStreetNameOrRelation(OsmPrimitive osm, Collection<Command> cmds) {
    280280        if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {
     
    339339        return n;
    340340    }
    341    
     341
    342342    private static void adjustNode(Collection<Pair<Node,Node>> segs, Node n) {
    343343
     
    395395        }
    396396    }
    397    
     397
    398398    static double det(double a, double b, double c, double d) {
    399399        return a * d - b * c;
     
    422422        return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
    423423    }
    424    
     424
    425425    private void applyInputNumberChange() {
    426426        Integer num = Integer.parseInt(inputNumber.getText());
     
    435435        inputNumber.setText(num.toString());
    436436    }
    437    
     437
    438438    private void revertInputNumberChange() {
    439439        Integer num = Integer.parseInt(inputNumber.getText());
     
    448448        inputNumber.setText(num.toString());
    449449    }
    450    
     450
    451451    private void createDialog() {
    452452        ImageIcon iconLink = ImageProvider.get(null, "Mf_relation.png");
     
    466466        clearButton = new JButton("Clear");
    467467        clearButton.addActionListener(new ActionListener() {
    468             public void actionPerformed(ActionEvent e) {
     468            @Override
     469                        public void actionPerformed(ActionEvent e) {
    469470                inputNumber.setText("");
    470471                inputStreet.setText("");
     
    491492        p.add(plus_two, GBC.std().insets(0, 0, 10, 0));
    492493        p.add(clearButton, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0));
    493    
     494
    494495        final Object[] options = {};
    495496        final JOptionPane pane = new JOptionPane(p,
     
    516517                Main.map.selectMapMode((MapMode)Main.map.getDefaultButtonAction());
    517518            }
    518             public void windowClosed(WindowEvent e) {}
    519             public void windowActivated(WindowEvent arg0) {}
    520             public void windowDeactivated(WindowEvent arg0) {}
    521             public void windowDeiconified(WindowEvent arg0) {}
    522             public void windowIconified(WindowEvent arg0) {}
    523             public void windowOpened(WindowEvent arg0) {}
     519            @Override
     520                        public void windowClosed(WindowEvent e) {}
     521            @Override
     522                        public void windowActivated(WindowEvent arg0) {}
     523            @Override
     524                        public void windowDeactivated(WindowEvent arg0) {}
     525            @Override
     526                        public void windowDeiconified(WindowEvent arg0) {}
     527            @Override
     528                        public void windowIconified(WindowEvent arg0) {}
     529            @Override
     530                        public void windowOpened(WindowEvent arg0) {}
    524531        });
    525532        String bounds = Main.pref.get("cadastrewms.addr.bounds",null);
     
    530537        }
    531538}
    532    
     539
    533540    private void setSelectedWay(Way w) {
    534541        this.selectedWay = w;
     
    539546        link.repaint();
    540547    }
    541    
     548
    542549    private void setNewSelection(OsmPrimitive osm) {
    543550        Collection<OsmPrimitive> newSelection = new LinkedList<>(Main.main.getCurrentDataSet().getSelected());
Note: See TracChangeset for help on using the changeset viewer.