PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/ftr-gwt-charts/src/eu/future/earth/gwt/charts/client/PointSorter.java

http://ftr-gwt-library.googlecode.com/
Java | 26 lines | 20 code | 6 blank | 0 comment | 5 complexity | 90d5620c6187e4fa1ab4d8b5ac065055 MD5 | raw file
 1package eu.future.earth.gwt.charts.client;
 2
 3import java.util.Comparator;
 4
 5public class PointSorter<T> implements Comparator<T> {
 6
 7	private PointTranslator<T> translator;
 8
 9	public PointSorter(PointTranslator<T> translator) {
10		super();
11		this.translator = translator;
12	}
13
14	public int compare(T o1, T o2) {
15		if (translator.getXCoor(o1) == translator.getXCoor(o2)) {
16			return 0;
17		} else {
18			if (translator.getXCoor(o1) < translator.getXCoor(o2)) {
19				return -1;
20			} else {
21				return 1;
22			}
23		}
24	}
25
26}