Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src-test / org / cresques / ui / HistogramPanelTest.java @ 8026

History | View | Annotate | Download (3.96 KB)

1
/*
2
 * Created on 19-jul-2006
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 */
25
package org.cresques.ui;
26

    
27
import java.awt.event.ComponentEvent;
28
import java.awt.event.ComponentListener;
29
import java.awt.event.WindowEvent;
30
import java.awt.event.WindowListener;
31
import java.io.File;
32
import java.net.MalformedURLException;
33
import java.util.Locale;
34

    
35
import javax.swing.JFrame;
36
import javax.swing.UIManager;
37

    
38
import org.cresques.ui.raster.HistogramPanel;
39
import org.gvsig.gui.beans.graphic.GraphicChartPanel;
40
import org.gvsig.i18n.Messages;
41

    
42
/**
43
 * C?digo de prueba para la interfaz de usuario de representaci?n de
44
 * histogramas.
45
 * 
46
 * @author Diego Guerrero (diego.guerrero@uclm.es)
47
 *
48
 */
49

    
50
public class HistogramPanelTest implements ComponentListener, WindowListener {
51
        
52
        private int                         w = 700, h = 500;
53
        private JFrame                         frame=new JFrame();
54
        private HistogramPanel        hp = null;
55
        
56
        public HistogramPanelTest(){
57
                hp = new HistogramPanel(w - 12, h - 45);
58
                //hp = new HistogramPanel(histogramas);
59
                int[][] g = new int[3][256]; 
60
                for (int i = 0; i < 256; i++){ 
61
            g[0][i] = 329;
62
            g[1][i] = 280;
63
            g[2][i] = 401;
64
                }
65
                
66
                GraphicChartPanel cp = hp.getPHistogram().getPGraphic();
67
                cp.replaceValuesChart(g);
68
                
69
                frame.addComponentListener(this);
70
                frame.addWindowListener(this);
71
                frame.getContentPane().add(hp);
72
                frame.setSize(w,h);
73
                frame.setResizable(true);
74
                frame.setTitle("Histogramas");
75
                frame.setVisible(true);
76
        }
77
        
78
        public static void main(String[] args){
79
                try {
80
                        Messages.addLocale(new Locale("es"));
81
                        Messages.addResourceFamily("text", new File("bin/org/cresques/translations"));
82
                } catch (MalformedURLException e) {
83
                        e.printStackTrace();
84
                }
85
                try {
86
                          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
87
                          //UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
88
                          //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
89
            } catch( Exception e ) {
90
                  System.err.println( "No se puede cambiar al LookAndFeel");
91
            }
92
                HistogramPanelTest hpt = new HistogramPanelTest();
93
        }
94

    
95
        public void componentHidden(ComponentEvent e) {
96
                // TODO Auto-generated method stub
97

    
98
        }
99

    
100
        public void componentMoved(ComponentEvent e) {
101
                // TODO Auto-generated method stub
102

    
103
        }
104

    
105
        public void componentResized(ComponentEvent e) {
106
                hp.setComponentSize(frame.getWidth() - 12, frame.getHeight() - 45);
107

    
108
        }
109

    
110
        public void componentShown(ComponentEvent e) {
111
                // TODO Auto-generated method stub
112

    
113
        }
114

    
115
        public void windowActivated(WindowEvent e) {
116
                // TODO Auto-generated method stub
117
                
118
        }
119

    
120
        public void windowClosed(WindowEvent e) {
121
                // TODO Auto-generated method stub
122
                
123
        }
124

    
125
        public void windowClosing(WindowEvent e) {
126
                System.exit(0);
127
                
128
        }
129

    
130
        public void windowDeactivated(WindowEvent e) {
131
                // TODO Auto-generated method stub
132
                
133
        }
134

    
135
        public void windowDeiconified(WindowEvent e) {
136
                // TODO Auto-generated method stub
137
                
138
        }
139

    
140
        public void windowIconified(WindowEvent e) {
141
                // TODO Auto-generated method stub
142
                
143
        }
144

    
145
        public void windowOpened(WindowEvent e) {
146
                // TODO Auto-generated method stub
147
                
148
        }
149

    
150
}