Revision 11004 trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/GraphicChartPanel.java
GraphicChartPanel.java | ||
---|---|---|
19 | 19 |
package org.gvsig.gui.beans.graphic; |
20 | 20 |
|
21 | 21 |
import java.awt.BasicStroke; |
22 |
import java.awt.BorderLayout; |
|
22 | 23 |
import java.awt.Color; |
23 |
import java.awt.FlowLayout; |
|
24 | 24 |
|
25 | 25 |
import javax.swing.JPanel; |
26 | 26 |
|
... | ... | |
40 | 40 |
|
41 | 41 |
public class GraphicChartPanel extends JPanel { |
42 | 42 |
private static final long serialVersionUID = 7328137487119964665L; |
43 |
private static final int HEIGHT_MARGIN = 5; |
|
44 |
private static final int WIDTH_MARGIN = 4; |
|
45 | 43 |
private JFreeChart chart; |
46 | 44 |
private ChartPanel jPanelChart = null; |
47 | 45 |
private XYSeries series[] = null; |
48 | 46 |
private XYSeriesCollection dataset = null; |
49 |
private int width = 300, height = 150; |
|
50 | 47 |
|
51 |
|
|
52 |
public GraphicChartPanel(int width, int height) { |
|
53 |
this.width = width; |
|
54 |
this.height = height; |
|
55 |
|
|
48 |
public GraphicChartPanel() { |
|
56 | 49 |
int nSeries = 3; |
57 | 50 |
|
58 | 51 |
series = new XYSeries[nSeries]; |
... | ... | |
79 | 72 |
* |
80 | 73 |
*/ |
81 | 74 |
private void initialize() { |
82 |
FlowLayout flowLayout = new FlowLayout(); |
|
83 |
flowLayout.setVgap(0); |
|
84 |
flowLayout.setHgap(0); |
|
85 |
this.setLayout(flowLayout); |
|
86 |
this.setSize(new java.awt.Dimension(width, height)); |
|
87 |
this.setPreferredSize(new java.awt.Dimension(width, height)); |
|
88 |
this.add(getChart(), null); |
|
75 |
this.setLayout(new BorderLayout()); |
|
76 |
this.add(getChart(), BorderLayout.CENTER); |
|
89 | 77 |
} |
90 | 78 |
|
91 | 79 |
/** |
... | ... | |
95 | 83 |
public ChartPanel getChart(){ |
96 | 84 |
if(jPanelChart == null){ |
97 | 85 |
jPanelChart = new ChartPanel(chart); |
98 |
jPanelChart.setSize(new java.awt.Dimension(width - WIDTH_MARGIN, height - HEIGHT_MARGIN)); |
|
99 |
jPanelChart.setPreferredSize(new java.awt.Dimension(width - WIDTH_MARGIN, height - HEIGHT_MARGIN)); |
|
100 | 86 |
jPanelChart.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); |
101 | 87 |
} |
102 | 88 |
return jPanelChart; |
... | ... | |
171 | 157 |
dataset.removeAllSeries(); |
172 | 158 |
jPanelChart.repaint(); |
173 | 159 |
} |
174 |
|
|
175 |
/** |
|
176 |
* Asigna el tama?o del componente |
|
177 |
* @param w Nuevo ancho del componente padre |
|
178 |
* @param h Nuevo alto del componente padre |
|
179 |
*/ |
|
180 |
public void setComponentSize(int w, int h){ |
|
181 |
width = w; |
|
182 |
height = h; |
|
183 |
this.setSize(new java.awt.Dimension(w, h)); |
|
184 |
this.setPreferredSize(new java.awt.Dimension(w, h)); |
|
185 |
jPanelChart.setSize(new java.awt.Dimension(w - WIDTH_MARGIN, h - HEIGHT_MARGIN)); |
|
186 |
jPanelChart.setPreferredSize(new java.awt.Dimension(w - WIDTH_MARGIN, h - HEIGHT_MARGIN)); |
|
187 |
} |
|
188 |
} |
|
160 |
} |
Also available in: Unified diff