我有一个名为 的类ImageMapDemo7
,我想用这个程序映射一个图像;但我遇到了一个错误。我有所有的包裹。JFreeChart中是否有任何SampleXYDataset2
课程?
代码是这样的:
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYDataset;
/**
* A demo showing how to create an HTML image map for a scatter plot.
*
*/
public class ImageMapDemo7 {
/**
* Default constructor.
*/
public ImageMapDemo7() {
super();
}
public static void main(final String[] args) {
final XYDataset data = new SampleXYDataset2();
final JFreeChart chart = ChartFactory.createScatterPlot(
"Scatter Plot Demo",
"X", "Y",
data,
PlotOrientation.VERTICAL,
true,
true,
false
);
// final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
chart.setBackgroundPaint(java.awt.Color.white);
// save it to an image
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final File file1 = new File("image1.jpg");
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
// write an HTML page incorporating the image with an image map
final File file2 = new File("scatter100.html");
final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2));
final PrintWriter writer = new PrintWriter(out);
writer.println("<HTML>");
writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>");
writer.println("<BODY>");
// ChartUtilities.writeImageMap(writer, "chart", info);
writer.println("<IMG SRC=\"image1.jpg\" "
+ "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
writer.println("</BODY>");
writer.println("</HTML>");
writer.close();
}
catch (IOException e) {
System.out.println(e.toString());
}
}
}
错误是这样的:
ImageMapDemo7.java:37: error: cannot find symbol
final XYDataset data = new SampleXYDataset2();
^
symbol: class SampleXYDataset2
location: class ImageMapDemo7