[英]Draw a down triangle shape
I am trying to draw down triangles in my GanttRenderer class in JFreeChart. 我试图在JFreeChart的GanttRenderer类中绘制三角形。 I can get the shape from the Shape Utilities: 我可以从Shape Utilities获取形状:
Shape triangle = ShapeUtilities.createDownTriangle(4.0f);
How do I draw the shape at the correct location and set the dimension parameters? 如何在正确的位置绘制形状并设置尺寸参数?
public class Renderer extends GanttRenderer {
private final TaskSeriesCollection model;
public Renderer(TaskSeriesCollection model) {
this.model = model;
}
@Override
protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) {
/*Some other code here*/
Shape triangle = ShapeUtilities.createDownTriangle(4.0f);
// Rectangle2D triangleContainer = triangle.getBounds2D();
// triangleContainer.setRect(subtaskStartTranslated, rectYAxisStart, rectBreadth, rectBreadth);
g2.setPaint(new Color(255,0,0));
g2.draw(triangle);
/*Some other code here*/
}
}
创建原始形状的平移形状,如下所示:
Shape downTriangle = ShapeUtils.createTranslatedShape(ShapeUtils.createDownTriangle(sizeFactor), sizeFactor, sizeFactor);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.