1 /***
2 *
3 * The owl-s matcher software is subject to the GNU Lesser General
4 * Public License Version 2.1 (the "License"). You may not copy or use this
5 * file, in either source code or executable form, except in compliance
6 * with the License. You may obtain a copy of the License at
7 * http://www.fsf.org/licenses/lgpl.txt or http://www.opensource.org/.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied without
11 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the License for the specific language governing rights and
13 * limitations under the License.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this distribution; if not, write to the
17 *
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307 USA
21 *
22 * Copyright (C) 2003-2004
23 * TU Berlin, FG IVS
24 * Stefan Tang,
25 * Christoph Liebetruth,
26 * Michael C. Jaeger,
27 *
28 * More information available at http://ivs.tu-berlin.de/
29 *
30 * $Id$
31 *
32 */
33 package de.tuberlin.ivs.owl.gui;
34 import java.awt.*;
35
36 /***
37 * Thread that refreshes the frames that display the progress when either
38 * a file is loaded/parsed or two services are matched.
39 *
40 * @author Stefan Tang (steftang@stanford.edu), Christoph Liebetruth (christophl@voelcker.com)
41 * @version 1.1
42 */
43 public class FrameThread extends Thread {
44
45 /***
46 * The parent frame of the display dialogs.
47 */
48 MainFrame mainFrame;
49
50 /***
51 * Mode for displaying the loading progress.
52 */
53 public static int LOAD = 0;
54
55 /***
56 * Mode for displaying the matching progress.
57 */
58 public static int MATCH = 1;
59
60 /***
61 * The dialog that will display the loading progress.
62 */
63 LoadingServiceProgressDialog progressDiag;
64
65 /***
66 * The dialog that will display the matching progress.
67 */
68 MatchingProgressDialog matchDiag;
69
70 /***
71 * The mode in which this thread runs.
72 */
73 int mode;
74
75 /***
76 * Constructor that initializes this thread for display of the loading
77 * progress.
78 * @param parent The parent frame of the dialog window.
79 * @param frame The dialog that displays the loading progress.
80 */
81 public FrameThread(MainFrame parent,LoadingServiceProgressDialog frame) {
82 mainFrame = parent;
83 this.mode = LOAD;
84 progressDiag = frame;
85 }
86
87 /***
88 * Constructor that initializes this thread for diplay of the matching
89 * progress.
90 * @param parent The parent frame of the dialog window.
91 * @param frame The dialog that displays the matching progress.
92 */
93 public FrameThread(MainFrame parent, MatchingProgressDialog frame) {
94 mainFrame = parent;
95 this.mode = MATCH;
96 matchDiag = frame;
97 }
98
99 /***
100 * Run method of the thread. Depending on the mode, displays either the frame
101 * that displays the progress while loading a file or while matching two
102 * services.
103 */
104 public void run() {
105 if (mode==LOAD) {
106 Dimension dlgSize = progressDiag.getPreferredSize();
107 Dimension frmSize = mainFrame.getSize();
108 Point loc = mainFrame.getLocation();
109 progressDiag.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
110 (frmSize.height - dlgSize.height) / 2 + loc.y);
111 progressDiag.pack();
112 MessageStream out = new MessageStream(progressDiag);
113 progressDiag.show();
114 } else if (mode==MATCH) {
115 Dimension dlgSize = matchDiag.getPreferredSize();
116 Dimension frmSize = mainFrame.getSize();
117 Point loc = mainFrame.getLocation();
118 matchDiag.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
119 (frmSize.height - dlgSize.height) / 2 + loc.y);
120 matchDiag.pack();
121 matchDiag.show();
122 }
123 }
124
125 /***
126 * Closes the frame that shows the current progress.
127 */
128 public void hideFrame() {
129 if (mode==LOAD) {
130 progressDiag.hide();
131 } else if (mode==MATCH) {
132 matchDiag.hide();
133 }
134 }
135
136 }