有几次我因为建议使用以下方法而受到批评:
在Swing组件上.当我想在显示的组件之间定义比例时,我没有看到任何替代它们的用法.我被告知这个:
对于布局,答案总是相同的:使用合适的LayoutManager
我在网上搜索了一下,但我没有找到任何关于这个主题的综合分析.所以我有以下问题:
我用JFreeChart创建了一个温度计图表,但我想改变温度计中的水银颜色.我怎样才能做到这一点?到目前为止,这是我的代码; 请说明更改此代码的位置:
final DefaultValueDataset dataset = new DefaultValueDataset(new Double(10));
// create the chart...
final ThermometerPlot plot = new ThermometerPlot(dataset);
final JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title
JFreeChart.DEFAULT_TITLE_FONT,
plot, // plot
false); // include legend
chart.setBackgroundPaint(new Color(241,250,224));
plot.setMercuryPaint();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperBound(50);
Run Code Online (Sandbox Code Playgroud)
我想创建类似极点/零点的极点/零点图.它用于显示IIR和FIR滤波器属性,如稳定性,类型......
我的问题是:如何为两个轴设置相同的比例(不是范围)?
我使用ScatterPlot作为图表.
JFreeChart chart = ChartFactory.createScatterPlot("Pole/zero plot", // chart
// title
"real", // x axis label
"imaginary", // y axis label
result, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
plot.setDomainGridlinePaint(Color.black);
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelsVisible(true, true);
plot.setDomainCrosshairVisible(true);
plot.setDomainCrosshairLockedOnData(true);
plot.setRangeCrosshairVisible(true);
plot.setRangeCrosshairLockedOnData(true);
float dash1[] = { 10.0f };
XYShapeAnnotation unitCircle = new XYShapeAnnotation(
new Ellipse2D.Double(-1, -1, 2, 2), new BasicStroke(1.0f,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, …Run Code Online (Sandbox Code Playgroud)