0
jfreechart 1.0.13JFreeChart不正確的工具提示位置
我在jfreechart中的工具提示的位置有一些問題。 我通過以下配置
private static final GradientPaint GRADIENT_PAINT = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
private static final double ITEM_MARGIN = 0.2d;
private static final double MAXIMUM_BAR_WIDTH = .04;
private static final int MAXIMUM_CATEGORY_LABEL_WIDTH = 10;
private static final int MAXIMUM_CATEGORY_LABEL_LINES = 2;
private static final Paint BACKGROUND_COLOR = new Color(196, 196, 196);
@Override
protected BarRenderer configMainRenderer() {
BarRenderer renderer = new BarRenderer();
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
renderer.setShadowVisible(false);
renderer.setDrawBarOutline(false);
renderer.setDrawBarOutline(true);
renderer.setMaximumBarWidth(MAXIMUM_BAR_WIDTH);
renderer.setSeriesPaint(0, GRADIENT_PAINT);
renderer.setItemMargin(ITEM_MARGIN);
return renderer;
}
@Override
protected NumberAxis configRangeAxis(IRangeAxis axis) {
NumberAxis valueAxis = new NumberAxis(axis.getName());
valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
return valueAxis;
}
@Override
protected CategoryAxis configDomainAxis(String domainAxisName) {
CategoryAxis domainAxis = new CategoryAxis(domainAxisName);
domainAxis.setMaximumCategoryLabelWidthRatio(MAXIMUM_CATEGORY_LABEL_WIDTH);
domainAxis.setMaximumCategoryLabelLines(MAXIMUM_CATEGORY_LABEL_LINES);
domainAxis.setTickLabelFont(getDefaultDomainAxisFont());
return domainAxis;
}
@Override
protected CategoryPlot plotSetup(Dataset dataset, CategoryAxis domainAxis, NumberAxis mainRangeAxis, BarRenderer mainRenderer) {
CategoryDataset catDataset = (CategoryDataset)dataset;
CategoryPlot plot = new CategoryPlot(catDataset, domainAxis, mainRangeAxis, mainRenderer);
plot.setOrientation(getModel().getPlotOrientation());
plot.setBackgroundPaint(BACKGROUND_COLOR);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
return plot;
然後我把新創建的圖表到ChartComposite鑑於構造它。
//creating composite for chart
chartComposite = new ChartComposite(controlsComposite, SWT.NONE);
chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
chartComposite.setVisible(false);
chartComposite.addChartMouseListener(this);
// update chartcomposite when necessary
chartComposite.setVisible(true);
chartComposite.setChart(chart);
chartComposite.setHorizontalAxisTrace(true);
chartComposite.forceRedraw();
因爲我有正確的圖表,但所有的工具提示都轉移到視圖/合成的右側。此外,當我試圖從該「0」點選擇可用的一些圖表區域-selection沒有,但似乎喜歡它轉移了。(見所附圖片)
我會很高興聽到這樣的任何建議行爲
這是[tag:swt]問題嗎?另請參閱此[答案](http://stackoverflow.com/a/8026305/230513)。 – trashgod
是的。我有類似的問題。 – Volad