Changeset 31504 in osm for applications
- Timestamp:
- 2015-08-16T08:41:50+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/rasterfilters
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/rasterfilters/build.xml
r31485 r31504 7 7 8 8 <!-- 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" /> 10 10 11 11 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 12 12 <property name="plugin.main.version" value="8625" /> 13 <property name="plugin.version" value="1.0 "/>13 <property name="plugin.version" value="1.0.1"/> 14 14 15 15 <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 22 22 import org.openstreetmap.josm.plugins.rasterfilters.preferences.FiltersDownloader; 23 23 import 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 */ 25 31 public class RasterFiltersPlugin extends Plugin implements LayerChangeListener { 26 32 … … 35 41 File file = new File(getPluginDir()); 36 42 if (file.mkdir()) { 43 44 // opening file with last user's settings 37 45 file = new File(file.getAbsoluteFile() + "\\urls.map"); 38 46 if (!file.exists()) { … … 93 101 .getComponent(0); 94 102 buttonRowPanel.add(filterButton); 95 96 Main.debug("Layer " + newLayer.getName() + "was added");97 103 } 98 104 … … 106 112 @Override 107 113 public void layerRemoved(Layer oldLayer) { 108 Main.debug("Layer " + oldLayer.getName() + "was removed");109 114 110 115 if (oldLayer instanceof ImageryLayer) { -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java
r31470 r31504 20 20 import org.openstreetmap.josm.tools.ImageProvider; 21 21 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 */ 22 30 public final class ShowLayerFiltersDialog extends AbstractAction implements LayerAction { 23 31 -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/filters/Filter.java
r31470 r31504 5 5 6 6 import 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 */ 8 17 public interface Filter { 9 18 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 */ 10 31 public JsonObject changeFilterState(JsonObject filterState); 11 32 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 */ 12 42 public BufferedImage applyFilter(BufferedImage img); 13 43 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 */ 14 50 public void setId(UID id); 15 51 52 /** 53 * Getter for filter's ID field. 54 * 55 * @return id of filter 56 */ 16 57 public UID getId(); 17 58 } -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterGuiListener.java
r31470 r31504 28 28 import com.bric.swing.ColorPicker; 29 29 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 */ 30 36 public class FilterGuiListener implements ChangeListener, ItemListener, 31 ActionListener, PropertyChangeListener, FilterStateOwner {37 ActionListener, PropertyChangeListener, FilterStateOwner { 32 38 33 39 private StateChangeListener handler; … … 44 50 } 45 51 52 /** 53 * Listener which responds on any changes of sliders values. 54 */ 46 55 @Override 47 56 public void stateChanged(ChangeEvent e) { … … 57 66 if (filterState.getParams().containsKey(parameterName)) { 58 67 59 SliderValue<Number> value = (SliderValue<Number>) filterState.getParams().get(parameterName); 68 SliderValue<Number> value = (SliderValue<Number>) filterState 69 .getParams().get(parameterName); 60 70 61 71 if (value.isDouble()) { … … 68 78 } 69 79 70 // notif y about state is changed now so sendmsg to FiltersManager80 // notifies about state is changed now and sends msg to FiltersManager 71 81 handler.filterStateChanged(filterId, filterState); 72 82 } … … 90 100 } 91 101 102 /** 103 * Method reacts on changes of checkbox GUI elements. 104 */ 92 105 @Override 93 106 public void itemStateChanged(ItemEvent e) { … … 105 118 } 106 119 120 /** 121 * Methods tracks all changes of select lists 122 */ 107 123 @Override 108 124 public void actionPerformed(ActionEvent e) { … … 111 127 112 128 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); 114 131 115 132 ComboBoxModel<String> model = box.getModel(); … … 123 140 } 124 141 142 /** 143 * This listener's method is for responding on some 144 * color pick changes. 145 */ 125 146 @Override 126 147 public void propertyChange(PropertyChangeEvent evt) { … … 133 154 String parameterName = picker.getName(); 134 155 135 ColorValue<Color> value = (ColorValue<Color>) filterState.getParams().get(parameterName); 156 ColorValue<Color> value = (ColorValue<Color>) filterState.getParams() 157 .get(parameterName); 136 158 value.setValue(new Color(r, g, b)); 137 159 -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterPanel.java
r31499 r31504 35 35 import com.bric.swing.ColorPicker; 36 36 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 */ 37 45 public class FilterPanel extends JPanel { 38 46 … … 47 55 } 48 56 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 */ 49 65 public JComponent addGuiElement(JsonObject json) { 50 66 String type = json.getString("type"); … … 271 287 } 272 288 } 273 Main.debug("minValue: " + String.valueOf(minValue) +274 "\nmaxValue: " + String.valueOf(maxValue) +275 "\ninitValue: " + new Double(initValue).intValue());276 289 277 290 try { -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FilterStateOwner.java
r31470 r31504 2 2 3 3 import 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 */ 10 public interface FilterStateOwner { 4 11 5 public interface FilterStateOwner {6 7 12 public FilterStateModel getState(); 8 13 9 14 } -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/gui/FiltersDialog.java
r31470 r31504 26 26 import org.openstreetmap.josm.plugins.rasterfilters.preferences.FiltersDownloader; 27 27 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 */ 28 35 public class FiltersDialog { 29 36 … … 123 130 JLabel label = new JLabel("Add filter"); 124 131 labelPanel.add(label); 125 //pane.add(labelPanel);132 // pane.add(labelPanel); 126 133 127 134 // TODO why after add clicked the top panel is resized??? … … 146 153 addButton.setMaximumSize(new Dimension(90, 30)); 147 154 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 // } 158 167 159 168 chooseFilterPanel.add(getAddButton()); … … 162 171 topPanel.add(chooseFilterPanel); 163 172 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))); 166 175 167 176 frame.setContentPane(pane); … … 170 179 } 171 180 172 173 if (FiltersDownloader.filterTitles.isEmpty()|| listModel.getSize() == 0) {181 if (FiltersDownloader.filterTitles.isEmpty() 182 || listModel.getSize() == 0) { 174 183 addButton.setEnabled(false); 175 184 filterChooser.setEnabled(false); … … 194 203 } 195 204 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 216 205 public FiltersManager getFiltersManager() { 217 206 return filtersManager; … … 247 236 return showedFiltersTitles; 248 237 } 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 } 249 258 } -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FilterStateModel.java
r31470 r31504 15 15 import org.openstreetmap.josm.plugins.rasterfilters.values.SliderValue; 16 16 import 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 */ 18 26 public class FilterStateModel { 19 27 … … 96 104 } 97 105 106 /** 107 * Method generates json from the current filter's model state. 108 * 109 * @return encoded json which describes current filter's state 110 */ 98 111 public JsonObject encodeJson() { 99 112 -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java
r31470 r31504 33 33 34 34 import 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 */ 36 42 public class FiltersManager implements StateChangeListener, ImageProcessor, 37 43 ActionListener, ItemListener { … … 142 148 143 149 /** 144 * The method notifies about changes in the filter's status 150 * The method notifies about changes in the filter's status. 145 151 * 146 152 * @param filterState … … 153 159 filtersMap.get(filterId).changeFilterState(filterState.encodeJson()); 154 160 155 Main.map.mapView.getActiveLayer().setFilterStateChanged(); 161 if (Main.map.mapView.getActiveLayer() != null) { 162 Main.map.mapView.getActiveLayer().setFilterStateChanged(); 163 } 156 164 157 165 } -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/StateChangeListener.java
r31470 r31504 3 3 import java.rmi.server.UID; 4 4 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 */ 5 11 public interface StateChangeListener { 6 12 -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/preferences/FiltersDownloader.java
r31470 r31504 41 41 import org.jsoup.select.Elements; 42 42 import 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 */ 44 51 public class FiltersDownloader implements ActionListener { 45 52 private static volatile String pluginDir; -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/preferences/RasterFiltersPreferences.java
r31470 r31504 23 23 import org.openstreetmap.josm.tools.GBC; 24 24 25 /** 26 * This class draws subtab 'Image Filters' in the Preferences menu. 27 * 28 * @author Nipel-Crumple 29 * 30 */ 25 31 public class RasterFiltersPreferences implements SubPreferenceSetting { 26 32 -
applications/editors/josm/plugins/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/values/Value.java
r31470 r31504 1 1 package org.openstreetmap.josm.plugins.rasterfilters.values; 2 2 3 import 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 */ 3 12 public interface Value<T extends Object> { 4 13 5 14 public T getValue(); 6 15 7 16 public void setValue(T value); 8 17 9 18 public String getParameterName(); 10 19 11 20 public void setParameterName(String name); 12 21 }
Note:
See TracChangeset
for help on using the changeset viewer.