Ignore:
Timestamp:
2018-01-04T11:05:03+01:00 (7 years ago)
Author:
rebeccas95
Message:

Update indoorhelper plugin to support the Simple Indoor Tagging scheme

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java

    r33887 r33974  
    2525
    2626import org.openstreetmap.josm.Main;
     27import org.openstreetmap.josm.gui.MainApplication;
    2728import org.openstreetmap.josm.gui.MapFrame;
     29import org.openstreetmap.josm.gui.autofilter.AutoFilter;
     30import org.openstreetmap.josm.gui.autofilter.AutoFilterManager;
     31import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     32import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     33import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationEvent;
     34import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener;
     35import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2836import org.openstreetmap.josm.plugins.Plugin;
    2937import org.openstreetmap.josm.plugins.PluginInformation;
     
    3644 *
    3745 * @author egru
     46 * @author rebsc
    3847 *
    3948 */
    40 public class IndoorHelperPlugin extends Plugin {
    41 
    42 
    43     @SuppressWarnings("unused")
     49public class IndoorHelperPlugin extends Plugin implements PaintableInvalidationListener, ActiveLayerChangeListener {
     50
     51
     52        @SuppressWarnings("unused")
    4453    private IndoorHelperController controller;
    4554    String sep = System.getProperty("file.separator");
     
    5463    public IndoorHelperPlugin(PluginInformation info) throws Exception {
    5564        super(info);
    56 
     65        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
    5766        this.exportValidator("/data/indoorhelper.validator.mapcss");
    58         this.exportStyleFile("indoor.mapcss");
     67        this.exportStyleFile("sit.mapcss");
    5968        this.exportStyleFile("entrance_door_icon.png");
    6069        this.exportStyleFile("entrance_icon.png");
    61 //        this.setIndoorValidator();
    62     }
     70        this.exportStyleFile("elevator_icon.png");
     71
     72        //this.setIndoorValidator();
     73    }
     74
    6375
    6476    /**
     
    7486    }
    7587
     88
    7689    /**
    7790     * Exports the mapcss validator file to the preferences directory.
    7891     */
    79     private void exportValidator(String resourceName) throws Exception {
     92    @SuppressWarnings("deprecation")
     93        private void exportValidator(String resourceName) throws Exception {
    8094        InputStream stream = null;
    8195        OutputStream resStreamOut = null;
    82 
    8396
    8497        try {
     
    93106            byte[] buffer = new byte[4096];
    94107
    95             String valDirPath = Main.pref.getDirs().getUserDataDirectory(false) + sep + "validator";
     108            String valDirPath = Main.pref.getUserDataDirectory() + sep + "validator";
    96109            File valDir = new File(valDirPath);
    97110            valDir.mkdirs();
     
    129142            byte[] buffer = new byte[4096];
    130143
    131             String valDirPath = Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles";
     144            @SuppressWarnings("deprecation")
     145                        String valDirPath = Main.pref.getUserDataDirectory() + sep + "styles";
    132146            File valDir = new File(valDirPath);
    133147            valDir.mkdirs();
     
    146160        }
    147161    }
     162
     163        @Override
     164        public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     165                OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
     166        if (editLayer != null) {
     167            editLayer.addInvalidationListener(this);
     168        }
     169        }
     170
     171        @Override
     172        public void paintableInvalidated(PaintableInvalidationEvent event){
     173                AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter();
     174                String currentFilterValue = new String();
     175
     176                if(currentAutoFilter != null) {
     177                        currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1];
     178
     179                        this.controller.setIndoorLevel(currentFilterValue);
     180                        this.controller.getIndoorLevel(currentFilterValue);
     181                        this.controller.unsetSpecificKeyFilter("repeat_on");
     182
     183                }else{
     184                        currentFilterValue = "";
     185                        this.controller.setIndoorLevel(currentFilterValue);
     186                        this.controller.getIndoorLevel(currentFilterValue);
     187                };
     188
     189        }
    148190
    149191    /**
     
    189231//        }
    190232//    }
     233
     234/**
     235 *
     236 *
     237 *
     238 *
     239 *
     240 *
     241 *
     242 *
     243 *
     244 */
    191245}
Note: See TracChangeset for help on using the changeset viewer.