Ignore:
Timestamp:
2015-08-16T08:41:50+02:00 (9 years ago)
Author:
niplecrumple
Message:

Added some javadocs. Fixed bug with closing JOSM.

Location:
applications/editors/josm/plugins/rasterfilters
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/rasterfilters/build.xml

    r31485 r31504  
    77       
    88        <!-- enter the SVN commit message -->
    9         <property name="commit.message" value="The first commit of rasterfilters JOSM's plugin" />
     9        <property name="commit.message" value="Publishing RasterFilters plugin ver 1.0.1" />
    1010       
    1111        <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    1212        <property name="plugin.main.version" value="8625" />
    13         <property name="plugin.version" value="1.0"/>
     13        <property name="plugin.version" value="1.0.1"/>
    1414
    1515    <property name="plugin.icon" value="images/josm_filters_48.png"/>
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java

    r31470 r31504  
    2222import org.openstreetmap.josm.plugins.rasterfilters.preferences.FiltersDownloader;
    2323import org.openstreetmap.josm.plugins.rasterfilters.preferences.RasterFiltersPreferences;
    24 
     24/**
     25 * Main Plugin class. This class embed new plugin button for adding filter and
     26 * subtab in Preferences menu
     27 *
     28 * @author Nipel-Crumple
     29 *
     30 */
    2531public class RasterFiltersPlugin extends Plugin implements LayerChangeListener {
    2632
     
    3541                File file = new File(getPluginDir());
    3642                if (file.mkdir()) {
     43
     44                        // opening file with last user's settings
    3745                        file = new File(file.getAbsoluteFile() + "\\urls.map");
    3846                        if (!file.exists()) {
     
    93101                                        .getComponent(0);
    94102                        buttonRowPanel.add(filterButton);
    95 
    96                         Main.debug("Layer " + newLayer.getName() + "was added");
    97103                }
    98104
     
    106112        @Override
    107113        public void layerRemoved(Layer oldLayer) {
    108                 Main.debug("Layer " + oldLayer.getName() + "was removed");
    109114
    110115                if (oldLayer instanceof ImageryLayer) {
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java

    r31470 r31504  
    2020import org.openstreetmap.josm.tools.ImageProvider;
    2121
     22/**
     23 * The action that is called when user click on 'Choose filters' button
     24 *
     25 * and sets image on that button
     26 *
     27 * @author Nipel-Crumple
     28 *
     29 */
    2230public final class ShowLayerFiltersDialog extends AbstractAction implements LayerAction {
    2331
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/filters/Filter.java

    r31470 r31504  
    55
    66import javax.json.JsonObject;
    7 
     7/**
     8 * The Filter interface is inherited by all filters which are implemented.
     9 *
     10 * This interface has four methods that should be overrided in
     11 *
     12 * implementation.
     13 *
     14 * @author Nipel-Crumple
     15 *
     16 */
    817public interface Filter {
    918
     19        /**
     20         * This method should take external fields values of filter's parameters
     21         * which should be described in the meta-information. In other words, if you have 3
     22         * controls of type 'linear_slider' and if state at least one of these
     23         * controls has changed, you will get new filter state in the form of
     24         * json object 'filterState', then parse it and
     25         * store given parameters' values in class.
     26         *
     27         * @param filterState json that has information about current filter state
     28         *
     29         * @return json object 'filterState'
     30         */
    1031        public JsonObject changeFilterState(JsonObject filterState);
    1132
     33        /**
     34         * This method processes given image and returns
     35         * updated version of the image. Algorithm and implementation of
     36         * this method depends on your needs and wishes.
     37         *
     38         * @param img image to process
     39         *
     40         * @return processed image
     41         */
    1242        public BufferedImage applyFilter(BufferedImage img);
    1343
     44        /**
     45         * Every filter must have his own unique ID number.
     46         * In case of rasterfilters plugin it ID is the type of UID.
     47         *
     48         * @param id sets value of ID field
     49         */
    1450        public void setId(UID id);
    1551
     52        /**
     53         * Getter for filter's ID field.
     54         *
     55         * @return id of filter
     56         */
    1657        public UID getId();
    1758}
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterGuiListener.java

    r31470 r31504  
    2828import com.bric.swing.ColorPicker;
    2929
     30/**
     31 * This class is GUI listener which tracks all changes of GUI controls
     32 * elements: sliders, checkboxes, color pickers and select lists.
     33 * @author Nipel-Crumple
     34 *
     35 */
    3036public class FilterGuiListener implements ChangeListener, ItemListener,
    31 ActionListener, PropertyChangeListener, FilterStateOwner {
     37                ActionListener, PropertyChangeListener, FilterStateOwner {
    3238
    3339        private StateChangeListener handler;
     
    4450        }
    4551
     52        /**
     53         * Listener which responds on any changes of sliders values.
     54         */
    4655        @Override
    4756        public void stateChanged(ChangeEvent e) {
     
    5766                if (filterState.getParams().containsKey(parameterName)) {
    5867
    59                         SliderValue<Number> value = (SliderValue<Number>) filterState.getParams().get(parameterName);
     68                        SliderValue<Number> value = (SliderValue<Number>) filterState
     69                                        .getParams().get(parameterName);
    6070
    6171                        if (value.isDouble()) {
     
    6878                }
    6979
    70                 // notify about state is changed now so send msg to FiltersManager
     80                // notifies about state is changed now and sends msg to FiltersManager
    7181                handler.filterStateChanged(filterId, filterState);
    7282        }
     
    90100        }
    91101
     102        /**
     103         * Method reacts on changes of checkbox GUI elements.
     104         */
    92105        @Override
    93106        public void itemStateChanged(ItemEvent e) {
     
    105118        }
    106119
     120        /**
     121         * Methods tracks all changes of select lists
     122         */
    107123        @Override
    108124        public void actionPerformed(ActionEvent e) {
     
    111127
    112128                String parameterName = box.getName();
    113                 SelectValue<String> value = (SelectValue<String>) filterState.getParams().get(parameterName);
     129                SelectValue<String> value = (SelectValue<String>) filterState
     130                                .getParams().get(parameterName);
    114131
    115132                ComboBoxModel<String> model = box.getModel();
     
    123140        }
    124141
     142        /**
     143         * This listener's method is for responding on some
     144         * color pick changes.
     145         */
    125146        @Override
    126147        public void propertyChange(PropertyChangeEvent evt) {
     
    133154                String parameterName = picker.getName();
    134155
    135                 ColorValue<Color> value = (ColorValue<Color>) filterState.getParams().get(parameterName);
     156                ColorValue<Color> value = (ColorValue<Color>) filterState.getParams()
     157                                .get(parameterName);
    136158                value.setValue(new Color(r, g, b));
    137159
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterPanel.java

    r31499 r31504  
    3535import com.bric.swing.ColorPicker;
    3636
     37/**
     38 * FilterPanel is usual JPanel with its
     39 * own GUI elements which is added according to
     40 * meta-information of filter.
     41 *
     42 * @author Nipel-Crumple
     43 *
     44 */
    3745public class FilterPanel extends JPanel {
    3846
     
    4755        }
    4856
     57        /**
     58         * Methods adds GUI element on filter's panel according to meta-information and
     59         * automatically resizes the given filter's panel.
     60         *
     61         * @param json filter's meta-information
     62         *
     63         * @return added GUI element
     64         */
    4965        public JComponent addGuiElement(JsonObject json) {
    5066                String type = json.getString("type");
     
    271287                                }
    272288                        }
    273                         Main.debug("minValue: " + String.valueOf(minValue) +
    274                                         "\nmaxValue: " + String.valueOf(maxValue) +
    275                                         "\ninitValue: " + new Double(initValue).intValue());
    276289
    277290                        try {
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterStateOwner.java

    r31470 r31504  
    22
    33import org.openstreetmap.josm.plugins.rasterfilters.model.FilterStateModel;
     4/**
     5 * Filter state's keeper. This interface is implemented by {@link FilterGuiListeener}.
     6 *
     7 * @author Nipel-Crumple
     8 *
     9 */
     10public interface FilterStateOwner {
    411
    5 public interface FilterStateOwner {
    6        
    712        public FilterStateModel getState();
    8        
     13
    914}
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FiltersDialog.java

    r31470 r31504  
    2626import org.openstreetmap.josm.plugins.rasterfilters.preferences.FiltersDownloader;
    2727
     28/**
     29 * This filters is responsible for creating filter's dialog where user can
     30 * choose and add new filter at this dialog.
     31 *
     32 * @author Nipel-Crumple
     33 *
     34 */
    2835public class FiltersDialog {
    2936
     
    123130                        JLabel label = new JLabel("Add filter");
    124131                        labelPanel.add(label);
    125 //                      pane.add(labelPanel);
     132                        // pane.add(labelPanel);
    126133
    127134                        // TODO why after add clicked the top panel is resized???
     
    146153                        addButton.setMaximumSize(new Dimension(90, 30));
    147154                        addButton.addActionListener(new AddFilterToPanelListener());
    148 //
    149 //                      // check if there is no meta information
    150 //                      Main.debug("Empty " + String.valueOf(FiltersDownloader.filterTitles.isEmpty()));
    151 //                      if (FiltersDownloader.filterTitles.isEmpty() || listModel.getSize() == 0) {
    152 //                              addButton.setEnabled(false);
    153 //                              filterChooser.setEnabled(false);
    154 //                      } else {
    155 //                              addButton.setEnabled(true);
    156 //                              filterChooser.setEnabled(true);
    157 //                      }
     155                        //
     156                        // // check if there is no meta information
     157                        // Main.debug("Empty " +
     158                        // String.valueOf(FiltersDownloader.filterTitles.isEmpty()));
     159                        // if (FiltersDownloader.filterTitles.isEmpty() ||
     160                        // listModel.getSize() == 0) {
     161                        // addButton.setEnabled(false);
     162                        // filterChooser.setEnabled(false);
     163                        // } else {
     164                        // addButton.setEnabled(true);
     165                        // filterChooser.setEnabled(true);
     166                        // }
    158167
    159168                        chooseFilterPanel.add(getAddButton());
     
    162171                        topPanel.add(chooseFilterPanel);
    163172                        pane.add(topPanel);
    164 //                      pane.add(chooseFilterPanel);
    165 //                      pane.add(Box.createRigidArea(new Dimension(0, 20)));
     173                        // pane.add(chooseFilterPanel);
     174                        // pane.add(Box.createRigidArea(new Dimension(0, 20)));
    166175
    167176                        frame.setContentPane(pane);
     
    170179                }
    171180
    172 
    173                 if (FiltersDownloader.filterTitles.isEmpty() || listModel.getSize() == 0) {
     181                if (FiltersDownloader.filterTitles.isEmpty()
     182                                || listModel.getSize() == 0) {
    174183                        addButton.setEnabled(false);
    175184                        filterChooser.setEnabled(false);
     
    194203        }
    195204
    196         public Layer getLayer() {
    197                 return layer;
    198         }
    199 
    200         public JPanel getFilterContainer() {
    201                 return filterContainer;
    202         }
    203 
    204         public DefaultComboBoxModel<String> getListModel() {
    205                 return listModel;
    206         }
    207 
    208         public JComboBox<String> getFilterChooser() {
    209                 return filterChooser;
    210         }
    211 
    212         public JButton getAddButton() {
    213                 return addButton;
    214         }
    215 
    216205        public FiltersManager getFiltersManager() {
    217206                return filtersManager;
     
    247236                return showedFiltersTitles;
    248237        }
     238
     239        public Layer getLayer() {
     240                return layer;
     241        }
     242
     243        public JPanel getFilterContainer() {
     244                return filterContainer;
     245        }
     246
     247        public DefaultComboBoxModel<String> getListModel() {
     248                return listModel;
     249        }
     250
     251        public JComboBox<String> getFilterChooser() {
     252                return filterChooser;
     253        }
     254
     255        public JButton getAddButton() {
     256                return addButton;
     257        }
    249258}
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FilterStateModel.java

    r31470 r31504  
    1515import org.openstreetmap.josm.plugins.rasterfilters.values.SliderValue;
    1616import org.openstreetmap.josm.plugins.rasterfilters.values.Value;
    17 
     17/**
     18 * Filter state's model which stores all parameters of
     19 * the filter according to its meta-information.
     20 * The usual values from meta-information are converted
     21 * into subtypes of the generic interface {@link Value}
     22 *
     23 * @author Nipel-Crumple
     24 *
     25 */
    1826public class FilterStateModel {
    1927
     
    96104        }
    97105
     106        /**
     107         * Method generates json from the current filter's model state.
     108         *
     109         * @return encoded json which describes current filter's state
     110         */
    98111        public JsonObject encodeJson() {
    99112
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java

    r31470 r31504  
    3333
    3434import com.bric.swing.ColorPicker;
    35 
     35/**
     36 * This class adds filter to the dialog and can also remove
     37 * or disable it from the filters chain.
     38 *
     39 * @author Nipel-Crumple
     40 *
     41 */
    3642public class FiltersManager implements StateChangeListener, ImageProcessor,
    3743ActionListener, ItemListener {
     
    142148
    143149        /**
    144          * The method notifies about changes in the filter's status
     150         * The method notifies about changes in the filter's status.
    145151         *
    146152         * @param filterState
     
    153159                        filtersMap.get(filterId).changeFilterState(filterState.encodeJson());
    154160
    155                 Main.map.mapView.getActiveLayer().setFilterStateChanged();
     161                if (Main.map.mapView.getActiveLayer() != null) {
     162                        Main.map.mapView.getActiveLayer().setFilterStateChanged();
     163                }
    156164
    157165        }
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/StateChangeListener.java

    r31470 r31504  
    33import java.rmi.server.UID;
    44
     5/**
     6 * Interface that notifies about filter's state is changed.
     7 * This interface is implemented by {@link FiltersManager}.
     8 * @author Nipel-Crumple
     9 *
     10 */
    511public interface StateChangeListener {
    612
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/preferences/FiltersDownloader.java

    r31470 r31504  
    4141import org.jsoup.select.Elements;
    4242import org.openstreetmap.josm.Main;
    43 
     43/**
     44 * This class is responsible for downloading jars which contains
     45 * filters implementations, for loading meta from the
     46 * <a href="https://josm.openstreetmap.de/wiki/ImageFilters">filter's page</a>.
     47 * Also it stores the downloaded information for creating filter's GUI and etc.
     48 *
     49 * @author Nipel-Crumple
     50 */
    4451public class FiltersDownloader implements ActionListener {
    4552        private static volatile String pluginDir;
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/preferences/RasterFiltersPreferences.java

    r31470 r31504  
    2323import org.openstreetmap.josm.tools.GBC;
    2424
     25/**
     26 * This class draws subtab 'Image Filters' in the Preferences menu.
     27 *
     28 * @author Nipel-Crumple
     29 *
     30 */
    2531public class RasterFiltersPreferences implements SubPreferenceSetting {
    2632
  • applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/values/Value.java

    r31470 r31504  
    11package org.openstreetmap.josm.plugins.rasterfilters.values;
    22
     3import org.openstreetmap.josm.plugins.rasterfilters.model.FilterStateModel;
     4
     5/**
     6 * Generic values which are used by {@link FilterStateModel}.
     7 *
     8 * @author Nipel-Crumple
     9 *
     10 * @param <T> generic class of the value
     11 */
    312public interface Value<T extends Object> {
    4        
     13
    514        public T getValue();
    6        
     15
    716        public void setValue(T value);
    8        
     17
    918        public String getParameterName();
    10        
     19
    1120        public void setParameterName(String name);
    1221}
Note: See TracChangeset for help on using the changeset viewer.