source: trunk/gsdl3/src/java/org/greenstone/applet/phind/ResultDisplay.java@ 3658

Last change on this file since 3658 was 3391, checked in by kjdon, 22 years ago

modified phind applet for gsdl3

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/**********************************************************************
2 *
3 * ResultDisplay.java -- Phrase list holder for Phind java applet
4 *
5 * Copyright 1997-2000 Gordon W. Paynter
6 * Copyright 2000 The New Zealand Digital Library Project
7 *
8 * A component of the Greenstone digital library software
9 * from the New Zealand Digital Library Project at the
10 * University of Waikato, New Zealand.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (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., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 *********************************************************************/
27
28/*********************************************************************
29
30This class is used in the Phind java applet (Phind.java).
31
32A ResultDisplay is a Panel that can display a single Component, which will
33be a ResultBox or PhindTitle object.
34
35ResultBoxes can be "chained" together with their "prev" and "next" fields,
36allowing us to have an arbitrary number of "displays" in which to show
37phrase lists.
38
39Main methods:
40* emptyContents will remove the component and emptyAll the "next" display
41* display will add an item to the first (ie: most "prev") available box
42
43**********************************************************************/
44package org.greenstone.applet.phind;
45//package org.nzdl.gsdl.Phind;
46
47import java.awt.Panel;
48import java.awt.BorderLayout;
49import java.awt.Component;
50
51class ResultDisplay extends Panel {
52
53 Phind phind;
54 ResultDisplay prev, next;
55 Component current;
56 boolean empty;
57
58 // Create a new Display
59 ResultDisplay(Phind ph, ResultDisplay pr) {
60 phind = ph;
61 prev = pr;
62 next = null;
63 if (prev != null) prev.next = this;
64 setLayout(new BorderLayout());
65
66 empty = true;
67 current = new PhindTitle(ph);
68 add(current);
69 }
70
71 // Empty the contents of the display,
72 // and all the next displays
73 void emptyContents() {
74 if (empty == false) {
75 empty = true;
76 current = new PhindTitle(phind);
77 removeAll();
78 add(current);
79 }
80 if (next != null) next.emptyContents();
81 }
82
83 // Set the contents of this display
84 Component setContents( Component r ) {
85 removeAll();
86 add("Center", r);
87 current = r;
88 empty = false;
89 if (r.getClass().getName().equals("ResultBox")) {
90 ((ResultBox) r).display = this;
91 }
92 return r;
93 }
94
95
96
97 // Display a component in the "most previous" display
98 ResultDisplay display( Component r ) {
99
100 if (prev == null) {
101 // if there is no previous box, add the component here
102 setContents(r);
103 return this;
104
105 } else if (prev.empty == true) {
106 // if the previous box is empty, add the component to it instead
107 return prev.display(r);
108
109 } else if (empty == true) {
110 // if this box is empty, add the compnent to it
111 setContents(r);
112 return this;
113
114 } else {
115 // if this box is occupied,
116 // shift it's contents prev-wards and add here.
117 prev.display(current);
118 setContents(r);
119 return this;
120 }
121 }
122
123}
124
125
126
Note: See TracBrowser for help on using the repository browser.