本文整理匯總了Java中org.jfree.chart.plot.CategoryPlot.getBackgroundImage方法的典型用法代碼示例。如果您正苦於以下問題:Java CategoryPlot.getBackgroundImage方法的具體用法?Java CategoryPlot.getBackgroundImage怎麽用?Java CategoryPlot.getBackgroundImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.plot.CategoryPlot
的用法示例。
在下文中一共展示了CategoryPlot.getBackgroundImage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawBackground
import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
* Draws the background for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// fill background...
Paint backgroundPaint = plot.getBackgroundPaint();
if (backgroundPaint != null) {
g2.setPaint(backgroundPaint);
g2.fill(clip);
}
GeneralPath leftWall = new GeneralPath();
leftWall.moveTo(x0, y0);
leftWall.lineTo(x0, y2);
leftWall.lineTo(x1, y3);
leftWall.lineTo(x1, y1);
leftWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(leftWall);
GeneralPath bottomWall = new GeneralPath();
bottomWall.moveTo(x0, y0);
bottomWall.lineTo(x1, y1);
bottomWall.lineTo(x3, y1);
bottomWall.lineTo(x2, y0);
bottomWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(bottomWall);
// higlight the background corners...
g2.setPaint(Color.lightGray);
Line2D corner = new Line2D.Double(x0, y0, x1, y1);
g2.draw(corner);
corner.setLine(x1, y1, x1, y3);
g2.draw(corner);
corner.setLine(x1, y1, x3, y1);
g2.draw(corner);
// draw background image, if there is one...
Image backgroundImage = plot.getBackgroundImage();
if (backgroundImage != null) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC,
plot.getBackgroundAlpha()));
g2.drawImage(backgroundImage,
(int) x1, (int) y3,
(int) (x3 - x1 + 1), (int) (y1 - y3 + 1),
null);
g2.setComposite(originalComposite);
}
}
示例2: drawBackground
import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
* Draws the background for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawBackground(Graphics2D g2, CategoryPlot plot,
Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// fill background...
Paint backgroundPaint = plot.getBackgroundPaint();
if (backgroundPaint != null) {
g2.setPaint(backgroundPaint);
g2.fill(clip);
}
GeneralPath leftWall = new GeneralPath();
leftWall.moveTo(x0, y0);
leftWall.lineTo(x0, y2);
leftWall.lineTo(x1, y3);
leftWall.lineTo(x1, y1);
leftWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(leftWall);
GeneralPath bottomWall = new GeneralPath();
bottomWall.moveTo(x0, y0);
bottomWall.lineTo(x1, y1);
bottomWall.lineTo(x3, y1);
bottomWall.lineTo(x2, y0);
bottomWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(bottomWall);
// higlight the background corners...
g2.setPaint(Color.lightGray);
Line2D corner = new Line2D.Double(x0, y0, x1, y1);
g2.draw(corner);
corner.setLine(x1, y1, x1, y3);
g2.draw(corner);
corner.setLine(x1, y1, x3, y1);
g2.draw(corner);
// draw background image, if there is one...
Image backgroundImage = plot.getBackgroundImage();
if (backgroundImage != null) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC, plot.getBackgroundAlpha()));
g2.drawImage(backgroundImage, (int) x1, (int) y3,
(int) (x3 - x1 + 1), (int) (y1 - y3 + 1), null);
g2.setComposite(originalComposite);
}
}
示例3: drawBackground
import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
* Draws the background for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawBackground(Graphics2D g2, CategoryPlot plot,
Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// fill background...
Paint backgroundPaint = plot.getBackgroundPaint();
if (backgroundPaint != null) {
g2.setPaint(backgroundPaint);
g2.fill(clip);
}
GeneralPath leftWall = new GeneralPath();
leftWall.moveTo(x0, y0);
leftWall.lineTo(x0, y2);
leftWall.lineTo(x1, y3);
leftWall.lineTo(x1, y1);
leftWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(leftWall);
GeneralPath bottomWall = new GeneralPath();
bottomWall.moveTo(x0, y0);
bottomWall.lineTo(x1, y1);
bottomWall.lineTo(x3, y1);
bottomWall.lineTo(x2, y0);
bottomWall.closePath();
g2.setPaint(getWallPaint());
g2.fill(bottomWall);
// higlight the background corners...
g2.setPaint(Color.lightGray);
Line2D corner = new Line2D.Double(x0, y0, x1, y1);
g2.draw(corner);
corner.setLine(x1, y1, x1, y3);
g2.draw(corner);
corner.setLine(x1, y1, x3, y1);
g2.draw(corner);
// draw background image, if there is one...
Image backgroundImage = plot.getBackgroundImage();
if (backgroundImage != null) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC,
plot.getBackgroundAlpha()));
g2.drawImage(backgroundImage, (int) x1, (int) y3,
(int) (x3 - x1 + 1), (int) (y1 - y3 + 1), null);
g2.setComposite(originalComposite);
}
}