### Question:
Decimator { public final void decimate(Geometry geom) { if (spanx == -1) return; if (geom instanceof MultiPoint) { return; } if (geom instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geom; final int numGeometries = collection.getNumGeometries(); for (int i = 0; i < numGeometries; i++) { decimate(collection.getGeometryN(i)); } } else if (geom instanceof LineString) { LineString line = (LineString) geom; LiteCoordinateSequence seq = (LiteCoordinateSequence) line .getCoordinateSequence(); if (decimateOnEnvelope(line, seq)) { return; } decimate(line, seq); } else if (geom instanceof Polygon) { Polygon line = (Polygon) geom; decimate(line.getExteriorRing()); final int numRings = line.getNumInteriorRing(); for (int i = 0; i < numRings; i++) { decimate(line.getInteriorRingN(i)); } } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(MathTransform screenToWorld);  Decimator(double spanx, double spany); static double[] computeGeneralizationDistances(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance); final void decimateTransformGeneralize(Geometry geometry,
			MathTransform transform); final void decimate(Geometry geom);  }### Answer:
@Test public void testNoDecimation() { LinearRing g = gf.createLinearRing(csf.create(new double[] {0,0,0,10,2,10,2,0,0,0})); LinearRing original = (LinearRing) g.clone(); assertTrue(g.isValid()); Decimator d = new Decimator(-1, -1); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertTrue(original.equals(g)); }
@Test public void testDecimateRing() { LinearRing g = gf.createLinearRing(csf.create(new double[] {0,0,0,10,2,10,2,0,0,0})); assertTrue(g.isValid()); Decimator d = new Decimator(4, 4); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(4, g.getCoordinateSequence().size()); }
@Test public void testDecimatePseudoRing() { LineString g = gf.createLineString(csf.create(new double[] {0,0,0,10,0,0})); assertTrue(g.isValid()); Decimator d = new Decimator(4, 4); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(3, g.getCoordinateSequence().size()); }
@Test public void testDecimateRingEnvelope() { LinearRing g = gf.createLinearRing(csf.create(new double[] {0,0,0,10,2,10,2,0,0,0})); assertTrue(g.isValid()); Decimator d = new Decimator(20, 20); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertEquals(4, g.getCoordinateSequence().size()); }
@Test public void testNoDecimation() { LinearRing g = gf.createLinearRing(csf.create(new double[] {0,0,0,10,2,10,2,0,0,0})); LinearRing original = (LinearRing) g.clone(); assertTrue(g.isValid()); Decimator d = new Decimator(-1, -1); d.decimate(g); g.geometryChanged(); assertTrue(g.isValid()); assertTrue(original.equalsExact(g)); }