Revision 6371
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/TestPagedBarPanel.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
2 |
|
|
3 |
|
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
|
|
7 |
import javax.swing.JFrame; |
|
8 |
|
|
9 |
public class TestPagedBarPanel implements ActionListener { |
|
10 |
private int w = 50; |
|
11 |
private int h = 250; |
|
12 |
private JFrame frame = new JFrame(); |
|
13 |
private PaginationBarPanel desc = null; |
|
14 |
|
|
15 |
public TestPagedBarPanel() { |
|
16 |
desc = new PaginationBarPanel(null); |
|
17 |
frame.getContentPane().add(desc); |
|
18 |
frame.setSize(w, h); |
|
19 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
20 |
frame.setVisible(true); |
|
21 |
} |
|
22 |
|
|
23 |
public static void main(String[] args) { |
|
24 |
new TestPagedBarPanel(); |
|
25 |
} |
|
26 |
|
|
27 |
public void actionPerformed(ActionEvent e) { |
|
28 |
|
|
29 |
} |
|
30 |
} |
|
0 | 31 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/TestPagedTablePanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
25 |
|
|
26 |
|
|
27 |
import java.awt.BorderLayout; |
|
28 |
import java.awt.Dimension; |
|
29 |
import java.awt.event.ActionEvent; |
|
30 |
import java.awt.event.ActionListener; |
|
31 |
|
|
32 |
import javax.swing.BorderFactory; |
|
33 |
import javax.swing.JFrame; |
|
34 |
import javax.swing.JPanel; |
|
35 |
|
|
36 |
import org.gvsig.raster.swing.pagedtable.ModelLoader; |
|
37 |
import org.gvsig.raster.swing.pagedtable.PagedTableEvent; |
|
38 |
import org.gvsig.raster.swing.pagedtable.PagedTableListener; |
|
39 |
|
|
40 |
public class TestPagedTablePanel implements ActionListener, PagedTableListener { |
|
41 |
private int w = 500; |
|
42 |
private int h = 350; |
|
43 |
private JFrame frame = new JFrame(); |
|
44 |
private PagedTableImpl desc = null; |
|
45 |
|
|
46 |
public TestPagedTablePanel() { |
|
47 |
String[] c = new String[]{"uno", "dos", "tres", "cuatro"}; |
|
48 |
int[] sizes = new int[]{40, 80, -1, 0}; |
|
49 |
GCPModel model = new GCPModel(c); |
|
50 |
CheckBoxColumnRenderer r = new CheckBoxColumnRenderer(this); |
|
51 |
CheckBoxColumnEditor e = new CheckBoxColumnEditor(); |
|
52 |
ModelLoader modelLoader = new ModelLoaderImpl(model); |
|
53 |
modelLoader.setRenderForColumn(0, r); |
|
54 |
modelLoader.setCellEditorForColumn(0, e); |
|
55 |
modelLoader.setColumnNames(c); |
|
56 |
modelLoader.setColumnWidths(sizes); |
|
57 |
desc = new PagedTableImpl(modelLoader); |
|
58 |
JPanel table = (JPanel)desc.getComponent(); |
|
59 |
table.setBorder(BorderFactory.createTitledBorder("My table")); |
|
60 |
desc.setConfirmationMessageDeleteAllEntries("Would you like to remove all entries?"); |
|
61 |
desc.setConfirmationMessageDeleteOneEntry("Would you like to remove selected entry?"); |
|
62 |
|
|
63 |
JPanel p = new JPanel(); |
|
64 |
p.setLayout(new BorderLayout()); |
|
65 |
p.add(table, BorderLayout.CENTER); |
|
66 |
|
|
67 |
JPanel p1 = new JPanel(); |
|
68 |
p1.setPreferredSize(new Dimension(80, 0)); |
|
69 |
p.add(p1, BorderLayout.EAST); |
|
70 |
|
|
71 |
JPanel p2 = new JPanel(); |
|
72 |
p2.setPreferredSize(new Dimension(0, 80)); |
|
73 |
p.add(p2, BorderLayout.NORTH); |
|
74 |
|
|
75 |
frame.getContentPane().add(p); |
|
76 |
frame.setSize(w, h); |
|
77 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
78 |
frame.setVisible(true); |
|
79 |
|
|
80 |
|
|
81 |
//desc.showMoveRowsControls(false); |
|
82 |
//desc.showControllerTable(false); |
|
83 |
} |
|
84 |
|
|
85 |
public static void main(String[] args) { |
|
86 |
new TestPagedTablePanel(); |
|
87 |
} |
|
88 |
|
|
89 |
public void actionPerformed(ActionEvent e) { |
|
90 |
// TODO Auto-generated method stub |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
public void tableChanged(PagedTableEvent event) { |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 |
} |
|
0 | 99 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/GCPModel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
25 |
|
|
26 |
import javax.swing.table.DefaultTableModel; |
|
27 |
|
|
28 |
import org.gvsig.raster.swing.pagedtable.TableModel; |
|
29 |
/** |
|
30 |
* Modelo correspondiente a una tabla de puntos de control |
|
31 |
* |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class GCPModel extends DefaultTableModel implements TableModel { |
|
35 |
final private static long serialVersionUID = -3370601314380922368L; |
|
36 |
private int nColumns = 0; |
|
37 |
|
|
38 |
public GCPModel(String[] columnNames) { |
|
39 |
super(new Object[0][columnNames.length], columnNames); |
|
40 |
this.nColumns = columnNames.length; |
|
41 |
} |
|
42 |
|
|
43 |
@SuppressWarnings("unchecked") |
|
44 |
public Class getColumnClass(int c) { |
|
45 |
return String.class; |
|
46 |
} |
|
47 |
|
|
48 |
public void setValueAt(Object value, int row, int col) { |
|
49 |
super.setValueAt(value, row, col); |
|
50 |
} |
|
51 |
|
|
52 |
public void addNewLine() { |
|
53 |
addNew(); |
|
54 |
} |
|
55 |
public void addNew() { |
|
56 |
Object[] line = new Object[nColumns]; |
|
57 |
line[0] = new Boolean(true); |
|
58 |
for (int i = 0; i < nColumns; i++) |
|
59 |
line[i] = new String(""); |
|
60 |
super.addRow(line); |
|
61 |
} |
|
62 |
|
|
63 |
public Object[] getNewLine() { |
|
64 |
Object[] o = new Object[nColumns]; |
|
65 |
o[0] = new Boolean(true); |
|
66 |
for (int i = 1; i < nColumns; i++) |
|
67 |
o[i] = ""; |
|
68 |
return o; |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/CheckBoxColumnEditor.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
|
|
30 |
import javax.swing.AbstractCellEditor; |
|
31 |
import javax.swing.JCheckBox; |
|
32 |
import javax.swing.JTable; |
|
33 |
import javax.swing.SwingUtilities; |
|
34 |
import javax.swing.table.TableCellEditor; |
|
35 |
|
|
36 |
/** |
|
37 |
* Componente tabla |
|
38 |
* |
|
39 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class CheckBoxColumnEditor extends AbstractCellEditor |
|
43 |
implements TableCellEditor { |
|
44 |
final private static long serialVersionUID = -3370601314380922368L; |
|
45 |
public JCheckBox theCheckBox; |
|
46 |
|
|
47 |
public CheckBoxColumnEditor() { |
|
48 |
super(); |
|
49 |
theCheckBox = new JCheckBox(); |
|
50 |
theCheckBox.addActionListener(new ActionListener() { |
|
51 |
public void actionPerformed(ActionEvent event) { |
|
52 |
fireEditingStopped() ; |
|
53 |
|
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
57 |
|
|
58 |
public Component getTableCellEditorComponent(JTable table, Object obj, |
|
59 |
boolean isSelected, |
|
60 |
int row, int col) { |
|
61 |
theCheckBox.setHorizontalAlignment(SwingUtilities.CENTER); |
|
62 |
|
|
63 |
Boolean lValueAsBoolean = (Boolean) obj; |
|
64 |
theCheckBox.setSelected(lValueAsBoolean.booleanValue()); |
|
65 |
|
|
66 |
return theCheckBox; |
|
67 |
} |
|
68 |
|
|
69 |
public Object getCellEditorValue() { |
|
70 |
return new Boolean(theCheckBox.isSelected()); |
|
71 |
} |
|
72 |
} |
|
0 | 73 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/CheckBoxColumnRenderer.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
|
|
30 |
import javax.swing.JCheckBox; |
|
31 |
import javax.swing.JTable; |
|
32 |
import javax.swing.SwingConstants; |
|
33 |
import javax.swing.table.TableCellRenderer; |
|
34 |
|
|
35 |
/** |
|
36 |
* Componente tabla |
|
37 |
* |
|
38 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
39 |
* |
|
40 |
*/ |
|
41 |
public class CheckBoxColumnRenderer extends JCheckBox implements TableCellRenderer { |
|
42 |
final private static long serialVersionUID = -3370601314380922368L; |
|
43 |
private ActionListener listener = null; |
|
44 |
|
|
45 |
public CheckBoxColumnRenderer() {} |
|
46 |
|
|
47 |
public CheckBoxColumnRenderer(ActionListener listener) { |
|
48 |
this.listener = listener; |
|
49 |
} |
|
50 |
|
|
51 |
public Component getTableCellRendererComponent(JTable table, |
|
52 |
Object value, |
|
53 |
boolean isSelected, |
|
54 |
boolean hasFocus, |
|
55 |
int row, int column) { |
|
56 |
if (value == null) { |
|
57 |
this.setSelected(false); |
|
58 |
} |
|
59 |
if(isSelected) |
|
60 |
if(listener != null) |
|
61 |
listener.actionPerformed(new ActionEvent(this, row, "SELECT_ROW")); |
|
62 |
|
|
63 |
if(value instanceof Boolean){ |
|
64 |
Boolean ValueAsBoolean = (Boolean) value; |
|
65 |
this.setSelected(ValueAsBoolean.booleanValue()); |
|
66 |
this.setHorizontalAlignment(SwingConstants.CENTER); |
|
67 |
} |
|
68 |
|
|
69 |
return this; |
|
70 |
} |
|
71 |
} |
|
0 | 72 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/org/gvsig/raster/swing/impl/pagedtable/TestPager.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.impl.pagedtable; |
|
2 |
|
|
3 |
|
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
public class TestPager { |
|
8 |
|
|
9 |
public TestPager() { |
|
10 |
Pager p = new Pager(5, null); |
|
11 |
for (int i = 0; i < 17; i++) { |
|
12 |
p.addEntry("Element" + i); |
|
13 |
} |
|
14 |
showPage(p, 0); |
|
15 |
showPage(p, 1); |
|
16 |
showPage(p, 2); |
|
17 |
showPage(p, 3); |
|
18 |
|
|
19 |
showSelectedPage(p); |
|
20 |
p.increaseSelectedPage(); |
|
21 |
showSelectedPage(p); |
|
22 |
p.increaseSelectedPage(); |
|
23 |
showSelectedPage(p); |
|
24 |
p.increaseSelectedPage(); |
|
25 |
showSelectedPage(p); |
|
26 |
p.increaseSelectedPage(); |
|
27 |
showSelectedPage(p); |
|
28 |
p.decreaseSelectedPage(); |
|
29 |
showSelectedPage(p); |
|
30 |
|
|
31 |
p.swapRow(2, 4); |
|
32 |
showPage(p, 0); |
|
33 |
p.swapRow(4, 2); |
|
34 |
showPage(p, 0); |
|
35 |
p.swapRow(0, 16); |
|
36 |
showPage(p, 0); |
|
37 |
showPage(p, 3); |
|
38 |
} |
|
39 |
|
|
40 |
private void showPage(Pager p, int n) { |
|
41 |
List<Object> l = p.getPage(n); |
|
42 |
for (int i = 0; i < l.size(); i++) { |
|
43 |
System.out.println((String)l.get(i)); |
|
44 |
} |
|
45 |
System.out.println("---------"); |
|
46 |
} |
|
47 |
|
|
48 |
private void showSelectedPage(Pager p) { |
|
49 |
List<Object> l = p.getSelectedPage(); |
|
50 |
for (int i = 0; i < l.size(); i++) { |
|
51 |
System.out.println((String)l.get(i)); |
|
52 |
} |
|
53 |
System.out.println("---------"); |
|
54 |
} |
|
55 |
|
|
56 |
public static void main(String[] args) { |
|
57 |
new TestPager(); |
|
58 |
} |
|
59 |
|
|
60 |
public void actionPerformed(ActionEvent e) { |
|
61 |
|
|
62 |
} |
|
63 |
} |
|
0 | 64 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/TestROIPanel.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
|
|
8 |
import org.gvsig.raster.swing.impl.roi.DefaultROIPanel; |
|
9 |
import org.gvsig.raster.swing.roi.ROIPanel; |
|
10 |
import org.gvsig.raster.swing.roi.ROIPanelDataModel; |
|
11 |
|
|
12 |
public class TestROIPanel implements ActionListener { |
|
13 |
private int w = 550; |
|
14 |
private int h = 300; |
|
15 |
private JFrame frame = new JFrame(); |
|
16 |
private ROIPanel desc = null; |
|
17 |
private ROIPanelDataModel model = null; |
|
18 |
|
|
19 |
public TestROIPanel() { |
|
20 |
model = new ROIPanelDataModel() { |
|
21 |
}; |
|
22 |
desc = new DefaultROIPanel(); |
|
23 |
frame.getContentPane().add(desc.getComponent()); |
|
24 |
frame.setSize(w, h); |
|
25 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
26 |
frame.setVisible(true); |
|
27 |
} |
|
28 |
|
|
29 |
public static void main(String[] args) { |
|
30 |
new TestROIPanel(); |
|
31 |
} |
|
32 |
|
|
33 |
public void actionPerformed(ActionEvent e) { |
|
34 |
|
|
35 |
} |
|
36 |
} |
|
0 | 37 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/TestCreateNewLayerPanel.java | ||
---|---|---|
1 |
import java.awt.event.ActionEvent; |
|
2 |
import java.awt.event.ActionListener; |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
|
|
8 |
import org.gvsig.raster.swing.impl.newlayer.CreateNewLayerPanelImpl; |
|
9 |
import org.gvsig.raster.swing.newlayer.FileNameManagement; |
|
10 |
|
|
11 |
public class TestCreateNewLayerPanel implements ActionListener { |
|
12 |
private int w = 550; |
|
13 |
private int h = 300; |
|
14 |
private JFrame frame = new JFrame(); |
|
15 |
private CreateNewLayerPanelImpl desc = null; |
|
16 |
|
|
17 |
public class FileNameManagementImpl implements FileNameManagement { |
|
18 |
|
|
19 |
public String getDefaultFilePath() { |
|
20 |
return System.getProperty("user.home"); |
|
21 |
} |
|
22 |
|
|
23 |
public List<String> getPrefixSupported() { |
|
24 |
List<String> list = new ArrayList<String>(); |
|
25 |
list.add("tif"); |
|
26 |
return list; |
|
27 |
} |
|
28 |
|
|
29 |
public String getUniqueLayerName() { |
|
30 |
return "Prueba"; |
|
31 |
} |
|
32 |
|
|
33 |
public void usesUniqueLayerName() { |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
public TestCreateNewLayerPanel() { |
|
39 |
desc = new CreateNewLayerPanelImpl(new FileNameManagementImpl()); |
|
40 |
frame.getContentPane().add(desc); |
|
41 |
frame.setSize(w, h); |
|
42 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
43 |
frame.setVisible(true); |
|
44 |
} |
|
45 |
|
|
46 |
public static void main(String[] args) { |
|
47 |
new TestCreateNewLayerPanel(); |
|
48 |
} |
|
49 |
|
|
50 |
public void actionPerformed(ActionEvent e) { |
|
51 |
|
|
52 |
} |
|
53 |
} |
|
0 | 54 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/test/java/TestInfoByPointPanel.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import javax.swing.JFrame; |
|
9 |
import javax.swing.JPanel; |
|
10 |
|
|
11 |
import org.gvsig.raster.swing.impl.tool.infobypoint.DefaultInfoByPointDataModel; |
|
12 |
import org.gvsig.raster.swing.impl.tool.infobypoint.MainInfoByPointPanelImpl; |
|
13 |
|
|
14 |
public class TestInfoByPointPanel implements ActionListener { |
|
15 |
private int w = 270; |
|
16 |
private int h = 434; |
|
17 |
private JFrame frame = new JFrame(); |
|
18 |
private MainInfoByPointPanelImpl desc = null; |
|
19 |
|
|
20 |
public TestInfoByPointPanel() { |
|
21 |
desc = new MainInfoByPointPanelImpl(null, null, new JPanel()); |
|
22 |
DefaultInfoByPointDataModel model = (DefaultInfoByPointDataModel)desc.getInfoByPointDataModel(); |
|
23 |
model.addObserver(desc); |
|
24 |
model.setARGB(255, 125, 110); |
|
25 |
model.setCMYK(new double[]{54, 254, 121, 190}); |
|
26 |
model.setHSL(234.3, 125.5, 110.3); |
|
27 |
model.setBandValues(new double[]{4.53, 2.24, 67.7, 67.87}); |
|
28 |
model.setNumberOfBands(4); |
|
29 |
model.setPixelPoint(100, 105); |
|
30 |
model.setViewPoint(305, 405); |
|
31 |
model.setWorldPoint(20554523.32, 19362125.23); |
|
32 |
List<String> list = new ArrayList<String>(); |
|
33 |
list.add("Esta_es_la_capa_numero_uno_de_la_lista_de_capas.jpg"); |
|
34 |
list.add("Esta_es_la_capa_segunda_de_la_lista_de_capas_del_info_by_point.jpg"); |
|
35 |
model.setLayerList(list); |
|
36 |
model.notifyObservers(); |
|
37 |
|
|
38 |
desc.addListenerExtendedButton(this); |
|
39 |
frame.getContentPane().add(desc); |
|
40 |
frame.setSize(w, h); |
|
41 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
42 |
frame.setVisible(true); |
|
43 |
} |
|
44 |
|
|
45 |
public static void main(String[] args) { |
|
46 |
new TestInfoByPointPanel(); |
|
47 |
} |
|
48 |
|
|
49 |
private boolean doubleSize = false; |
|
50 |
public void actionPerformed(ActionEvent e) { |
|
51 |
if(!doubleSize) |
|
52 |
frame.setSize(w * 2, h); |
|
53 |
else |
|
54 |
frame.setSize(w, h); |
|
55 |
doubleSize = !doubleSize; |
|
56 |
} |
|
57 |
|
|
58 |
// public void stateChanged(ChangeEvent e) { |
|
59 |
// if(e.getSource() == desc.getTabs()) { |
|
60 |
// if(desc.getTabs().getSelectedIndex() == 2) { |
|
61 |
// frame.setSize(w, 600); |
|
62 |
// } else { |
|
63 |
// frame.setSize(w, h); |
|
64 |
// } |
|
65 |
// } |
|
66 |
// } |
|
67 |
} |
|
0 | 68 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.swing.impl.RasterSwingImplLibrary |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/resources/org/gvsig/raster/swing/impl/i18n/text_en.properties | ||
---|---|---|
1 |
delete_roi_file=Removes all ROI from the layer. The vectorial file is not deleted, just the relation with the raster layer. |
|
2 |
cargar_rois=Load ROIs from shp file |
|
0 | 3 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/resources/org/gvsig/raster/swing/impl/i18n/text.properties | ||
---|---|---|
1 |
delete_roi_file=Elimina todas las ROI de la capa. El fichero vectorial no es borrado, solo su relaci?n con la capa r?ster. |
|
2 |
cargar_rois=Cargar ROIs de un fichero shp |
|
0 | 3 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/buttonbar/ButtonBarContainerImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.swing.impl.buttonbar; |
|
23 |
|
|
24 |
import java.awt.FlowLayout; |
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import javax.swing.JButton; |
|
28 |
import javax.swing.JPanel; |
|
29 |
|
|
30 |
import org.gvsig.andami.IconThemeHelper; |
|
31 |
import org.gvsig.raster.swing.buttonbar.ButtonBar; |
|
32 |
|
|
33 |
public class ButtonBarContainerImpl extends JPanel implements ButtonBar { |
|
34 |
private static final long serialVersionUID = -2556987128553063939L; |
|
35 |
|
|
36 |
private ArrayList<JButton> buttons = new ArrayList<JButton>(); |
|
37 |
|
|
38 |
private int wComp = 400; |
|
39 |
private int hComp = 26; |
|
40 |
private boolean disableAllControls = false; |
|
41 |
private boolean[] buttonsState = null; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* This is the default constructor |
|
46 |
*/ |
|
47 |
public ButtonBarContainerImpl() { |
|
48 |
super(); |
|
49 |
initialize(); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* This method initializes this |
|
54 |
* |
|
55 |
* @return void |
|
56 |
*/ |
|
57 |
private void initialize() { |
|
58 |
FlowLayout flowLayout = new FlowLayout(); |
|
59 |
flowLayout.setHgap(0); |
|
60 |
flowLayout.setVgap(0); |
|
61 |
this.setLayout(flowLayout); |
|
62 |
this.setSize(wComp, hComp); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* A?ade un boton al ArrayList de los botones. |
|
68 |
* |
|
69 |
* @param iconName: nombre del icono asignado al boton. La imagen tendr?a que |
|
70 |
* estar dentro de la carpeta "images/" |
|
71 |
* @param tip: tip del boton; |
|
72 |
* @param order: orden que ocupar? el boton dentro del control |
|
73 |
*/ |
|
74 |
public void addButton(String iconName, String tip, int order) { |
|
75 |
JButton bt = new JButton(); |
|
76 |
|
|
77 |
bt.setPreferredSize(new java.awt.Dimension(22, 22)); |
|
78 |
try{ |
|
79 |
if (iconName != null) |
|
80 |
bt.setIcon(IconThemeHelper.getImageIcon(iconName)); |
|
81 |
}catch(NullPointerException exc){ |
|
82 |
//El icono no existe -> No se a?ade ninguno |
|
83 |
} |
|
84 |
|
|
85 |
if(tip != null) |
|
86 |
bt.setToolTipText(tip); |
|
87 |
|
|
88 |
buttons.add(order, bt); |
|
89 |
addList(); |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Elimina el bot?n correspondiente al indice que le pasamos. |
|
95 |
* @param index |
|
96 |
*/ |
|
97 |
public void delButton(int index){ |
|
98 |
buttons.remove(index); |
|
99 |
this.removeAll(); |
|
100 |
addList(); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* A?ade en el panel los botones que tenemos en el ArrayList. |
|
105 |
* |
|
106 |
*/ |
|
107 |
public void addList(){ |
|
108 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
109 |
this.add((JButton)buttons.get(i)); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
/** |
|
115 |
* Esta funci?n deshabilita todos los controles y guarda sus valores |
|
116 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue |
|
117 |
* se vuelvan a quedar como estaba |
|
118 |
*/ |
|
119 |
public void disableAllControls(){ |
|
120 |
if(!disableAllControls){ |
|
121 |
disableAllControls = true; |
|
122 |
|
|
123 |
buttonsState = new boolean[buttons.size()]; |
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
for (int i = 0 ; i < buttons.size() ; i++){ |
|
128 |
|
|
129 |
//Salvamos los estados |
|
130 |
buttonsState[i] = ((JButton)buttons.get(i)).isEnabled(); |
|
131 |
//Desactivamos controles |
|
132 |
((JButton)buttons.get(i)).setEnabled(false); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n |
|
139 |
* disableAllControls |
|
140 |
*/ |
|
141 |
public void restoreControlsValue(){ |
|
142 |
if(disableAllControls){ |
|
143 |
disableAllControls = false; |
|
144 |
|
|
145 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
146 |
((JButton)buttons.get(i)).setEnabled(buttonsState[i]); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* M?todo para acceder a los botones del control; |
|
153 |
* @param index |
|
154 |
* @return |
|
155 |
*/ |
|
156 |
public JButton getButton(int index){ |
|
157 |
return (JButton)buttons.get(index); |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* M?todo para establecer la posici?n de los botones dentro del control. |
|
162 |
* @param align: "left" o "right" |
|
163 |
*/ |
|
164 |
public void setButtonAlignment(String align){ |
|
165 |
FlowLayout layout = new FlowLayout(); |
|
166 |
layout.setHgap(2); |
|
167 |
layout.setVgap(0); |
|
168 |
|
|
169 |
if (align.equals("right")) |
|
170 |
layout.setAlignment(FlowLayout.RIGHT); |
|
171 |
else |
|
172 |
layout.setAlignment(FlowLayout.LEFT); |
|
173 |
|
|
174 |
this.setLayout(layout); |
|
175 |
} |
|
176 |
|
|
177 |
public void setComponentBorder(boolean br){ |
|
178 |
if(br) |
|
179 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
180 |
if(!br) |
|
181 |
this.setBorder(javax.swing.BorderFactory.createEmptyBorder()); |
|
182 |
} |
|
183 |
|
|
184 |
} |
|
0 | 185 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/openfile/OpenFileContainerImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.swing.impl.openfile; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.io.File; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import javax.swing.ImageIcon; |
|
31 |
import javax.swing.JButton; |
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.JTextField; |
|
34 |
|
|
35 |
import org.gvsig.andami.IconThemeHelper; |
|
36 |
import org.gvsig.gui.beans.Messages; |
|
37 |
import org.gvsig.raster.swing.openfile.OpenFileContainer; |
|
38 |
|
|
39 |
/** |
|
40 |
* Implementation of a open file panel |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class OpenFileContainerImpl extends JPanel implements OpenFileContainer { |
|
44 |
private static final long serialVersionUID = 5823371652872582451L; |
|
45 |
|
|
46 |
private JButton jButton = null; |
|
47 |
private JTextField tOpen = null; |
|
48 |
private OpenFileListener listener = null; |
|
49 |
private boolean showBorder = true; |
|
50 |
|
|
51 |
private boolean isButtonVisible = true; |
|
52 |
|
|
53 |
public OpenFileContainerImpl(boolean showBorder, String[] fileFilter, String defaultPath) { |
|
54 |
this.showBorder = showBorder; |
|
55 |
listener = new OpenFileListener(this, fileFilter, defaultPath); |
|
56 |
initialize(); |
|
57 |
listener.setButton(this.getJButton()); |
|
58 |
} |
|
59 |
|
|
60 |
public OpenFileContainerImpl(boolean showBorder, List<String> fileFilter, String defaultPath) { |
|
61 |
this(showBorder, (String[])fileFilter.toArray(new String[0]), defaultPath); |
|
62 |
listener.setButton(this.getJButton()); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* This method initializes this |
|
67 |
* |
|
68 |
*/ |
|
69 |
private void initialize() { |
|
70 |
this.setLayout(new GridBagLayout()); |
|
71 |
if(showBorder) |
|
72 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("open_file"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
73 |
|
|
74 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
75 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
76 |
gridBagConstraints1.weightx = 1; |
|
77 |
gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 0); |
|
78 |
|
|
79 |
this.add(getTOpen(), gridBagConstraints1); |
|
80 |
|
|
81 |
gridBagConstraints1.gridx = 1; |
|
82 |
gridBagConstraints1.weightx = 0; |
|
83 |
|
|
84 |
this.add(getJButton(), gridBagConstraints1); |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* This method initializes jButton |
|
90 |
* |
|
91 |
* @return javax.swing.JButton |
|
92 |
*/ |
|
93 |
private JButton getJButton() { |
|
94 |
if (jButton == null) { |
|
95 |
ImageIcon icon = null; |
|
96 |
try { |
|
97 |
icon = IconThemeHelper.getImageIcon("icon-folder-open"); |
|
98 |
} catch (Exception e) { |
|
99 |
} |
|
100 |
if(icon == null || icon.getIconWidth() <= 0 || icon.getIconHeight() <= 0) |
|
101 |
icon = new ImageIcon(System.getProperty("user.dir") + "/src/main/resources/images/icon-folder-open.gif", ""); |
|
102 |
|
|
103 |
jButton = new JButton(icon); |
|
104 |
jButton.setPreferredSize(new Dimension(22, 22)); |
|
105 |
jButton.addActionListener(listener); |
|
106 |
jButton.setVisible(isButtonVisible); |
|
107 |
getTOpen().setEnabled(isButtonVisible); |
|
108 |
} |
|
109 |
return jButton; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* This method initializes jTextField |
|
114 |
* |
|
115 |
* @return javax.swing.JTextField |
|
116 |
*/ |
|
117 |
public JTextField getTOpen() { |
|
118 |
if (tOpen == null) { |
|
119 |
tOpen = new JTextField(); |
|
120 |
tOpen.setPreferredSize(new Dimension(0, 22)); |
|
121 |
} |
|
122 |
return tOpen; |
|
123 |
} |
|
124 |
|
|
125 |
/* |
|
126 |
* (non-Javadoc) |
|
127 |
* @see org.gvsig.raster.swing.openfile.OpenFileContainer#setPath(java.lang.String) |
|
128 |
*/ |
|
129 |
public void setPath(String path) { |
|
130 |
getTOpen().setText(path); |
|
131 |
} |
|
132 |
|
|
133 |
|
|
134 |
/** |
|
135 |
* Devuelve el file cuya ruta corresponde con el campo de texto. |
|
136 |
* @return |
|
137 |
*/ |
|
138 |
public File getFile() { |
|
139 |
File fil = null; |
|
140 |
if(this.getTOpen().getText() != "") { |
|
141 |
try { |
|
142 |
fil = new File(this.getTOpen().getText()); |
|
143 |
} catch(Exception exc) { |
|
144 |
System.err.println("Ruta o archivo no v?lido"); |
|
145 |
} |
|
146 |
} |
|
147 |
return fil; |
|
148 |
} |
|
149 |
|
|
150 |
public void setEnabled(boolean enabled) { |
|
151 |
getTOpen().setEnabled(enabled); |
|
152 |
getJButton().setEnabled(enabled); |
|
153 |
} |
|
154 |
|
|
155 |
} |
|
0 | 156 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/openfile/OpenFileListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.swing.impl.openfile; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.io.File; |
|
27 |
|
|
28 |
import javax.swing.JButton; |
|
29 |
import javax.swing.JFileChooser; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class OpenFileListener implements ActionListener { |
|
35 |
private JButton button = null; |
|
36 |
private String fName = null; |
|
37 |
private OpenFileContainerImpl controlPanel = null; |
|
38 |
private String[] fileFilter = null; |
|
39 |
private String lastDirectory = null; |
|
40 |
|
|
41 |
public OpenFileListener(OpenFileContainerImpl panel, String[] fileFilter, String lastDirectory) { |
|
42 |
this.controlPanel = panel; |
|
43 |
this.fileFilter = fileFilter; |
|
44 |
this.lastDirectory = lastDirectory; |
|
45 |
} |
|
46 |
|
|
47 |
public void setButton(JButton but) { |
|
48 |
this.button = but; |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
public void actionPerformed(ActionEvent e) { |
|
53 |
if(e.getSource() == this.button) { |
|
54 |
JFileChooser file = new JFileChooser(); |
|
55 |
//file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
|
56 |
file.setDialogTitle("Select File"); |
|
57 |
if(lastDirectory != null) { |
|
58 |
File lastDir = new File(lastDirectory); |
|
59 |
if(lastDir.isDirectory() && lastDir.exists()) { |
|
60 |
file.setCurrentDirectory(lastDir); |
|
61 |
} |
|
62 |
if(!lastDir.isDirectory()) { |
|
63 |
lastDir = new File(lastDir.getParent()); |
|
64 |
if(lastDir.exists()) |
|
65 |
file.setCurrentDirectory(lastDir); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
if(fileFilter != null) { |
|
70 |
for (int i = 0; i < fileFilter.length; i++) { |
|
71 |
file.addChoosableFileFilter(new ReadFilter(file, fileFilter[i])); |
|
72 |
} |
|
73 |
int returnVal = file.showOpenDialog(controlPanel); |
|
74 |
if(returnVal == JFileChooser.APPROVE_OPTION) { |
|
75 |
lastDirectory = file.getSelectedFile().getAbsolutePath(); |
|
76 |
fName = file.getSelectedFile().toString(); |
|
77 |
controlPanel.getTOpen().setText(fName); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
83 |
|
|
84 |
public String getFileName(){ |
|
85 |
return fName; |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
class ReadFilter extends javax.swing.filechooser.FileFilter{ |
|
90 |
|
|
91 |
JFileChooser chooser = null; |
|
92 |
String filter = null; |
|
93 |
|
|
94 |
public ReadFilter(JFileChooser cho,String fil){ |
|
95 |
this.chooser = cho; |
|
96 |
this.filter = fil; |
|
97 |
} |
|
98 |
|
|
99 |
public boolean accept(File f) { |
|
100 |
return f.isDirectory() || f.getName().toLowerCase().endsWith("."+filter); |
|
101 |
} |
|
102 |
|
|
103 |
public String getDescription() { |
|
104 |
return "."+filter; |
|
105 |
} |
|
106 |
|
|
107 |
} |
|
0 | 108 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.53/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/openfile/FileTextField.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.swing.impl.openfile; |
|
23 |
|
|
24 |
import java.awt.GridBagConstraints; |
|
25 |
import java.awt.GridBagLayout; |
|
26 |
import java.awt.Insets; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.awt.event.FocusEvent; |
|
30 |
import java.awt.event.FocusListener; |
|
31 |
import java.io.File; |
|
32 |
|
|
33 |
import javax.swing.JButton; |
|
34 |
import javax.swing.JPanel; |
|
35 |
import javax.swing.JTextField; |
|
36 |
|
|
37 |
import org.gvsig.gui.beans.Messages; |
|
38 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
39 |
import org.gvsig.raster.swing.openfile.FileFilter; |
|
40 |
|
|
41 |
public class FileTextField extends JPanel { |
|
42 |
private static final long serialVersionUID = 1L; |
|
43 |
private JTextField tf_fileName = null; |
|
44 |
private JButton bt_chooseFile = null; |
|
45 |
private File selectedFile = null; |
|
46 |
private JFileChooser jfc; |
|
47 |
/** |
|
48 |
* Used to create file choosers with 'memory' |
|
49 |
*/ |
|
50 |
private String JFC_ID = null; |
|
51 |
|
|
52 |
public static final int ACTION_EVENT_FIELD_DISABLED = 0; |
|
53 |
public static final int ACTION_EVENT_FIELD_ENABLED = 1; |
|
54 |
public static final int ACTION_EVENT_VALUE_CHANGED = 1; |
|
55 |
|
|
56 |
public FileTextField() { |
|
57 |
super(); |
|
58 |
JFC_ID = this.getClass().getName(); |
|
59 |
initializeUI(); |
|
60 |
} |
|
61 |
|
|
62 |
public FileTextField(String id) { |
|
63 |
super(); |
|
64 |
JFC_ID = id; |
|
65 |
initializeUI(); |
|
66 |
} |
|
67 |
|
|
68 |
private void initializeUI() { |
|
69 |
jfc = new JFileChooser(JFC_ID, (String) null); |
|
70 |
setLayout(new GridBagLayout()); |
|
71 |
|
|
72 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
73 |
constraints.gridx = 0; |
|
74 |
constraints.gridy = 0; |
|
75 |
constraints.gridwidth = 1; |
|
76 |
constraints.gridheight = 1; |
Also available in: Unified diff