001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.sources; 003 004import java.util.ArrayList; 005import java.util.List; 006import java.util.Objects; 007 008import org.openstreetmap.josm.data.Bounds; 009import org.openstreetmap.josm.data.imagery.Shape; 010 011/** 012 * 013 * Multi-polygon bounds for source backgrounds. 014 * Used to display source coverage in preferences and to determine relevant source entries based on edit location. 015 * 016 * @author Frederik Ramm, extracted by Taylor Smock 017 * @since 16545 (extracted from {@link org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds}) 018 */ 019public class SourceBounds extends Bounds { 020 021 /** 022 * Constructs a new {@code SourceBounds} from string. 023 * @param asString The string containing the list of shapes defining this bounds 024 * @param separator The shape separator in the given string, usually a comma 025 */ 026 public SourceBounds(String asString, String separator) { 027 super(asString, separator); 028 } 029 030 private List<Shape> shapes = new ArrayList<>(); 031 032 /** 033 * Adds a new shape to this bounds. 034 * @param shape The shape to add 035 */ 036 public final void addShape(Shape shape) { 037 this.shapes.add(shape); 038 } 039 040 /** 041 * Sets the list of shapes defining this bounds. 042 * @param shapes The list of shapes defining this bounds. 043 */ 044 public final void setShapes(List<Shape> shapes) { 045 this.shapes = shapes; 046 } 047 048 /** 049 * Returns the list of shapes defining this bounds. 050 * @return The list of shapes defining this bounds 051 */ 052 public final List<Shape> getShapes() { 053 return shapes; 054 } 055 056 @Override 057 public int hashCode() { 058 return Objects.hash(super.hashCode(), shapes); 059 } 060 061 @Override 062 public boolean equals(Object o) { 063 if (this == o) return true; 064 if (o == null || getClass() != o.getClass()) return false; 065 if (!super.equals(o)) return false; 066 SourceBounds that = (SourceBounds) o; 067 return Objects.equals(shapes, that.shapes); 068 } 069}