コード例 #1
0
 /**
  * Adds the specified layer at the end of the list
  *
  * @param layer a {@link Layer}
  */
 public void addLast(Layer<?> layer) {
   int indexAdded = layers.size();
   layers.add(layer);
   ListDataEvent event =
       new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, indexAdded, indexAdded);
   notifyListeners(event);
 }
コード例 #2
0
 @Override
 public void clear() {
   int lastIndex = layers.size() - 1;
   layers.clear();
   ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, lastIndex);
   notifyListeners(event);
 }
コード例 #3
0
 /**
  * Adds the specified layer at the beginning of the list because layers are stacked. They are also
  * painted in reverse order
  *
  * @param layer a {@link Layer}
  * @return true
  */
 @Override
 public boolean add(Layer<?> layer) {
   int indexAdded = layers.size();
   layers.addFirst(layer);
   ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, indexAdded);
   notifyListeners(event);
   return true;
 }
コード例 #4
0
 @Override
 public boolean addAll(Collection<? extends Layer<?>> layers) {
   int indexFirstAdded = this.layers.size();
   int indexLastAdded = indexFirstAdded + layers.size();
   boolean listChanged = this.layers.addAll(layers);
   if (listChanged) {
     ListDataEvent event =
         new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, indexFirstAdded, indexLastAdded);
     notifyListeners(event);
   }
   return listChanged;
 }
コード例 #5
0
 @Override
 public boolean retainAll(Collection<?> c) {
   int sizeBeforeChanges = layers.size();
   boolean listChanged = layers.retainAll(c);
   if (listChanged) {
     ListDataEvent event =
         new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, sizeBeforeChanges - 1);
     notifyListeners(event);
     return true;
   } else {
     return false;
   }
 }
コード例 #6
0
 @Override
 public boolean remove(Object o) {
   int indexRemoved = layers.indexOf(o);
   if (indexRemoved != -1) {
     layers.remove(o);
     ListDataEvent event =
         new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, indexRemoved, indexRemoved);
     notifyListeners(event);
     return true;
   } else {
     return false;
   }
 }