@Test public void testDateColoring() throws Exception { List<Earthquake> quakes = new ArrayList<Earthquake>(); quakes.add(new Earthquake(Position.fromDegrees(100, 100, -100), 5, getMillisForDate("1950-01-01"))); quakes.add(new Earthquake(Position.fromDegrees(100, 100, -100), 5, getMillisForDate("1970-01-01"))); quakes.add(new Earthquake(Position.fromDegrees(100, 100, -100), 5, getMillisForDate("1990-01-01"))); FloatBuffer colorBuffer = FloatBuffer.allocate(quakes.size() * 3); classUnderTest.generateDateColoring(colorBuffer, quakes); colorBuffer.rewind(); List<HSLColor> colors = getColors(colorBuffer); assertEquals(3, colors.size()); assertEquals(BLUE_HUE, colors.get(0).getHue(), 1); assertEquals(GREEN_HUE, colors.get(1).getHue(), 1); assertEquals(RED_HUE, colors.get(2).getHue(), 1); }
protected void generateDateColoring(FloatBuffer colorBuffer, List<Earthquake> earthquakes) { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; if (coloringMinDate == null || coloringMaxDate == null) { for (Earthquake earthquake : earthquakes) { minTime = Math.min(minTime, earthquake.timeInMillis); maxTime = Math.max(maxTime, earthquake.timeInMillis); } } minTime = coloringMinDate != null ? coloringMinDate : minTime; maxTime = coloringMaxDate != null ? coloringMaxDate : maxTime; for (Earthquake earthquake : earthquakes) { double percent = (earthquake.timeInMillis - minTime) / (double) (maxTime - minTime); percent = 1 - Math.max(0, Math.min(1, percent)); Color color = new HSLColor((float) (240d * percent), 100f, 50f).getRGB(); colorBuffer.put(color.getRed() / 255f).put(color.getGreen() / 255f).put(color.getBlue() / 255f); } }
HistoricEarthquakesLayer extends AbstractLayer implements Loader { protected void generateDateColoring(FloatBuffer colorBuffer, List<Earthquake> earthquakes) { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; if (coloringMinDate == null || coloringMaxDate == null) { for (Earthquake earthquake : earthquakes) { minTime = Math.min(minTime, earthquake.timeInMillis); maxTime = Math.max(maxTime, earthquake.timeInMillis); } } minTime = coloringMinDate != null ? coloringMinDate : minTime; maxTime = coloringMaxDate != null ? coloringMaxDate : maxTime; for (Earthquake earthquake : earthquakes) { double percent = (earthquake.timeInMillis - minTime) / (double) (maxTime - minTime); percent = 1 - Math.max(0, Math.min(1, percent)); Color color = new HSLColor((float) (240d * percent), 100f, 50f).getRGB(); colorBuffer.put(color.getRed() / 255f).put(color.getGreen() / 255f).put(color.getBlue() / 255f); } } }
HistoricEarthquakesLayer extends AbstractLayer implements Loader { protected void generateDateColoring(FloatBuffer colorBuffer, List<Earthquake> earthquakes) { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; if (coloringMinDate == null || coloringMaxDate == null) { for (Earthquake earthquake : earthquakes) { minTime = Math.min(minTime, earthquake.timeInMillis); maxTime = Math.max(maxTime, earthquake.timeInMillis); } } minTime = coloringMinDate != null ? coloringMinDate : minTime; maxTime = coloringMaxDate != null ? coloringMaxDate : maxTime; for (Earthquake earthquake : earthquakes) { double percent = (earthquake.timeInMillis - minTime) / (double) (maxTime - minTime); percent = 1 - Math.max(0, Math.min(1, percent)); Color color = new HSLColor((float) (240d * percent), 100f, 50f).getRGB(); colorBuffer.put(color.getRed() / 255f).put(color.getGreen() / 255f).put(color.getBlue() / 255f); } } HistoricEarthquakesLayer(AVList params);  HistoricEarthquakesLayer(Document dom, AVList params);  HistoricEarthquakesLayer(Element domElement, AVList params); }
HistoricEarthquakesLayer extends AbstractLayer implements Loader { protected void generateDateColoring(FloatBuffer colorBuffer, List<Earthquake> earthquakes) { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; if (coloringMinDate == null || coloringMaxDate == null) { for (Earthquake earthquake : earthquakes) { minTime = Math.min(minTime, earthquake.timeInMillis); maxTime = Math.max(maxTime, earthquake.timeInMillis); } } minTime = coloringMinDate != null ? coloringMinDate : minTime; maxTime = coloringMaxDate != null ? coloringMaxDate : maxTime; for (Earthquake earthquake : earthquakes) { double percent = (earthquake.timeInMillis - minTime) / (double) (maxTime - minTime); percent = 1 - Math.max(0, Math.min(1, percent)); Color color = new HSLColor((float) (240d * percent), 100f, 50f).getRGB(); colorBuffer.put(color.getRed() / 255f).put(color.getGreen() / 255f).put(color.getBlue() / 255f); } } HistoricEarthquakesLayer(AVList params);  HistoricEarthquakesLayer(Document dom, AVList params);  HistoricEarthquakesLayer(Element domElement, AVList params); @Override boolean isLoading(); @Override void addLoadingListener(LoadingListener listener); @Override void removeLoadingListener(LoadingListener listener); }
HistoricEarthquakesLayer extends AbstractLayer implements Loader { protected void generateDateColoring(FloatBuffer colorBuffer, List<Earthquake> earthquakes) { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; if (coloringMinDate == null || coloringMaxDate == null) { for (Earthquake earthquake : earthquakes) { minTime = Math.min(minTime, earthquake.timeInMillis); maxTime = Math.max(maxTime, earthquake.timeInMillis); } } minTime = coloringMinDate != null ? coloringMinDate : minTime; maxTime = coloringMaxDate != null ? coloringMaxDate : maxTime; for (Earthquake earthquake : earthquakes) { double percent = (earthquake.timeInMillis - minTime) / (double) (maxTime - minTime); percent = 1 - Math.max(0, Math.min(1, percent)); Color color = new HSLColor((float) (240d * percent), 100f, 50f).getRGB(); colorBuffer.put(color.getRed() / 255f).put(color.getGreen() / 255f).put(color.getBlue() / 255f); } } HistoricEarthquakesLayer(AVList params);  HistoricEarthquakesLayer(Document dom, AVList params);  HistoricEarthquakesLayer(Element domElement, AVList params); @Override boolean isLoading(); @Override void addLoadingListener(LoadingListener listener); @Override void removeLoadingListener(LoadingListener listener); final static String DATE_COLORING; final static String MAGNITUDE_COLORING; final static String DEPTH_COLORING; }