root / trunk / libraries / libUIComponent / src-test / org / gvsig / gui / beans / graphic / TestGraphic.java @ 11070
History | View | Annotate | Download (1.66 KB)
1 | 10741 | nacho | package org.gvsig.gui.beans.graphic; |
---|---|---|---|
2 | |||
3 | 11070 | bsanchez | import java.awt.BorderLayout; |
4 | |||
5 | 10741 | nacho | import javax.swing.JFrame; |
6 | |||
7 | 11070 | bsanchez | import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
8 | import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
||
9 | 10741 | nacho | import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
10 | 11070 | bsanchez | import org.jfree.data.xy.XYSeries; |
11 | import org.jfree.data.xy.XYSeriesCollection; |
||
12 | 10741 | nacho | |
13 | 11004 | bsanchez | public class TestGraphic implements GraphicListener { |
14 | 10741 | nacho | private JFrame frame=new JFrame(); |
15 | 11070 | bsanchez | private DefaultButtonsPanel defaultButtonsPanel = null; |
16 | 10741 | nacho | private GraphicContainer graphic = null; |
17 | |||
18 | public TestGraphic() throws NotInitializeException{ |
||
19 | 10981 | bsanchez | graphic = new GraphicContainer(true); |
20 | 11070 | bsanchez | |
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 | 11004 | bsanchez | graphic.addValueChangedListener(this);
|
36 | 11070 | bsanchez | 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 | 10779 | bsanchez | frame.show(); |
43 | 10741 | nacho | } |
44 | |||
45 | public static void main(String[] args) { |
||
46 | try{
|
||
47 | 10885 | bsanchez | new TestGraphic();
|
48 | 10779 | bsanchez | } catch (NotInitializeException ex){
|
49 | 10741 | nacho | System.out.println("Tabla no inicializada"); |
50 | } |
||
51 | } |
||
52 | 11004 | bsanchez | |
53 | public void actionValueChanged(GraphicEvent e) { |
||
54 | System.out.println(graphic.getX1() + ":" + graphic.getX2()); |
||
55 | } |
||
56 | 10779 | bsanchez | } |