1
我使用jfree圖來繪製一些定位點。jfree圖在圖像上繪製陰謀
問題是該圖是繪製在灰色表面上而不是我的平面圖上。所以我試圖使用背景圖片,但是這會將圖片置於背景中,並且因爲我需要它而不可用。
我想用圖像替換灰色背景。我怎樣才能做到這一點?
我使用ChartPanel在它上面繪製圖表。問題是,這隻允許顏色作爲背景和圖像。我試圖將圖片設置爲圖表,如下面的代碼中所示,但這隻設置背景圖像並在灰色區域的前景中繪製圖表。
JFreeChart chart = ChartFactory.createScatterPlot("XY Chart", // Title
"x-axis", // x-axis Label
"y-axis", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
false, // Show Legend
false, // Use tooltips
false // Configure chart to generate URLs?
);
BufferedImage image = null;
try {
File url = new File(System.getProperty("user.dir").toString()+"\\1.jpg");
image = ImageIO.read(url);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
chart.setBackgroundImage(image);
你應該爲你的問題添加更多細節,包括你的一些代碼和一個截圖,如果你能得到一個,更好地解釋你期望得到的東西。 – Brian
我認爲你正在繪製面板。嘗試設置面板的背景,然後繪製它。 –