private static void compress(JPanel compressedContents, final SimpleXYDataset d, final SimpleXYDataset d2) {
double scale = 10000.0 / compressedContents.getWidth();
DefaultCompressor compressor = new DefaultCompressor();
PointData input = new PointData(d.getXData(), d.getYData());
PointData output = new PointData();
compressor.compress(input, output, 0, scale);
int size = d.getPointCount();
int size2 = output.getX().getLength();
DoubleData x = output.getX();
DoubleData y = output.getY();
d2.removeAllPoints();
for(int i = 0; i < size2; i++) {
d2.add(x.get(i), y.get(i));
}
System.out.println("Input size: " + size);