Revision 33964
tags/v2_0_0_Build_2020/libraries/libUIComponent/.cvsignore | ||
---|---|---|
1 |
bin |
|
2 |
bin-test |
|
0 | 3 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/controls/dnd/JDnDTableTest.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.2 2007-08-21 09:58:04 bsanchez |
|
47 |
* - Quitados imports innecesarios |
|
48 |
* - Quitado codigo no usado |
|
49 |
* - Cambio de deprecated show por setVisible(true) |
|
50 |
* |
|
51 |
* Revision 1.1 2007/08/20 08:34:46 evercher |
|
52 |
* He fusionado LibUI con LibUIComponents |
|
53 |
* |
|
54 |
* Revision 1.1 2006/09/27 13:34:57 jaume |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
package controls.dnd; |
|
60 |
|
|
61 |
import java.awt.Dimension; |
|
62 |
|
|
63 |
import javax.swing.JFrame; |
|
64 |
import javax.swing.JPanel; |
|
65 |
|
|
66 |
import org.gvsig.gui.beans.TestUI; |
|
67 |
import org.gvsig.gui.beans.controls.dnd.JDnDList; |
|
68 |
import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
|
69 |
import org.gvsig.gui.beans.controls.dnd.JDnDTable; |
|
70 |
import org.gvsig.gui.beans.controls.dnd.JDnDTableModel; |
|
71 |
/** |
|
72 |
* El model que ha de suportar les funcions d'una JDnDTable. Encara est? en |
|
73 |
* proves. |
|
74 |
* |
|
75 |
* @author jaume |
|
76 |
*/ |
|
77 |
public class JDnDTableTest { |
|
78 |
static String[] colNames = new String[] {"1234", "abcd", "qwerty"}; |
|
79 |
static String[][] values = new String[][] {new String[] {"a1", "a2", "a3"}, |
|
80 |
new String[] {"b1", "b2", "b3"}, |
|
81 |
new String[] {"c1", "c2", "c3"}}; |
|
82 |
|
|
83 |
public static void main(String args[]) { |
|
84 |
JFrame f = new TestUI("JDnDTableTest"); |
|
85 |
JPanel content = new JPanel(); |
|
86 |
content.setPreferredSize(new Dimension(500,400)); |
|
87 |
|
|
88 |
JDnDTableModel model = new JDnDTableModel(values, colNames); |
|
89 |
JDnDListModel listModel = new JDnDListModel(); |
|
90 |
listModel.addElement("a"); |
|
91 |
listModel.addElement("b"); |
|
92 |
listModel.addElement("c"); |
|
93 |
|
|
94 |
JDnDTable tbl = new JDnDTable(); |
|
95 |
|
|
96 |
tbl.setModel(model); |
|
97 |
tbl.setSize(new Dimension(450, 350)); |
|
98 |
JDnDList list = new JDnDList(); |
|
99 |
list.setModel(listModel); |
|
100 |
content.add(tbl); |
|
101 |
content.add(list); |
|
102 |
f.setContentPane(content); |
|
103 |
f.pack(); |
|
104 |
f.setVisible(true); |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/progresspanel/TestProgressPanel.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.progresspanel; |
|
2 |
|
|
3 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
4 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
|
5 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
6 |
|
|
7 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
8 |
* |
|
9 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
10 |
* of the Valencian Government (CIT) |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
25 |
* MA 02110-1301, USA. |
|
26 |
* |
|
27 |
*/ |
|
28 |
|
|
29 |
/** |
|
30 |
* <code>TestProgressPanel</code>. Test para comprobar el funcionamiento del |
|
31 |
* objeto <code>TestProgressPanel</code> |
|
32 |
* |
|
33 |
* @version 20/03/2007 |
|
34 |
* @author BorSanZa - Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
35 |
*/ |
|
36 |
public class TestProgressPanel { |
|
37 |
|
|
38 |
private tryPanel frame = null; |
|
39 |
|
|
40 |
public class tryPanel implements Runnable, ButtonsPanelListener { |
|
41 |
private ProgressPanel frame = new ProgressPanel(); |
|
42 |
private volatile Thread blinker; |
|
43 |
|
|
44 |
public void showWindow() { |
|
45 |
frame.getButtonsPanel().getButton(ButtonsPanel.BUTTON_PAUSE).setVisible(false); |
|
46 |
frame.setTitle("Actualizando datos"); |
|
47 |
frame.showLog(false); |
|
48 |
frame.getButtonsPanel().addButtonPressedListener(this); |
|
49 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
50 |
frame.setVisible(true); |
|
51 |
} |
|
52 |
|
|
53 |
private boolean threadSuspended = false; |
|
54 |
|
|
55 |
public void start() { |
|
56 |
blinker = new Thread(this); |
|
57 |
blinker.start(); |
|
58 |
} |
|
59 |
|
|
60 |
public synchronized void stop() { |
|
61 |
blinker = null; |
|
62 |
notify(); |
|
63 |
} |
|
64 |
|
|
65 |
public void run() { |
|
66 |
Thread thisThread = Thread.currentThread(); |
|
67 |
int i = 0; |
|
68 |
frame.addLineLog("Realizando testeo..."); |
|
69 |
while ((blinker == thisThread) && (i < 1000)) { |
|
70 |
try { |
|
71 |
Thread.sleep(1); |
|
72 |
|
|
73 |
synchronized(this) { |
|
74 |
while (threadSuspended && blinker==thisThread) |
|
75 |
wait(); |
|
76 |
} |
|
77 |
} catch (InterruptedException e) { |
|
78 |
} |
|
79 |
|
|
80 |
if (i==0) |
|
81 |
frame.addLineLog("Testeo 1 completado al 0%"); |
|
82 |
if ((i>=0) && (i<=100)) |
|
83 |
frame.replaceLastLineLog("Testeo 1 completado al " + i + "%"); |
|
84 |
if (i==100) { |
|
85 |
frame.replaceLastLineLog("Testeo 1 completado"); |
|
86 |
frame.addLineLog("Testeo 2 completado al 0%"); |
|
87 |
} |
|
88 |
if ((i>=100) && (i<=800)) |
|
89 |
frame.replaceLastLineLog("Testeo 2 completado al " + (int)((i-100)*100)/700 + "%"); |
|
90 |
if (i==800) { |
|
91 |
frame.replaceLastLineLog("Testeo 2 completado"); |
|
92 |
frame.addLineLog("Testeo 3 completado al 0%"); |
|
93 |
} |
|
94 |
if ((i>=800) && (i<=1000)) |
|
95 |
frame.replaceLastLineLog("Testeo 3 completado al " + (int)((i-800)*100)/200 + "%"); |
|
96 |
i++; |
|
97 |
|
|
98 |
frame.setPercent((int) (i*100)/1000); |
|
99 |
} |
|
100 |
// Cerramos la ventana |
|
101 |
frame.setVisible(false); |
|
102 |
frame = null; |
|
103 |
} |
|
104 |
|
|
105 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
106 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) { |
|
107 |
this.stop(); |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
public static void main(String[] args) { |
|
113 |
new TestProgressPanel(); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* This is the default constructor |
|
118 |
*/ |
|
119 |
public TestProgressPanel() { |
|
120 |
super(); |
|
121 |
initialize(); |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* This method initializes this |
|
126 |
* |
|
127 |
* @return void |
|
128 |
*/ |
|
129 |
private void initialize() { |
|
130 |
frame = new tryPanel(); |
|
131 |
frame.showWindow(); |
|
132 |
frame.start(); |
|
133 |
} |
|
134 |
} |
|
0 | 135 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/progresspanel/Test2ProgressPanel.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.progresspanel; |
|
2 |
|
|
3 |
import java.awt.event.ComponentAdapter; |
|
4 |
import java.awt.event.ComponentEvent; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
import org.gvsig.gui.beans.Messages; |
|
8 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
9 |
|
|
10 |
|
|
11 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
12 |
* |
|
13 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
14 |
* of the Valencian Government (CIT) |
|
15 |
* |
|
16 |
* This program is free software; you can redistribute it and/or |
|
17 |
* modify it under the terms of the GNU General Public License |
|
18 |
* as published by the Free Software Foundation; either version 2 |
|
19 |
* of the License, or (at your option) any later version. |
|
20 |
* |
|
21 |
* This program is distributed in the hope that it will be useful, |
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24 |
* GNU General Public License for more details. |
|
25 |
* |
|
26 |
* You should have received a copy of the GNU General Public License |
|
27 |
* along with this program; if not, write to the Free Software |
|
28 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
29 |
* MA 02110-1301, USA. |
|
30 |
* |
|
31 |
*/ |
|
32 |
|
|
33 |
/** |
|
34 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
35 |
*/ |
|
36 |
public class Test2ProgressPanel { |
|
37 |
|
|
38 |
public static void main(String[] args) { |
|
39 |
SampleProcess iprocess = new SampleProcess("Proceso de ejemplo", |
|
40 |
Messages.getText("Ongoing_process_please_wait")); |
|
41 |
|
|
42 |
IncrementableTask iTask = new IncrementableTask(iprocess, new ProgressPanel(false)); |
|
43 |
iTask.addIncrementableListener(iprocess); |
|
44 |
iprocess.setIncrementableTask(iTask); |
|
45 |
|
|
46 |
final SampleProcess f_iprocess = iprocess; |
|
47 |
final IncrementableTask f_iTask = iTask; |
|
48 |
|
|
49 |
iTask.getProgressPanel().addComponentListener(new ComponentAdapter() { |
|
50 |
/* |
|
51 |
* (non-Javadoc) |
|
52 |
* @see java.awt.event.ComponentAdapter#componentHidden(java.awt.event.ComponentEvent) |
|
53 |
*/ |
|
54 |
public void componentHidden(ComponentEvent e) { |
|
55 |
f_iTask.getProgressPanel().dispose(); |
|
56 |
|
|
57 |
/* Writes in the gvSIG log the results of the process */ |
|
58 |
String text = "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" + |
|
59 |
"Resumen del proceso:\n" + |
|
60 |
f_iprocess.getLog() + |
|
61 |
"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"; |
|
62 |
Logger.getLogger(getClass().getName()).debug(text); |
|
63 |
} |
|
64 |
}); |
|
65 |
|
|
66 |
/* Starts the process */ |
|
67 |
iprocess.start(); |
|
68 |
iTask.start(); |
|
69 |
} |
|
70 |
} |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/progresspanel/SampleProcess.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.progresspanel; |
|
2 |
|
|
3 |
import org.gvsig.gui.beans.Messages; |
|
4 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
5 |
import org.gvsig.gui.beans.incrementabletask.IncrementableProcess; |
|
6 |
|
|
7 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
8 |
* |
|
9 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
10 |
* of the Valencian Government (CIT) |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
25 |
* MA 02110-1301, USA. |
|
26 |
* |
|
27 |
*/ |
|
28 |
|
|
29 |
/** |
|
30 |
* Process that adds a layer with derivative geometries, according the configuration. |
|
31 |
* |
|
32 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
33 |
*/ |
|
34 |
public class SampleProcess extends IncrementableProcess { |
|
35 |
public SampleProcess(String title, String label) { |
|
36 |
super(title); |
|
37 |
|
|
38 |
this.label = label; |
|
39 |
this.isPausable = true; |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Sample process. |
|
44 |
* <br> |
|
45 |
* "cancelProcess" is a shared object that, if you want allow to cancel the process, |
|
46 |
* you should read it once in a while and check if it's canceled, if true, throw an InterrupedException |
|
47 |
* |
|
48 |
* @throws InterruptedException if fails the process |
|
49 |
*/ |
|
50 |
public void process() throws InterruptedException { |
|
51 |
try { |
|
52 |
percentage = 0; |
|
53 |
|
|
54 |
for (int i = 1; i <= 20; i++) { |
|
55 |
percentage = i * 5; |
|
56 |
|
|
57 |
if (cancelProcess.isCanceled()) { |
|
58 |
throw new InterruptedException(); |
|
59 |
} |
|
60 |
|
|
61 |
log.addLine("Paso: " + i); |
|
62 |
Thread.sleep(1000); |
|
63 |
} |
|
64 |
|
|
65 |
percentage = 100; |
|
66 |
log.addLine(Messages.getText("Process_finished_successfully")); |
|
67 |
return; |
|
68 |
} |
|
69 |
catch (Exception ex) { |
|
70 |
if (! cancelProcess.isCanceled()) { |
|
71 |
// Next line must be uncommented |
|
72 |
//NotificationManager.showMessageError(Messages.getText("Failed_the_process"), ex); |
|
73 |
log.addLine(Messages.getText("Failed_the_process")); |
|
74 |
} |
|
75 |
|
|
76 |
/* CANCELLATION PROCESS */ |
|
77 |
|
|
78 |
// Must restore the changes |
|
79 |
//.... |
|
80 |
|
|
81 |
throw new InterruptedException(); |
|
82 |
} |
|
83 |
finally { |
|
84 |
/* Summary of the process */ |
|
85 |
log.addLine(" Proceso de ejemplo con barra de progreso durante 20 segundos"); |
|
86 |
|
|
87 |
// Ends the progress panel |
|
88 |
iTask.getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).doClick(); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/labelslidertext/TestLabelSliderTextTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.labelslidertext; |
|
20 |
|
|
21 |
import javax.swing.JFrame; |
|
22 |
|
|
23 |
public class TestLabelSliderTextTable { |
|
24 |
private int w = 375; |
|
25 |
private int h = 150; |
|
26 |
private JFrame frame = new JFrame(); |
|
27 |
private LabelSliderTextContainer slider = null; |
|
28 |
|
|
29 |
public TestLabelSliderTextTable() { |
|
30 |
slider = new LabelSliderTextContainer(0, 255, 255, true, "Longaniza de nombre"); |
|
31 |
slider.setDecimal(false); |
|
32 |
slider.setBorder("Cabecera"); |
|
33 |
frame.getContentPane().add(slider); |
|
34 |
frame.setSize(w, h); |
|
35 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
36 |
frame.setVisible(true); |
|
37 |
} |
|
38 |
|
|
39 |
public static void main(String[] args) { |
|
40 |
new TestLabelSliderTextTable(); |
|
41 |
} |
|
42 |
} |
|
0 | 43 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/table/TestTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.table; |
|
20 |
|
|
21 |
import org.gvsig.gui.beans.TestUI; |
|
22 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
23 |
/** |
|
24 |
* Test para la clase Table |
|
25 |
* @version 30/10/2007 |
|
26 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
27 |
*/ |
|
28 |
public class TestTable extends TestUI { |
|
29 |
private static final long serialVersionUID = -1071011269441792511L; |
|
30 |
private TableContainer table = null; |
|
31 |
|
|
32 |
public TestTable() throws NotInitializeException { |
|
33 |
super("TestTable"); |
|
34 |
String[] columnNames = {"columna 1", "columna 2", "columna 3", "columna 4"}; |
|
35 |
int[] columnWidths = {70, 90, 110, 130}; |
|
36 |
table = new TableContainer(columnNames, columnWidths); |
|
37 |
table.initialize(); |
|
38 |
table.setControlVisible(true); |
|
39 |
table.setMoveRowsButtonsVisible(true); |
|
40 |
table.setEditable(true); |
|
41 |
|
|
42 |
String row[] = {"", "", "", ""}; |
|
43 |
for (int i = 0; i < 10; i++) { |
|
44 |
row[0] = String.valueOf(i); |
|
45 |
row[1] = String.valueOf(i); |
|
46 |
row[2] = String.valueOf(i); |
|
47 |
row[3] = String.valueOf(i); |
|
48 |
table.addRow(row); |
|
49 |
} |
|
50 |
|
|
51 |
table.swapRow(5, 6); |
|
52 |
table.delRow(3); |
|
53 |
|
|
54 |
getContentPane().add(table); |
|
55 |
setSize(400, 300); |
|
56 |
setVisible(true); |
|
57 |
} |
|
58 |
|
|
59 |
public static void main(String[] args) { |
|
60 |
try { |
|
61 |
new TestTable(); |
|
62 |
} catch (NotInitializeException ex){ |
|
63 |
System.out.println("Tabla no inicializada"); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
0 | 67 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/table/TestTableButtonModelTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.table; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
import java.awt.event.ActionEvent; |
|
23 |
import java.awt.event.ActionListener; |
|
24 |
|
|
25 |
import org.gvsig.gui.beans.TestUI; |
|
26 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
27 |
|
|
28 |
public class TestTableButtonModelTable implements ActionListener { |
|
29 |
private int w = 460; |
|
30 |
private int h = 200; |
|
31 |
private TestUI frame = new TestUI("TestTableButtonModelTable"); |
|
32 |
private TableContainer table = null; |
|
33 |
|
|
34 |
public TestTableButtonModelTable() throws NotInitializeException { |
|
35 |
String[] columnNames = { "Bot?n", "columna2", "columna3", "columna 4", "col5" }; |
|
36 |
int[] columnWidths = { 54, 114, 94, 114, 60 }; |
|
37 |
table = new TableContainer(columnNames, columnWidths); |
|
38 |
table.setModel("TableButtonModel"); |
|
39 |
table.initialize(); |
|
40 |
|
|
41 |
Object[] row = { Color.GREEN, "texto 0", "texto 0", "texto 0", "125" }; |
|
42 |
Object[] row1 = { Color.BLUE, "texto 1", "texto 1", "texto 1", "255" }; |
|
43 |
Object[] row2 = { Color.RED, "texto 2", "texto 2", "texto 2", "80" }; |
|
44 |
table.addRow(row); |
|
45 |
|
|
46 |
/*JButton b7 = new JButton(); |
|
47 |
b7.setBackground(Color.RED); |
|
48 |
b7.addActionListener(this); |
|
49 |
((TableButtonModel)table.getModel()).setValueAt(b7, 0, 0);*/ |
|
50 |
table.addRow(row1); |
|
51 |
table.addRow(row2); |
|
52 |
|
|
53 |
frame.getContentPane().add(table); |
|
54 |
frame.setSize(w, h); |
|
55 |
frame.setVisible(true); |
|
56 |
} |
|
57 |
|
|
58 |
public static void main(String[] args) { |
|
59 |
try { |
|
60 |
new TestTableButtonModelTable(); |
|
61 |
} catch(NotInitializeException ex){ |
|
62 |
System.out.println("Tabla no inicializada"); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
public void actionPerformed(ActionEvent e) { |
|
67 |
System.out.println("Evento de bot?n!!"); |
|
68 |
} |
|
69 |
} |
|
0 | 70 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/table/TestTableColorTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.table; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
import java.awt.event.ActionEvent; |
|
23 |
import java.awt.event.ActionListener; |
|
24 |
|
|
25 |
import org.gvsig.gui.beans.TestUI; |
|
26 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
27 |
/** |
|
28 |
* Test del TableContainer |
|
29 |
* |
|
30 |
* @version 27/05/2007 |
|
31 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
32 |
*/ |
|
33 |
public class TestTableColorTable implements ActionListener { |
|
34 |
private int w = 460; |
|
35 |
private int h = 200; |
|
36 |
private TestUI frame = new TestUI("TestTableColorTable"); |
|
37 |
private TableContainer table = null; |
|
38 |
|
|
39 |
public TestTableColorTable() throws NotInitializeException { |
|
40 |
String[] columnNames = { "selec", "clase", "RGB", "Valor", "Max", "Alpha" }; |
|
41 |
int[] columnWidths = { 54, 1104, 94, 114, 114, 60 }; |
|
42 |
table = new TableContainer(columnNames, columnWidths); |
|
43 |
table.setModel("TableColorModel"); |
|
44 |
table.initialize(); |
|
45 |
|
|
46 |
Object[] row = { Color.GREEN, "", "0,255,0", new Double(2), new Double(2), "255" }; |
|
47 |
Object[] row1 = { Color.BLUE, "", "0,0,255", new Double(1), new Double(2), "255" }; |
|
48 |
Object[] row2 = { Color.RED , "", "255,0,0", new Double(0), new Double(1), "255" }; |
|
49 |
table.addRow(row); |
|
50 |
|
|
51 |
table.addRow(row1); |
|
52 |
table.addRow(row2); |
|
53 |
|
|
54 |
frame.getContentPane().add(table); |
|
55 |
frame.setSize(w, h); |
|
56 |
frame.setVisible(true); |
|
57 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
58 |
} |
|
59 |
|
|
60 |
public static void main(String[] args) { |
|
61 |
try { |
|
62 |
new TestTableColorTable(); |
|
63 |
} catch(NotInitializeException ex){ |
|
64 |
System.out.println("Tabla no inicializada"); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public void actionPerformed(ActionEvent e) { |
|
69 |
System.out.println("Evento de bot?n!!"); |
|
70 |
} |
|
71 |
} |
|
0 | 72 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/table/CheckBoxModelTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.table; |
|
20 |
|
|
21 |
import javax.swing.event.TableModelEvent; |
|
22 |
import javax.swing.event.TableModelListener; |
|
23 |
|
|
24 |
import org.gvsig.gui.beans.TestUI; |
|
25 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
26 |
|
|
27 |
public class CheckBoxModelTable extends TestUI implements TableModelListener { |
|
28 |
private static final long serialVersionUID = -7971006561681605303L; |
|
29 |
private int w = 400; |
|
30 |
private int h = 200; |
|
31 |
private TableContainer table = null; |
|
32 |
|
|
33 |
public CheckBoxModelTable() throws NotInitializeException { |
|
34 |
super("CheckBoxModelTable"); |
|
35 |
String[] columnNames = {" ", "Nombre", ""}; |
|
36 |
int[] columnWidths = {22, 334, 0}; |
|
37 |
table = new TableContainer(columnNames, columnWidths); |
|
38 |
table.setModel("CheckBoxModel"); |
|
39 |
table.initialize(); |
|
40 |
table.setControlVisible(false); |
|
41 |
table.setMoveRowsButtonsVisible(true); |
|
42 |
|
|
43 |
Object row[] = {"", "", ""}; |
|
44 |
for (int i = 0; i < 10; i++) { |
|
45 |
row[0] = new Boolean(true); |
|
46 |
row[1] = String.valueOf(i); |
|
47 |
row[2] = new Integer(i); |
|
48 |
table.addRow(row); |
|
49 |
} |
|
50 |
|
|
51 |
table.delRow(1); |
|
52 |
table.getTable().getJTable().getColumnModel().getColumn(2).setMinWidth(0); |
|
53 |
table.getTable().getJTable().getColumnModel().getColumn(2).setMaxWidth(0); |
|
54 |
table.getTable().getJTable().getColumnModel().getColumn(0).setMinWidth(22); |
|
55 |
table.getTable().getJTable().getColumnModel().getColumn(0).setMaxWidth(22); |
|
56 |
|
|
57 |
table.getModel().addTableModelListener(this); |
|
58 |
getContentPane().add(table); |
|
59 |
setSize(w, h); |
|
60 |
setVisible(true); |
|
61 |
} |
|
62 |
|
|
63 |
public static void main(String[] args) { |
|
64 |
try { |
|
65 |
new CheckBoxModelTable(); |
|
66 |
} catch (NotInitializeException ex) { |
|
67 |
System.out.println("Tabla no inicializada"); |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
public void tableChanged(TableModelEvent e) { |
|
72 |
System.out.println("Ha cambiado"); |
|
73 |
} |
|
74 |
} |
|
0 | 75 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/table/TestTreeRadioButtonModelTable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.table; |
|
20 |
|
|
21 |
import org.gvsig.gui.beans.TestUI; |
|
22 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
23 |
|
|
24 |
public class TestTreeRadioButtonModelTable { |
|
25 |
private int w = 400; |
|
26 |
private int h = 200; |
|
27 |
private TestUI frame = new TestUI("TestTreeRadioButtonModelTable"); |
|
28 |
private TableContainer table = null; |
|
29 |
|
|
30 |
public TestTreeRadioButtonModelTable() throws NotInitializeException { |
|
31 |
String[] columnNames = { "A", "R", "G", "B", "Capa" }; |
|
32 |
int[] columnWidths = { 22, 22, 22, 22, 334 }; |
|
33 |
table = new TableContainer(columnNames, columnWidths); |
|
34 |
table.setModel("ARGBBandSelectorModel"); |
|
35 |
table.initialize(); |
|
36 |
|
|
37 |
Object[] row = { new Boolean(false), new Boolean(true), new Boolean(false), new Boolean(false), "layer1.tif" }; |
|
38 |
Object[] row1 = { new Boolean(false), new Boolean(false), new Boolean(true), new Boolean(false), "layer2.tif" }; |
|
39 |
Object[] row2 = { new Boolean(false), new Boolean(false), new Boolean(false), new Boolean(true), "layer3.tif" }; |
|
40 |
Object[] row3 = { new Boolean(true), new Boolean(false), new Boolean(false), new Boolean(false), "layer4.tif" }; |
|
41 |
table.addRow(row); |
|
42 |
table.addRow(row1); |
|
43 |
table.addRow(row2); |
|
44 |
table.addRow(row3); |
|
45 |
|
|
46 |
frame.getContentPane().add(table); |
|
47 |
frame.setSize(w, h); |
|
48 |
frame.setVisible(true); |
|
49 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
50 |
} |
|
51 |
|
|
52 |
public static void main(String[] args) { |
|
53 |
try { |
|
54 |
new TestTreeRadioButtonModelTable(); |
|
55 |
} catch (NotInitializeException ex) { |
|
56 |
System.out.println("Tabla no inicializada"); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/datainput/TestDataInput.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.datainput; |
|
20 |
|
|
21 |
import java.awt.GridLayout; |
|
22 |
import java.util.EventObject; |
|
23 |
|
|
24 |
import javax.swing.BorderFactory; |
|
25 |
import javax.swing.JFrame; |
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
public class TestDataInput implements DataInputContainerListener { |
|
29 |
private DataInputContainer data = null; |
|
30 |
private DataInputContainer data2 = null; |
|
31 |
|
|
32 |
public TestDataInput(){ |
|
33 |
data = new DataInputContainer(); |
|
34 |
data.setLabelText("Valor 1"); |
|
35 |
data.addValueChangedListener(this); |
|
36 |
|
|
37 |
data2 = new DataInputContainer(); |
|
38 |
data2.setLabelText("Valor 2"); |
|
39 |
|
|
40 |
JPanel panel = new JPanel(new GridLayout(2, 1, 2, 2)); |
|
41 |
panel.add(data); |
|
42 |
panel.add(data2); |
|
43 |
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
44 |
|
|
45 |
JFrame frame = new JFrame("DataInputContainerDemo"); |
|
46 |
frame.add(panel); |
|
47 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
48 |
frame.pack(); |
|
49 |
frame.setVisible(true); |
|
50 |
} |
|
51 |
|
|
52 |
public static void main(String[] args) { |
|
53 |
new TestDataInput(); |
|
54 |
} |
|
55 |
|
|
56 |
public void actionValueChanged(EventObject e) { |
|
57 |
System.out.println(data.getValue()); |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/combobutton/TestComboButton.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.combobutton; |
|
20 |
|
|
21 |
import java.awt.event.ActionEvent; |
|
22 |
import java.awt.event.ActionListener; |
|
23 |
|
|
24 |
import javax.swing.ImageIcon; |
|
25 |
import javax.swing.JButton; |
|
26 |
|
|
27 |
import org.gvsig.gui.beans.TestUI; |
|
28 |
import org.gvsig.gui.beans.controls.combobutton.ComboButton; |
|
29 |
|
|
30 |
public class TestComboButton implements ActionListener { |
|
31 |
|
|
32 |
public TestComboButton() { |
|
33 |
TestUI frame = new TestUI("TestComboButton"); |
|
34 |
ComboButton cb = new ComboButton(); |
|
35 |
ImageIcon icon1 = new ImageIcon(getClass().getResource("images/backward.png")); |
|
36 |
ImageIcon icon2 = new ImageIcon(getClass().getResource("images/forward.png")); |
|
37 |
JButton b1 = new JButton("Action 1", icon1); |
|
38 |
b1.addActionListener(new ActionListener() { |
|
39 |
public void actionPerformed(ActionEvent arg0) { |
|
40 |
System.out.println("Pulsando el bot?n 1"); |
|
41 |
System.out.println("Action command: " + arg0.getActionCommand()); |
|
42 |
} |
|
43 |
}); |
|
44 |
b1.setActionCommand("action1"); |
|
45 |
JButton b2 = new JButton("Action 2", icon2); |
|
46 |
b2.addActionListener(new ActionListener() { |
|
47 |
public void actionPerformed(ActionEvent arg0) { |
|
48 |
System.out.println("Pulsando el bot?n 2"); |
|
49 |
System.out.println("Action command: " + arg0.getActionCommand()); |
|
50 |
} |
|
51 |
}); |
|
52 |
b2.setActionCommand("action2"); |
|
53 |
cb.setName("Prueba"); |
|
54 |
cb.addButton(b1); |
|
55 |
cb.addSeparator(); |
|
56 |
cb.addButton(b2); |
|
57 |
cb.addActionListener(this); |
|
58 |
frame.getContentPane().add(cb); |
|
59 |
frame.setSize(80, 80); |
|
60 |
frame.setVisible(true); |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
public static void main(String[] args) { |
|
65 |
new TestComboButton(); |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
public void actionPerformed(ActionEvent e) { |
|
70 |
System.out.println("actionPerformed() : " + e.getActionCommand()); |
|
71 |
} |
|
72 |
} |
|
0 | 73 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/incrementabletask/TestThread.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.incrementabletask; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
public class TestThread { |
|
26 |
public class miThread1 extends Thread { |
|
27 |
public void run() { |
|
28 |
System.out.println("miThread1 begin"); |
|
29 |
for (int i=0; i<=10; i++) { |
|
30 |
System.out.println(i); |
|
31 |
try { |
|
32 |
Thread.sleep(500); |
|
33 |
} catch (InterruptedException e) { |
|
34 |
e.printStackTrace(); |
|
35 |
} |
|
36 |
} |
|
37 |
System.out.println("miThread1 end"); |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public TestThread() { |
|
42 |
System.out.println("testThread begin"); |
|
43 |
miThread1 a = new miThread1(); |
|
44 |
a.start(); |
|
45 |
while (true) { |
|
46 |
try { |
|
47 |
Thread.sleep(250); |
|
48 |
} catch (InterruptedException e) { |
|
49 |
e.printStackTrace(); |
|
50 |
} |
|
51 |
System.out.println("isAlive(): " + a.isAlive()); |
|
52 |
if (!a.isAlive()) break; |
|
53 |
} |
|
54 |
System.out.println("testThread end"); |
|
55 |
} |
|
56 |
|
|
57 |
public static void main(String[] args) { |
|
58 |
System.out.println("main begin"); |
|
59 |
new TestThread(); |
|
60 |
System.out.println("main end"); |
|
61 |
} |
|
62 |
|
|
63 |
} |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/incrementabletask/TestIncrementableTask.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.incrementabletask; |
|
2 |
|
|
3 |
import org.gvsig.gui.beans.progresspanel.LogControl; |
|
4 |
|
|
5 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
6 |
* |
|
7 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
8 |
* of the Valencian Government (CIT) |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
23 |
* MA 02110-1301, USA. |
|
24 |
* |
|
25 |
*/ |
|
26 |
|
|
27 |
/** |
|
28 |
* Test del IncrementableTask |
|
29 |
* |
|
30 |
* @version 27/05/2007 |
|
31 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
32 |
*/ |
|
33 |
public class TestIncrementableTask { |
|
34 |
class ClassProcess implements Runnable, IIncrementable, IncrementableListener { |
|
35 |
int i = 0; |
|
36 |
long j = 0; |
|
37 |
LogControl log = new LogControl(); |
|
38 |
IncrementableTask incrementableTask = null; |
|
39 |
|
|
40 |
private volatile Thread blinker; |
|
41 |
// private boolean ended = false; |
|
42 |
// private boolean threadSuspended = false; |
|
43 |
|
|
44 |
public ClassProcess() { |
|
45 |
} |
|
46 |
|
|
47 |
public void start() { |
|
48 |
blinker = new Thread(this); |
|
49 |
blinker.start(); |
|
50 |
} |
|
51 |
|
|
52 |
public synchronized void stop() { |
|
53 |
// ended = true; |
|
54 |
blinker = null; |
|
55 |
notify(); |
|
56 |
} |
|
57 |
|
|
58 |
public boolean isAlive() { |
|
59 |
return blinker.isAlive(); |
|
60 |
} |
|
61 |
|
|
62 |
public void procesoDuro() throws InterruptedException { |
|
63 |
try { |
|
64 |
for (long k = 0; k <= 8000; k++) |
|
65 |
for (long n = 0; n <= 5000; n++) { |
|
66 |
for (long l = 0; l <= 100; l++); |
|
67 |
if (Thread.currentThread().isInterrupted()) |
|
68 |
throw new InterruptedException(); |
|
69 |
} |
|
70 |
System.out.println("b"); |
|
71 |
} finally { |
|
72 |
System.out.println("c"); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
public synchronized void run() { |
|
77 |
try { |
|
78 |
procesoDuro(); |
|
79 |
} catch (InterruptedException e1) { |
|
80 |
System.out.println("Se ha salido"); |
|
81 |
} |
|
82 |
/* |
|
83 |
for (long k=0; k<=65535; k++) |
|
84 |
for (long n=0; n<=5000; n++); |
|
85 |
for (j=0; j<=65535; j++) { |
|
86 |
if (Thread.currentThread().isInterrupted()) |
|
87 |
break; |
|
88 |
for (long i=0; i<=65535; i++); |
|
89 |
log.replaceLastLine(j + ""); |
|
90 |
System.out.println(Thread.currentThread().isInterrupted()); |
|
91 |
if ((j%1000)==0) { |
|
92 |
log.addLine(j + ""); |
|
93 |
} |
|
94 |
synchronized(this) { |
|
95 |
while (threadSuspended && !Thread.currentThread().isInterrupted()) |
|
96 |
try { |
|
97 |
wait(500); |
|
98 |
} catch (InterruptedException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
} |
|
101 |
} |
|
102 |
}*/ |
|
103 |
incrementableTask.processFinalize(); |
|
104 |
} |
|
105 |
|
|
106 |
public String getLabel() { |
|
107 |
return "Generando estad?sticas, por favor, espere..."; |
|
108 |
} |
|
109 |
|
|
110 |
public String getLog() { |
|
111 |
return log.getText(); |
|
112 |
} |
|
113 |
|
|
114 |
public int getPercent() { |
|
115 |
return (int) ((j*100)/65535); |
|
116 |
} |
|
117 |
|
|
118 |
public String getTitle() { |
|
119 |
return "Barra de progreso"; |
|
120 |
} |
|
121 |
|
|
122 |
public void setIncrementableTask(IncrementableTask value) { |
|
123 |
incrementableTask = value; |
|
124 |
} |
|
125 |
|
|
126 |
public void actionCanceled(IncrementableEvent e) { |
|
127 |
// ended = true; |
|
128 |
blinker.interrupt(); |
|
129 |
} |
|
130 |
|
|
131 |
public void actionResumed(IncrementableEvent e) { |
|
132 |
// threadSuspended = false; |
|
133 |
} |
|
134 |
|
|
135 |
public void actionSuspended(IncrementableEvent e) { |
|
136 |
// threadSuspended = true; |
|
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
public void setLabel(String label) { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
public boolean isSuspended() { |
|
146 |
// TODO Auto-generated method stub |
|
147 |
return false; |
|
148 |
} |
|
149 |
|
|
150 |
public void resume() { |
|
151 |
// TODO Auto-generated method stub |
|
152 |
|
|
153 |
} |
|
154 |
|
|
155 |
public void suspend() { |
|
156 |
// TODO Auto-generated method stub |
|
157 |
|
|
158 |
} |
|
159 |
|
|
160 |
public boolean isCancelable() { |
|
161 |
// TODO Auto-generated method stub |
|
162 |
return false; |
|
163 |
} |
|
164 |
|
|
165 |
public void process() throws InterruptedException, Exception { |
|
166 |
// TODO Auto-generated method stub |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
public void setCancelable(boolean b) { |
|
171 |
// TODO Auto-generated method stub |
|
172 |
|
|
173 |
} |
|
174 |
|
|
175 |
public boolean isPausable() { |
|
176 |
// TODO Auto-generated method stub |
|
177 |
return false; |
|
178 |
} |
|
179 |
|
|
180 |
public void setPausable(boolean b) { |
|
181 |
// TODO Auto-generated method stub |
|
182 |
|
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
ClassProcess classProcess = null; |
|
187 |
|
|
188 |
public TestIncrementableTask() { |
|
189 |
super(); |
|
190 |
initialize(); |
|
191 |
} |
|
192 |
|
|
193 |
private void initialize() { |
|
194 |
classProcess = new ClassProcess(); |
|
195 |
IncrementableTask incrementableTask = new IncrementableTask(classProcess); |
|
196 |
classProcess.setIncrementableTask(incrementableTask); |
|
197 |
incrementableTask.showWindow(); |
|
198 |
incrementableTask.addIncrementableListener(classProcess); |
|
199 |
|
|
200 |
incrementableTask.start(); |
|
201 |
classProcess.start(); |
|
202 |
while (classProcess.isAlive()) { |
|
203 |
try { |
|
204 |
Thread.sleep(500); |
|
205 |
} catch (InterruptedException e) { |
|
206 |
e.printStackTrace(); |
|
207 |
} |
|
208 |
} |
|
209 |
classProcess.stop(); |
|
210 |
classProcess = null; |
|
211 |
incrementableTask = null; |
|
212 |
} |
|
213 |
|
|
214 |
public static void main(String[] args) { |
|
215 |
new TestIncrementableTask(); |
|
216 |
} |
|
217 |
} |
|
0 | 218 |
tags/v2_0_0_Build_2020/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/colorslideredition/TestColorSliderEdition.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.colorslideredition; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
import java.awt.Dimension; |
|
23 |
import java.awt.GridBagConstraints; |
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
|
|
27 |
import javax.swing.JCheckBox; |
|
28 |
import javax.swing.JPanel; |
|
29 |
import javax.swing.border.EmptyBorder; |
|
30 |
|
|
31 |
import org.gvsig.gui.beans.TestUI; |
|
32 |
/** |
|
33 |
* |
|
34 |
* @version 02/11/2007 |
|
35 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
36 |
*/ |
|
37 |
public class TestColorSliderEdition implements ActionListener { |
|
38 |
private TestUI jFrame = new TestUI("TestColorSliderEdition"); |
|
39 |
private ColorSliderEdition colorSliderEdition = null; |
|
40 |
JCheckBox jCBInterpolated = null; |
|
41 |
JCheckBox jCBEnabled = null; |
|
42 |
|
|
43 |
public TestColorSliderEdition() { |
|
44 |
jCBInterpolated = new JCheckBox("Interpolated"); |
|
45 |
jCBInterpolated.setSelected(true); |
|
46 |
jCBInterpolated.addActionListener(this); |
|
47 |
jCBEnabled = new JCheckBox("Enabled"); |
|
48 |
jCBEnabled.addActionListener(this); |
|
49 |
jCBEnabled.setSelected(true); |
|
50 |
|
|
51 |
jFrame.setSize(new Dimension(498, 127)); |
|
52 |
colorSliderEdition = new ColorSliderEdition(); |
|
53 |
colorSliderEdition.setPreferredSize(new Dimension(0, 44)); |
|
54 |
colorSliderEdition.setMinimumSize(new Dimension(0, 44)); |
|
55 |
|
|
56 |
colorSliderEdition.addItem(new ItemColorSlider(0, Color.black), false); |
|
57 |
colorSliderEdition.addItem(new ItemColorSlider(25, Color.red), false); |
|
58 |
colorSliderEdition.addItem(new ItemColorSlider(50, Color.yellow), false); |
|
59 |
colorSliderEdition.addItem(new ItemColorSlider(75, Color.blue), true); |
|
60 |
colorSliderEdition.addItem(new ItemColorSlider(100, new Color(255, 255, 255, 0)), true); |
|
61 |
|
|
62 |
JPanel jPanel = new JPanel(); |
|
63 |
jFrame.setContentPane(jPanel); |
|
64 |
|
|
65 |
jPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
66 |
jPanel.setLayout(new java.awt.GridBagLayout()); |
|
67 |
|
|
68 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
69 |
gridBagConstraints.gridx = 0; |
|
70 |
gridBagConstraints.gridy = 0; |
|
71 |
gridBagConstraints.weightx = 1; |
|
72 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
73 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 5); |
|
74 |
jPanel.add(colorSliderEdition, gridBagConstraints); |
|
75 |
|
|
76 |
gridBagConstraints = new GridBagConstraints(); |
|
77 |
gridBagConstraints.gridx = 0; |
|
78 |
gridBagConstraints.gridy = 1; |
|
79 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
80 |
jPanel.add(jCBInterpolated, gridBagConstraints); |
|
81 |
|
|
82 |
gridBagConstraints = new GridBagConstraints(); |
|
83 |
gridBagConstraints.gridx = 0; |
|
84 |
gridBagConstraints.gridy = 2; |
|
85 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5); |
|
86 |
jPanel.add(jCBEnabled, gridBagConstraints); |
|
87 |
|
|
88 |
jFrame.setVisible(true); |
|
89 |
} |
Also available in: Unified diff