/** * Gets the value that an image set iterator will return for the * image associated with the given key when it is positioned * outside the bounds of that image. * * @param key the key * @return the value returned for out-of-bounds value requests * (may be {@code null}) */ public Number getOutsideValue(K key) { assertKey(key); return elements.get(key).getOutsideValue(); }
/** * Private constructor. * * @param set the target image set * @param bounds the bounds for this iterator */ private Iterator(ImageSet set, Rectangle bounds) { if (set == null || set.isEmpty()) { throw new IllegalArgumentException("The ImageSet must not be null or empty"); } this.keys = CollectionFactory.list(); this.delegates = CollectionFactory.list(); Set<K> keySet = set.keySet(); for (K key : keySet) { keys.add(key); delegates.add(new SimpleIterator(set.get(key), bounds, set.getOutsideValue(key))); } }
/** * Creates a new image set which will contain the same keys, images and * outside values as the input set. If the input set is {@code null} or * empty, an empty image set is created. * * @param <K> the key type * @param set the image set to copy * * @return the new copy */ public static <K> ImageSet<K> copy(ImageSet<K> set) { ImageSet<K> newSet = new ImageSet<K>(); if (!(set == null || set.isEmpty())) { for (K key : set.keySet()) { RenderedImage image = set.get(key); Number outsideValue = set.getOutsideValue(key); newSet.add(key, image, outsideValue); } } return newSet; }