本文整理汇总了Java中org.jfree.chart.ChartPanel.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java ChartPanel.setBackground方法的具体用法?Java ChartPanel.setBackground怎么用?Java ChartPanel.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.ChartPanel
的用法示例。
在下文中一共展示了ChartPanel.setBackground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateChart
import org.jfree.chart.ChartPanel; //导入方法依赖的package包/类
public void updateChart(double[] data) {
this.removeAll();
this.revalidate();
series = new XYSeries("XYGraph");
for(int i=0; i<data.length;i++){
if(data[i]>-1){
series.add(5*i , data[i]/255 );
}
}
dataset = new XYSeriesCollection();
dataset.addSeries(series);
chart = ChartFactory.createScatterPlot(
null, // Title
"ω [rad/s]", // x-axis Label
"Q / Qmax", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL,
false, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint( Color.WHITE );
XYItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(0, Color.RED);
double delta = 2.0;
Shape shape1 = new Rectangle2D.Double(-delta, -delta, delta, delta);
renderer.setSeriesShape(0, shape1);
ValueAxis yAxis = plot.getRangeAxis();
yAxis.setRange(0, 1.1);
ValueAxis xAxis = plot.getDomainAxis();
xAxis.setRange(0, 2000);
ChartPanel cp = new ChartPanel(chart);
cp.setBackground(Color.WHITE);
this.setLayout(new BorderLayout());
this.add(cp, BorderLayout.CENTER);
this.repaint();
}
示例2: updateCharts
import org.jfree.chart.ChartPanel; //导入方法依赖的package包/类
/**
* Updates the charts.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
for (int i = 0; i < listOfChartPanels.size(); i++) {
JPanel panel = listOfChartPanels.get(i);
panel.removeAll();
final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {
private static final long serialVersionUID = -6953213567063104487L;
@Override
public Dimension getPreferredSize() {
return DIMENSION_CHART_PANEL_ENLARGED;
}
};
chartPanel.setPopupMenu(null);
chartPanel.setBackground(COLOR_TRANSPARENT);
chartPanel.setOpaque(false);
chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
panel.add(chartPanel, BorderLayout.CENTER);
JPanel openChartPanel = new JPanel(new GridBagLayout());
openChartPanel.setOpaque(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
JButton openChartButton = new JButton(OPEN_CHART_ACTION);
openChartButton.setOpaque(false);
openChartButton.setContentAreaFilled(false);
openChartButton.setBorderPainted(false);
openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
openChartButton.setIcon(null);
Font font = openChartButton.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));
openChartPanel.add(openChartButton, gbc);
panel.add(openChartPanel, BorderLayout.SOUTH);
panel.revalidate();
panel.repaint();
}
}