我需要实现一个新的"图形生成器"。为了说明这个要求,我将展示一个使用旧生成器输出的示例以及我试图开发的那个(或者我到目前为止)的输出。
我现在的主要问题是刻度线标签上的线条之间的空格。图像必须是600x150,所以我需要尽可能多地压缩图形的文本部分(它不需要视觉上美观),但到目前为止我找不到任何合适的代码。
实际上我需要消除尽可能多的白色间距"如我所能。如果有人提示如何实施以下内容,我将非常感激:
这是我用来自定义图表的代码:
CategoryPlot categoryplot = lineChart.getCategoryPlot();
lineChart.setTitle(
new org.jfree.chart.title.TextTitle(lineChart.getTitle().getText(),
new Font("SansSerif", Font.PLAIN, 10)
)
);
lineChart.setBackgroundPaint(Color.white);
categoryplot.setBackgroundPaint(Color.WHITE);
CategoryAxis domainAxis = new CategoryAxis();
domainAxis.setMaximumCategoryLabelLines(4);
categoryplot.setDomainAxis(domainAxis);
Font font = new Font("Courier", Font.PLAIN, 8);
categoryplot.getDomainAxis().setTickLabelFont(font);
categoryplot.getDomainAxis().setCategoryLabelPositionOffset(-6);
categoryplot.getDomainAxis().setTickLabelInsets(
new RectangleInsets(1.0, 1.0, 1.0, 1.0));
NumberAxis yAxis = (NumberAxis) categoryplot.getRangeAxis();
yAxis.setAutoRangeIncludesZero(false);
categoryplot.getRenderer().setSeriesStroke(
1,
new BasicStroke(
2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
1.0f, new float[] {6.0f, 6.0f}, 0.0f
)
);
categoryplot.setDomainGridlinesVisible(true);
categoryplot.setRangeGridlinesVisible(true);
categoryplot.setDomainGridlinePaint(Color.GRAY);
categoryplot.setRangeGridlinePaint(Color.GRAY);
categoryplot.getRenderer().setSeriesStroke(
2,
new BasicStroke(
2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
1.0f, new float[] {6.0f, 6.0f}, 0.0f
)
);
categoryplot.getRenderer().setSeriesPaint(0, Color.BLUE);
categoryplot.getRenderer().setSeriesPaint(1, Color.RED);
categoryplot.getRenderer().setSeriesPaint(2, Color.RED);
LineAndShapeRenderer renderer = (LineAndShapeRenderer) categoryplot.getRenderer();
renderer.setBaseShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setBaseFillPaint(Color.white);
renderer.setSeriesShape(0, new Ellipse2D.Double(-5, -5, 10, 10));