// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// 	private static final long serialVersionUID = 1851275921474044916L;
// 		
// 
// 	private final double time;
// 	private final double frequency;
// 	private final double intensity;
// 	private final int x;
// 	private final int y;
// 		
// 	public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// 		this.time = time;
// 		this.frequency = frequency;
// 		this.intensity = intensity;
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public double getTime() {
// 		return time;
// 	}
// 
// 	public double getFrequency() {
// 		return frequency;
// 	}
// 
// 	public double getIntensity() {
// 		return intensity;
// 	}
// 		
// 	public int getTick() {
// 		return x;
// 	}
// 		
// 	public int getBin() {
// 		return y;
// 	}
// 		
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + x;
// 		result = prime * result + y;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		Star other = (Star) obj;
// 		if (x != other.x)
// 			return false;
// 		if (y != other.y)
// 			return false;
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// 	}
// }
// 
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class TimeStarComparator implements Comparator<Star> {
// 	@Override
// 	public int compare(Star o1, Star o2) {
// 		int t1 = o1.getTick();
// 		int t2 = o2.getTick();
// 			
// 		if (t1 == t2) {
// 			return 0;
// 		}
// 		else if (t1 < t2) {
// 			return -1;
// 		}
// 		else {
// 			return 1;
// 		}
// 	}
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.sidoh.collections.TreeMapOfSets;
import org.sidoh.io.ProgressNotifier;
import org.sidoh.io.ProgressNotifier.Builder;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.ConstellationMap.TimeStarComparator;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
package org.sidoh.song_recognition.signature;



public class StarHashExtractor implements SpectrogramSignatureExtractor<StarHashSignature> {
	
	private final ConstellationMapExtractor starExtractor;
	private final Region.Builder regionBuilder;
	private final int timeResolution;
	private final ProgressNotifier.Builder progress;
	private final Region.Builder reverseRegionBuilder;
	
	public StarHashExtractor(ConstellationMapExtractor starExtractor, 
			Region.Builder regionBuilder, 
			int timeResolution,
			ProgressNotifier.Builder progress) {
		this(starExtractor, regionBuilder, null, timeResolution, progress);
	}

	public StarHashExtractor(ConstellationMapExtractor starExtractor, 
			Region.Builder regionBuilder, 
			Region.Builder reverseRegionBuilder,
			int timeResolution,
			ProgressNotifier.Builder progress) {
		this.starExtractor = starExtractor;
		this.regionBuilder = regionBuilder;
		this.reverseRegionBuilder = reverseRegionBuilder;
		this.timeResolution = timeResolution;
		this.progress = progress;
	}
	
	@Override
	public StarHashSignature extractSignature(Spectrogram spec) {
		ConstellationMapSignature starSig = starExtractor.extractSignature(spec);
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// 	private static final long serialVersionUID = 1851275921474044916L;
// 		
// 
// 	private final double time;
// 	private final double frequency;
// 	private final double intensity;
// 	private final int x;
// 	private final int y;
// 		
// 	public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// 		this.time = time;
// 		this.frequency = frequency;
// 		this.intensity = intensity;
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public double getTime() {
// 		return time;
// 	}
// 
// 	public double getFrequency() {
// 		return frequency;
// 	}
// 
// 	public double getIntensity() {
// 		return intensity;
// 	}
// 		
// 	public int getTick() {
// 		return x;
// 	}
// 		
// 	public int getBin() {
// 		return y;
// 	}
// 		
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + x;
// 		result = prime * result + y;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		Star other = (Star) obj;
// 		if (x != other.x)
// 			return false;
// 		if (y != other.y)
// 			return false;
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// 	}
// }
// 
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class TimeStarComparator implements Comparator<Star> {
// 	@Override
// 	public int compare(Star o1, Star o2) {
// 		int t1 = o1.getTick();
// 		int t2 = o2.getTick();
// 			
// 		if (t1 == t2) {
// 			return 0;
// 		}
// 		else if (t1 < t2) {
// 			return -1;
// 		}
// 		else {
// 			return 1;
// 		}
// 	}
// }


// Path: src/java/org/sidoh/song_recognition/signature/StarHashExtractor.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.sidoh.collections.TreeMapOfSets;
import org.sidoh.io.ProgressNotifier;
import org.sidoh.io.ProgressNotifier.Builder;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.ConstellationMap.TimeStarComparator;
import org.sidoh.song_recognition.spectrogram.Spectrogram;

package org.sidoh.song_recognition.signature;



public class StarHashExtractor implements SpectrogramSignatureExtractor<StarHashSignature> {
	
	private final ConstellationMapExtractor starExtractor;
	private final Region.Builder regionBuilder;
	private final int timeResolution;
	private final ProgressNotifier.Builder progress;
	private final Region.Builder reverseRegionBuilder;
	
	public StarHashExtractor(ConstellationMapExtractor starExtractor, 
			Region.Builder regionBuilder, 
			int timeResolution,
			ProgressNotifier.Builder progress) {
		this(starExtractor, regionBuilder, null, timeResolution, progress);
	}

	public StarHashExtractor(ConstellationMapExtractor starExtractor, 
			Region.Builder regionBuilder, 
			Region.Builder reverseRegionBuilder,
			int timeResolution,
			ProgressNotifier.Builder progress) {
		this.starExtractor = starExtractor;
		this.regionBuilder = regionBuilder;
		this.reverseRegionBuilder = reverseRegionBuilder;
		this.timeResolution = timeResolution;
		this.progress = progress;
	}
	
	@Override
	public StarHashSignature extractSignature(Spectrogram spec) {
		ConstellationMapSignature starSig = starExtractor.extractSignature(spec);
		List<Star> stars = new ArrayList<Star>(starSig.getConstellationMap().getStars());