Ignore:
Timestamp:
2010-09-15T18:56:19+02:00 (14 years ago)
Author:
stoecker
Message:

remove tabs

Location:
applications/editors/josm/plugins/terracer/src/terracer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java

    r22018 r23191  
    7575    JCheckBox deleteOutlineCheckBox;
    7676
    77         HouseNumberInputHandler inputHandler;
     77    HouseNumberInputHandler inputHandler;
    7878
    7979    /**
     
    102102    }
    103103
    104         /**
     104    /**
    105105     * This method initializes this
    106106     *
     
    111111        this.hi.addFocusListener(this.inputHandler);
    112112        this.segments.addFocusListener(this.inputHandler);
    113                 this.interpolation.addItemListener(this.inputHandler);
     113        this.interpolation.addItemListener(this.inputHandler);
    114114    }
    115115
     
    136136        if (inputPanel == null) {
    137137
    138                 GridBagConstraints c = new GridBagConstraints();
    139 
    140                 messageLabel = new JTextArea();
     138            GridBagConstraints c = new GridBagConstraints();
     139
     140            messageLabel = new JTextArea();
    141141            messageLabel.setText(DEFAULT_MESSAGE);
    142142            messageLabel.setAutoscrolls(true);
     
    168168            inputPanel.setLayout(new GridBagLayout());
    169169            c.fill = GridBagConstraints.HORIZONTAL;
    170                         c.gridwidth = GridBagConstraints.REMAINDER;
     170            c.gridwidth = GridBagConstraints.REMAINDER;
    171171            inputPanel.add(messageLabel, c);
    172172
     
    191191    }
    192192
    193         /**
     193    /**
    194194     * Overrides the default actions. Will not close the window when upload trace is clicked
    195195     */
     
    268268            interpolation.add(tr("Even/Odd"));
    269269            if (Main.pref.getInteger(INTERPOLATION, 2) == 1) {
    270                 interpolation.select(tr("All"));
     270                interpolation.select(tr("All"));
    271271            } else {
    272                 interpolation.select(tr("Even/Odd"));
     272                interpolation.select(tr("Even/Odd"));
    273273            }
    274274            //return (dialog.interpolation.getSelectedItem().equals(tr("All"))) ? 1 : 2;
  • applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java

    r21169 r23191  
    6161        this.street = street;
    6262        this.associatedStreet = associatedStreet;
    63        
     63
    6464        // This dialog is started modal
    6565        this.dialog = new HouseNumberInputDialog(this, street, associatedStreet != null);
    66        
     66
    6767        // We're done
    6868    }
    6969
    70         /**
    71         * Find a button with a certain caption.
    72         * Loops recursively through all objects to find all buttons.
    73         * Function returns on the first match.
    74         *
    75         * @param root A container object that is recursively searched for other containers or buttons
    76         * @param caption The caption of the button that is being searched
    77         *
    78         * @return The first button that matches the caption or null if not found
    79         */
    80         private static JButton getButton(Container root, String caption) {
    81                 Component children[] = root.getComponents();
     70    /**
     71    * Find a button with a certain caption.
     72    * Loops recursively through all objects to find all buttons.
     73    * Function returns on the first match.
     74    *
     75    * @param root A container object that is recursively searched for other containers or buttons
     76    * @param caption The caption of the button that is being searched
     77    *
     78    * @return The first button that matches the caption or null if not found
     79    */
     80    private static JButton getButton(Container root, String caption) {
     81        Component children[] = root.getComponents();
    8282         for (Component child : children) {
    83                 JButton b;
    84                 if (child instanceof JButton) {
    85                                 b = (JButton) child;
    86                                 if (caption.equals(b.getText())) return b;
    87                         } else if (child instanceof Container) {
     83            JButton b;
     84            if (child instanceof JButton) {
     85                b = (JButton) child;
     86                if (caption.equals(b.getText())) return b;
     87            } else if (child instanceof Container) {
    8888                  b = getButton((Container)child, caption);
    8989                  if (b != null) return b;
    9090             }
    9191         }
    92                 return null;
    93         }
    94        
     92        return null;
     93    }
     94
    9595    /**
    9696     * Validate the current input fields.
     
    110110        // Allow non numeric characters for the low number as long as there is no high number of the segmentcount is 1
    111111        if (dialog.hi.getText().length() > 0 | segments() > 1) {
    112                     isOk = isOk
    113                             && checkNumberStringField(dialog.lo, tr("Lowest number"),
    114                                     message);
    115                 }
     112            isOk = isOk
     113                    && checkNumberStringField(dialog.lo, tr("Lowest number"),
     114                            message);
     115        }
    116116        isOk = isOk
    117117                && checkNumberStringField(dialog.hi, tr("Highest number"),
     
    124124            JButton okButton = getButton(dialog, "OK");
    125125            if (okButton != null)
    126                 okButton.setEnabled(true);
    127            
     126                okButton.setEnabled(true);
     127
    128128            // For some reason the messageLabel doesn't want to show up
    129129            dialog.messageLabel.setForeground(Color.black);
     
    133133            JButton okButton = getButton(dialog, "OK");
    134134            if (okButton != null)
    135                         okButton.setEnabled(false);
    136                                
    137                 // For some reason the messageLabel doesn't want to show up, so a MessageDialog is shown instead. Someone more knowledgeable might fix this.
    138                 dialog.messageLabel.setForeground(Color.red);
    139                 dialog.messageLabel.setText(message.toString());
    140                 //JOptionPane.showMessageDialog(null, message.toString(), tr("Error"), JOptionPane.ERROR_MESSAGE);
     135                okButton.setEnabled(false);
     136
     137            // For some reason the messageLabel doesn't want to show up, so a MessageDialog is shown instead. Someone more knowledgeable might fix this.
     138            dialog.messageLabel.setForeground(Color.red);
     139            dialog.messageLabel.setText(message.toString());
     140            //JOptionPane.showMessageDialog(null, message.toString(), tr("Error"), JOptionPane.ERROR_MESSAGE);
    141141
    142142            return false;
     
    273273            JButton button = (JButton) e.getSource();
    274274            if ("OK".equals(button.getActionCommand()) & button.isEnabled()) {
    275                 if (validateInput()) {
    276                             saveValues();
    277                            
    278                                 terracerAction.terraceBuilding(
    279                                     outline,
    280                                     street,
    281                                     associatedStreet,
    282                                     segments(),
    283                                     dialog.lo.getText(),
    284                                     dialog.hi.getText(),
    285                                     stepSize(),
    286                                     streetName(),
    287                                     doHandleRelation(),
    288                                     doDeleteOutline());
    289                                
    290                             this.dialog.dispose();
    291                         }
     275                if (validateInput()) {
     276                    saveValues();
     277
     278                    terracerAction.terraceBuilding(
     279                        outline,
     280                        street,
     281                        associatedStreet,
     282                        segments(),
     283                        dialog.lo.getText(),
     284                        dialog.hi.getText(),
     285                        stepSize(),
     286                        streetName(),
     287                        doHandleRelation(),
     288                        doDeleteOutline());
     289
     290                    this.dialog.dispose();
     291                }
    292292            } else if ("Cancel".equals(button.getActionCommand())) {
    293293                this.dialog.dispose();
     
    357357        if (street != null)
    358358            return null;
    359            
     359
    360360        Object selected = dialog.streetComboBox.getSelectedItem();
    361361        if (selected == null) {
     
    376376     */
    377377    public boolean doHandleRelation() {
    378         if (this.dialog == null) {
    379                 JOptionPane.showMessageDialog(null, "dialog", "alert", JOptionPane.ERROR_MESSAGE);
    380         }
    381         if (this.dialog.handleRelationCheckBox == null) {
    382                 JOptionPane.showMessageDialog(null, "checkbox", "alert", JOptionPane.ERROR_MESSAGE);
    383                 return true;
    384         }  else {
    385                 return this.dialog.handleRelationCheckBox.isSelected();
    386         }
    387     }
    388 
    389    
     378        if (this.dialog == null) {
     379            JOptionPane.showMessageDialog(null, "dialog", "alert", JOptionPane.ERROR_MESSAGE);
     380        }
     381        if (this.dialog.handleRelationCheckBox == null) {
     382            JOptionPane.showMessageDialog(null, "checkbox", "alert", JOptionPane.ERROR_MESSAGE);
     383            return true;
     384        }  else {
     385            return this.dialog.handleRelationCheckBox.isSelected();
     386        }
     387    }
     388
     389
    390390    /**
    391391     * Whether the user likes to delete the outline way.
     
    394394        return dialog.deleteOutlineCheckBox.isSelected();
    395395    }
    396    
     396
    397397    /* (non-Javadoc)
    398398     * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
    399399     */
    400400    public void focusGained(FocusEvent e) {
    401                 // Empty, but placeholder is required
     401        // Empty, but placeholder is required
    402402    }
    403403
     
    406406     */
    407407    public void focusLost(FocusEvent e) {
    408         if (e.getOppositeComponent() == null)
    409                 return;
     408        if (e.getOppositeComponent() == null)
     409            return;
    410410
    411411        validateInput();
  • applications/editors/josm/plugins/terracer/src/terracer/ReverseTerraceAction.java

    r19678 r23191  
    7878            }
    7979        }
    80        
     80
    8181        if (front.isEmpty()) {
    8282            JOptionPane.showMessageDialog(Main.parent,
    8383                    tr("Cannot reverse!"));
    8484            return;
    85         }               
     85        }
    8686
    8787        // This is like a visitedWays set, but in a linear order.
     
    130130    protected void updateEnabledState() {
    131131        setEnabled(getCurrentDataSet() != null);
    132     }   
     132    }
    133133}
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java

    r21376 r23191  
    5858    // repeated terraces. this is the easiest, but not necessarily nicest, way.
    5959    // private static String lastSelectedValue = "";
    60        
    61         Collection<Command> commands;
    62        
     60
     61    Collection<Command> commands;
     62
    6363    public TerracerAction() {
    6464        super(tr("Terrace a building"), "terrace",
     
    152152    }
    153153
    154         public Integer getNumber(String number) {
    155                 try {
     154    public Integer getNumber(String number) {
     155        try {
    156156            return Integer.parseInt(number);
    157157        } catch (NumberFormatException ex) {
    158158            return null;
    159159        }
    160         }
    161        
     160    }
     161
    162162    /**
    163163     * Terraces a single, closed, quadrilateral way.
     
    178178     */
    179179    public void terraceBuilding(Way outline,
    180                                 Way street,
    181                                 Relation associatedStreet,
    182                                 Integer segments,
    183                                 String From,
    184                                 String To,
    185                                 int step,
    186                                 String streetName,
    187                                 boolean handleRelations,
    188                                 boolean deleteOutline) {
     180                Way street,
     181                Relation associatedStreet,
     182                Integer segments,
     183                String From,
     184                String To,
     185                int step,
     186                String streetName,
     187                boolean handleRelations,
     188                boolean deleteOutline) {
    189189        final int nb;
    190        
     190
    191191        Integer to, from;
    192192        to = getNumber(To);
     
    210210        Collection<Way> ways = new LinkedList<Way>();
    211211
    212                 // Should this building be terraced (i.e. is there more then one section?)
    213                 if (nb > 1) {
    214                     // create intermediate nodes by interpolating.
    215                    
    216                     // now find which is the longest side connecting the first node
    217                         Pair<Way, Way> interp = findFrontAndBack(outline);
    218 
    219                         final double frontLength = wayLength(interp.a);
    220                         final double backLength = wayLength(interp.b);
    221                        
    222                     for (int i = 0; i <= nb; ++i) {
    223                         new_nodes[0][i] = interpolateAlong(interp.a, frontLength * i / nb);
    224                         new_nodes[1][i] = interpolateAlong(interp.b, backLength * i / nb);
    225                         this.commands.add(new AddCommand(new_nodes[0][i]));
    226                         this.commands.add(new AddCommand(new_nodes[1][i]));
    227                     }
    228 
    229                     // assemble new quadrilateral, closed ways
    230                     for (int i = 0; i < nb; ++i) {
    231                         Way terr = new Way();
    232                         // Using Way.nodes.add rather than Way.addNode because the latter
    233                         // doesn't
    234                         // exist in older versions of JOSM.
    235                         terr.addNode(new_nodes[0][i]);
    236                         terr.addNode(new_nodes[0][i + 1]);
    237                         terr.addNode(new_nodes[1][i + 1]);
    238                         terr.addNode(new_nodes[1][i]);
    239                         terr.addNode(new_nodes[0][i]);
    240                        
    241                         // add the tags of the outline to each building (e.g. source=*)
    242                         TagCollection.from(outline).applyTo(terr);
    243 
    244                                 String number = null;
    245                                 if (from != null) {
    246                                         number = Integer.toString(from + i * step);
    247                                 }
    248                         terr = addressBuilding(terr, street, streetName, number);
    249 
    250                         ways.add(terr);
    251                         this.commands.add(new AddCommand(terr));
    252                     }
    253 
    254                     if (deleteOutline) {
    255                         this.commands.add(DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(outline), true, true));
    256                     }
    257                 } else {
    258                         // Single section, just add the address details
    259                         Way newOutline;
    260                         newOutline = addressBuilding(outline, street, streetName, From);
    261                         ways.add(newOutline);
    262                         this.commands.add(new ChangeCommand(outline, newOutline));
    263                 }
    264                
    265                 if (handleRelations) { // create a new relation or merge with existing
    266                     if (associatedStreet == null) {  // create a new relation
    267                         associatedStreet = new Relation();
    268                         associatedStreet.put("type", "associatedStreet");
    269                         if (street != null) { // a street was part of the selection
    270                             associatedStreet.put("name", street.get("name"));
    271                             associatedStreet.addMember(new RelationMember("street", street));
    272                         } else {
    273                             associatedStreet.put("name", streetName);
    274                         }
    275                         for (Way w : ways) {
    276                             associatedStreet.addMember(new RelationMember("house", w));
    277                         }
    278                         this.commands.add(new AddCommand(associatedStreet));
    279                     }
    280                     else { // relation exists already - add new members
    281                         Relation newAssociatedStreet = new Relation(associatedStreet);
    282                         for (Way w : ways) {
    283                             newAssociatedStreet.addMember(new RelationMember("house", w));
    284                         }
    285                         this.commands.add(new ChangeCommand(associatedStreet, newAssociatedStreet));
    286                     }
    287                 }
    288                 Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
    289                 if (nb > 1) {
    290                         // Select the new building outlines (for quick reversing)
    291                     Main.main.getCurrentDataSet().setSelected(ways);
    292                 } else if (street != null) {
    293                         // Select the way (for quick selection of a new house (with the same way))
    294                     Main.main.getCurrentDataSet().setSelected(street);
    295                 }
     212        // Should this building be terraced (i.e. is there more then one section?)
     213        if (nb > 1) {
     214            // create intermediate nodes by interpolating.
     215
     216            // now find which is the longest side connecting the first node
     217            Pair<Way, Way> interp = findFrontAndBack(outline);
     218
     219            final double frontLength = wayLength(interp.a);
     220            final double backLength = wayLength(interp.b);
     221
     222            for (int i = 0; i <= nb; ++i) {
     223                new_nodes[0][i] = interpolateAlong(interp.a, frontLength * i / nb);
     224                new_nodes[1][i] = interpolateAlong(interp.b, backLength * i / nb);
     225                this.commands.add(new AddCommand(new_nodes[0][i]));
     226                this.commands.add(new AddCommand(new_nodes[1][i]));
     227            }
     228
     229            // assemble new quadrilateral, closed ways
     230            for (int i = 0; i < nb; ++i) {
     231                Way terr = new Way();
     232                // Using Way.nodes.add rather than Way.addNode because the latter
     233                // doesn't
     234                // exist in older versions of JOSM.
     235                terr.addNode(new_nodes[0][i]);
     236                terr.addNode(new_nodes[0][i + 1]);
     237                terr.addNode(new_nodes[1][i + 1]);
     238                terr.addNode(new_nodes[1][i]);
     239                terr.addNode(new_nodes[0][i]);
     240
     241                // add the tags of the outline to each building (e.g. source=*)
     242                TagCollection.from(outline).applyTo(terr);
     243
     244                String number = null;
     245                if (from != null) {
     246                    number = Integer.toString(from + i * step);
     247                }
     248                terr = addressBuilding(terr, street, streetName, number);
     249
     250                ways.add(terr);
     251                this.commands.add(new AddCommand(terr));
     252            }
     253
     254            if (deleteOutline) {
     255                this.commands.add(DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(outline), true, true));
     256            }
     257        } else {
     258            // Single section, just add the address details
     259            Way newOutline;
     260            newOutline = addressBuilding(outline, street, streetName, From);
     261            ways.add(newOutline);
     262            this.commands.add(new ChangeCommand(outline, newOutline));
     263        }
     264
     265        if (handleRelations) { // create a new relation or merge with existing
     266            if (associatedStreet == null) {  // create a new relation
     267                associatedStreet = new Relation();
     268                associatedStreet.put("type", "associatedStreet");
     269                if (street != null) { // a street was part of the selection
     270                    associatedStreet.put("name", street.get("name"));
     271                    associatedStreet.addMember(new RelationMember("street", street));
     272                } else {
     273                    associatedStreet.put("name", streetName);
     274                }
     275                for (Way w : ways) {
     276                    associatedStreet.addMember(new RelationMember("house", w));
     277                }
     278                this.commands.add(new AddCommand(associatedStreet));
     279            }
     280            else { // relation exists already - add new members
     281                Relation newAssociatedStreet = new Relation(associatedStreet);
     282                for (Way w : ways) {
     283                    newAssociatedStreet.addMember(new RelationMember("house", w));
     284                }
     285                this.commands.add(new ChangeCommand(associatedStreet, newAssociatedStreet));
     286            }
     287        }
     288        Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
     289        if (nb > 1) {
     290            // Select the new building outlines (for quick reversing)
     291            Main.main.getCurrentDataSet().setSelected(ways);
     292        } else if (street != null) {
     293            // Select the way (for quick selection of a new house (with the same way))
     294            Main.main.getCurrentDataSet().setSelected(street);
     295        }
    296296    }
    297297
     
    306306     */
    307307    private Way addressBuilding(Way outline, Way street, String streetName, String number) {
    308         Way changedOutline = outline;
     308        Way changedOutline = outline;
    309309        if (number != null) {
    310310            // only, if the user has specified house numbers
     
    431431        return Math.min(positiveModulus(i1 - i2, n), positiveModulus(i2 - i1, n));
    432432    }
    433    
     433
    434434    /**
    435435     * return the modulus in the range [0, n)
    436436     */
    437437    private int positiveModulus(int a, int n) {
    438         if (n <=0) 
     438        if (n <=0)
    439439            throw new IllegalArgumentException();
    440440        int res = a % n;
     
    444444        return res;
    445445    }
    446    
     446
    447447    /**
    448448     * Calculate the length of a side (from node i to i+1) in a way. This assumes that
     
    548548    protected void updateEnabledState() {
    549549        setEnabled(getCurrentDataSet() != null);
    550     }   
     550    }
    551551}
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerPlugin.java

    r19658 r23191  
    11/**
    22 * Terracer: A JOSM Plugin for terraced houses.
    3  * 
     3 *
    44 * Copyright 2009 CloudMade Ltd.
    5  * 
     5 *
    66 * Released under the GPLv2, see LICENSE file for details.
    77 */
     
    1515/**
    1616 * Plugin interface implementation for Terracer.
    17  * 
     17 *
    1818 * @author zere
    1919 */
     
    2121    public TerracerPlugin(PluginInformation info) {
    2222        super(info);
    23        
     23
    2424        MainMenu.add(Main.main.menu.toolsMenu, new TerracerAction());
    2525        MainMenu.add(Main.main.menu.toolsMenu, new ReverseTerraceAction());
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerRuntimeException.java

    r19085 r23191  
    1010/**
    1111 * The Class TerracerRuntimeException indicates errors from the Terracer Plugin.
    12  * 
     12 *
    1313 * @author casualwalker
    1414 */
    1515public class TerracerRuntimeException extends RuntimeException {
    1616
    17         /** The Constant serialVersionUID. */
    18         private static final long serialVersionUID = 857926026580277816L;
     17    /** The Constant serialVersionUID. */
     18    private static final long serialVersionUID = 857926026580277816L;
    1919
    20         /**
    21         * Default constructor.
    22         */
    23         public TerracerRuntimeException() {
    24                 super();
    25         }
     20    /**
     21    * Default constructor.
     22    */
     23    public TerracerRuntimeException() {
     24        super();
     25    }
    2626
    27         /**
    28         * @param message
    29         * @param cause
    30         */
    31         public TerracerRuntimeException(String message, Throwable cause) {
    32                 super(message, cause);
    33         }
     27    /**
     28    * @param message
     29    * @param cause
     30    */
     31    public TerracerRuntimeException(String message, Throwable cause) {
     32        super(message, cause);
     33    }
    3434
    35         /**
    36         * @param message
    37         */
    38         public TerracerRuntimeException(String message) {
    39                 super(message);
    40         }
     35    /**
     36    * @param message
     37    */
     38    public TerracerRuntimeException(String message) {
     39        super(message);
     40    }
    4141
    42         /**
    43         * @param cause
    44         */
    45         public TerracerRuntimeException(Throwable cause) {
    46                 super(cause);
    47         }
     42    /**
     43    * @param cause
     44    */
     45    public TerracerRuntimeException(Throwable cause) {
     46        super(cause);
     47    }
    4848
    4949}
Note: See TracChangeset for help on using the changeset viewer.