Ignore:
Timestamp:
2017-11-25T01:25:40+01:00 (8 years ago)
Author:
donvip
Message:

update to JOSM 12856

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/indoorhelper/src/model/PresetCounter.java

    r32637 r33887  
    2828/**
    2929 * Counter for the calls of specific indoor objects, to track which items were used most frequently.
    30  * 
     30 *
    3131 * @author egru
    3232 *
    3333 */
    3434public class PresetCounter {
    35    
     35
    3636    private List<IndoorObject> rankingList;
    3737    private List<ObjectCounter> counterList;
    38    
     38
    3939    /**
    4040     * Initiates the counterList with the available IndoorObjects.
    4141     */
    42    
     42
    4343    public PresetCounter() {
    4444        this.init();
    4545    }
    46    
     46
    4747    private void init() {
    4848        counterList = new ArrayList<>();
    49        
     49
    5050        counterList.add(new ObjectCounter(IndoorObject.CONCRETE_WALL, 0));
    5151        counterList.add(new ObjectCounter(IndoorObject.DOOR, 0));
     
    6060        counterList.add(new ObjectCounter(IndoorObject.TOILET_MALE, 0));
    6161    }
    62    
     62
    6363    /**
    6464     * Increments the counter of a specific IndoorObject in the list.
     
    6767    public void count(IndoorObject object) {
    6868        ListIterator<ObjectCounter> iterator = this.counterList.listIterator();
    69        
     69
    7070        // Go through the list and increment the corresponding objects counter value.
    7171        while (iterator.hasNext()) {
    7272            ObjectCounter counterTemp = iterator.next();
    7373            if (counterTemp.getObject().equals(object)) {
    74                     counterList.get(iterator.nextIndex()-1).increment();   
     74                    counterList.get(iterator.nextIndex()-1).increment();
    7575            }
    7676        }
    77        
     77
    7878        //Sort the list.
    7979        this.sort();
    8080    }
    81    
     81
    8282    private void sort() {
    8383        Collections.sort(counterList);
    8484        Collections.reverse(counterList);
    8585    }
    86    
     86
    8787    public List<IndoorObject> getRanking() {
    88         rankingList = new ArrayList<IndoorObject>();
    89        
     88        rankingList = new ArrayList<>();
     89
    9090        rankingList.add(counterList.get(0).getObject());
    9191        rankingList.add(counterList.get(1).getObject());
    9292        rankingList.add(counterList.get(2).getObject());
    9393        rankingList.add(counterList.get(3).getObject());
    94        
     94
    9595        return rankingList;
    9696    }
    97    
    98     private class ObjectCounter implements Comparable<ObjectCounter> {
     97
     98    private static class ObjectCounter implements Comparable<ObjectCounter> {
    9999        private IndoorObject object;
    100100        private int count;
    101        
     101
    102102        ObjectCounter(IndoorObject o, int c) {
    103103            this.object = o;
    104104            this.count = c;
    105105        }
    106        
     106
    107107        public int getCount() {
    108108            return this.count;
    109109        }
    110        
     110
    111111        public IndoorObject getObject() {
    112112            return this.object;
    113113        }
    114        
     114
    115115        public void increment() {
    116116            this.count += 1;
    117117        }
    118        
     118
    119119        @Override
    120120        public int compareTo(ObjectCounter o) {
     
    128128                return 1;
    129129            }
    130            
     130
    131131            return 0;
    132132        }
    133        
     133
    134134    }
    135    
     135
    136136}
Note: See TracChangeset for help on using the changeset viewer.