root / trunk / libraries / libUIComponent / src-test / org / gvsig / gui / beans / graphic / TestGraphic.java @ 11070
History | View | Annotate | Download (1.66 KB)
1 |
package org.gvsig.gui.beans.graphic; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
|
5 |
import javax.swing.JFrame; |
6 |
|
7 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
8 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
9 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
10 |
import org.jfree.data.xy.XYSeries; |
11 |
import org.jfree.data.xy.XYSeriesCollection; |
12 |
|
13 |
public class TestGraphic implements GraphicListener { |
14 |
private JFrame frame=new JFrame(); |
15 |
private DefaultButtonsPanel defaultButtonsPanel = null; |
16 |
private GraphicContainer graphic = null; |
17 |
|
18 |
public TestGraphic() throws NotInitializeException{ |
19 |
graphic = new GraphicContainer(true); |
20 |
|
21 |
|
22 |
int nSeries = 3; |
23 |
|
24 |
String[] names = new String[nSeries]; |
25 |
int[][] series = new int[nSeries][256]; |
26 |
|
27 |
for(int iSerie = 0; iSerie < nSeries; iSerie++){ |
28 |
names[iSerie] = "Band " + iSerie;
|
29 |
for (int i = 0; i < 256; i++) |
30 |
series[iSerie][i] = i * (iSerie + 1);
|
31 |
} |
32 |
graphic.getPGraphic().setNewChart(series, names); |
33 |
|
34 |
|
35 |
graphic.addValueChangedListener(this);
|
36 |
defaultButtonsPanel = new DefaultButtonsPanel(ButtonsPanel.BUTTONS_CLOSE);
|
37 |
defaultButtonsPanel.setLayout(new BorderLayout(5, 5)); |
38 |
defaultButtonsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
39 |
defaultButtonsPanel.add(graphic, BorderLayout.CENTER);
|
40 |
frame.getContentPane().add(defaultButtonsPanel); |
41 |
frame.setSize(640, 480); |
42 |
frame.show(); |
43 |
} |
44 |
|
45 |
public static void main(String[] args) { |
46 |
try{
|
47 |
new TestGraphic();
|
48 |
} catch (NotInitializeException ex){
|
49 |
System.out.println("Tabla no inicializada"); |
50 |
} |
51 |
} |
52 |
|
53 |
public void actionValueChanged(GraphicEvent e) { |
54 |
System.out.println(graphic.getX1() + ":" + graphic.getX2()); |
55 |
} |
56 |
} |