svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / InfoPanel.java @ 5222
History | View | Annotate | Download (4.17 KB)
1 | 2809 | nacho | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | package org.cresques.ui.raster; |
||
25 | |||
26 | import java.awt.BorderLayout; |
||
27 | |||
28 | import javax.swing.JPanel; |
||
29 | import javax.swing.JScrollPane; |
||
30 | import javax.swing.JTable; |
||
31 | import javax.swing.table.TableColumn; |
||
32 | |||
33 | |||
34 | /**
|
||
35 | * Panel que contiene la informaci?n sobre un raster
|
||
36 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
37 | */
|
||
38 | public class InfoPanel extends JPanel { |
||
39 | final private static long serialVersionUID = -3370601314380922368L; |
||
40 | private JPanel jPanel = null; |
||
41 | private JTable jTable = null; |
||
42 | private JScrollPane jScrollPane = null; |
||
43 | |||
44 | /**
|
||
45 | * Nombre del panel
|
||
46 | */
|
||
47 | 3791 | nacho | private String nom = "Info"; |
48 | 2809 | nacho | |
49 | /**
|
||
50 | * Dialogo padre que contiene a este
|
||
51 | */
|
||
52 | public FilterRasterDialogPanel parent = null; |
||
53 | |||
54 | /**
|
||
55 | * Propiedades guardadas en una matriz Nx2 con la forma proiedad/valor
|
||
56 | */
|
||
57 | public Object[][] props = null; |
||
58 | |||
59 | /**
|
||
60 | * Cabeceras de las columnas del dialogo accesibles desde fuera para su traducci?n
|
||
61 | */
|
||
62 | public Object[] columnNames = { "Propiedad", "Valor" }; |
||
63 | |||
64 | /**
|
||
65 | * Constructor que asigna el objeto del panel padre y las propiedades (props) contenidas este.
|
||
66 | * Ejecuta el m?todo initialize.
|
||
67 | * @param parent Panel que contiene a este
|
||
68 | */
|
||
69 | public InfoPanel(FilterRasterDialogPanel parent) {
|
||
70 | super();
|
||
71 | this.parent = parent;
|
||
72 | this.props = parent.props;
|
||
73 | initialize(); |
||
74 | } |
||
75 | |||
76 | /**
|
||
77 | * M?todo de inicializaci?n
|
||
78 | *
|
||
79 | * @return void
|
||
80 | */
|
||
81 | public void initialize() { |
||
82 | this.setLayout(new BorderLayout()); |
||
83 | this.setSize(350, 210); |
||
84 | this.add(getJPanel(), java.awt.BorderLayout.CENTER);
|
||
85 | initControls(); |
||
86 | } |
||
87 | |||
88 | /**
|
||
89 | 3791 | nacho | * Obtiene el nombre del panel
|
90 | * @return Cadena con el nombre del panel
|
||
91 | */
|
||
92 | public String getName(){ |
||
93 | return this.nom; |
||
94 | } |
||
95 | |||
96 | /**
|
||
97 | 2809 | nacho | * Resetea los controles por defecto
|
98 | */
|
||
99 | public void resetTable() { |
||
100 | this.jTable = null; |
||
101 | this.jPanel = null; |
||
102 | this.jScrollPane = null; |
||
103 | } |
||
104 | |||
105 | /**
|
||
106 | * Inicializa controles a sus valores por defecto
|
||
107 | */
|
||
108 | public void initControls() { |
||
109 | TableColumn column = null; |
||
110 | column = jTable.getColumnModel().getColumn(0);
|
||
111 | column.setPreferredWidth(10);
|
||
112 | } |
||
113 | |||
114 | /**
|
||
115 | * This method initializes jPanel
|
||
116 | *
|
||
117 | * @return javax.swing.JPanel
|
||
118 | */
|
||
119 | private JPanel getJPanel() { |
||
120 | if (jPanel == null) { |
||
121 | jPanel = new JPanel(); |
||
122 | jPanel.setLayout(new BorderLayout()); |
||
123 | jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
||
124 | } |
||
125 | |||
126 | return jPanel;
|
||
127 | } |
||
128 | |||
129 | /**
|
||
130 | * This method initializes jTable
|
||
131 | *
|
||
132 | * @return javax.swing.JTable
|
||
133 | */
|
||
134 | private JTable getJTable() { |
||
135 | if (jTable == null) { |
||
136 | jTable = new JTable(props, columnNames); |
||
137 | jTable.setShowGrid(true);
|
||
138 | jTable.setShowHorizontalLines(false);
|
||
139 | |||
140 | //jTable.setRowHeight(30);
|
||
141 | jTable.setCellSelectionEnabled(true);
|
||
142 | } |
||
143 | |||
144 | return jTable;
|
||
145 | } |
||
146 | |||
147 | /**
|
||
148 | * This method initializes jScrollPane
|
||
149 | *
|
||
150 | * @return javax.swing.JScrollPane
|
||
151 | */
|
||
152 | private JScrollPane getJScrollPane() { |
||
153 | if (jScrollPane == null) { |
||
154 | jScrollPane = new JScrollPane(); |
||
155 | jScrollPane.setViewportView(getJTable()); |
||
156 | } |
||
157 | |||
158 | return jScrollPane;
|
||
159 | } |
||
160 | } // @jve:decl-index=0:visual-constraint="40,32" |