Back to index

im-sdk  12.3.91
IIIMLookupEvent.java
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 
00043 
00044 package com.sun.iiim;
00045 
00046 import java.awt.Dimension;
00047 import java.text.AttributedString;
00048 import java.text.AttributedCharacterIterator;
00049 
00053 public class IIIMLookupEvent extends IIIMEvent {
00054 
00055     private int master;
00056     private int choicePerWindow;
00057     private Dimension rowColum;
00058     private int direction;
00059     private int labelOwner;
00060     private int firstCandidate;
00061     private int lastCandidate;
00062     private int currentCandidate;
00063     private String[] candidates;
00064     private AttributedCharacterIterator[] candidateIterator;
00065     private String[] labelList;
00066     private AttributedCharacterIterator[] labelIterator;
00067     private int processType;
00068     private int indexPage;
00069     private String title;
00070     private AttributedCharacterIterator titleIterator;
00071 
00072     //
00073     // The first argument of each constructor type may be redundant, but
00074     // it will allow the event with the same kind of aruguments
00075     // and different type of event.
00076     //
00077 
00084     public IIIMLookupEvent(int type, int master, int choicePerWindow,
00085                         Dimension rowColum, int direction, int labelOwner) {
00086        super(LOOKUP);
00087        if (type != START) {
00088            throw new IllegalArgumentException();
00089        }
00090        this.type = START;
00091        this.master = master;
00092        this.choicePerWindow = choicePerWindow;
00093        this.rowColum = rowColum;
00094        this.direction = direction;
00095        this.labelOwner = labelOwner;
00096     }
00097 
00101     public IIIMLookupEvent(int type) {
00102        super(LOOKUP);
00103        if (type != DONE) {
00104            throw new IllegalArgumentException();
00105        }
00106        this.type = DONE;
00107     }
00108 
00116     public IIIMLookupEvent(int type, int firstCandidate, int lastCandidate,
00117                         int currentCandidate, String[] candidates,
00118                         String[] labelList, String title) {
00119        super(LOOKUP);
00120        if (type != DRAW) {
00121            throw new IllegalArgumentException();
00122        }
00123        this.type = DRAW;
00124        this.firstCandidate = firstCandidate;
00125        this.lastCandidate = lastCandidate;
00126        this.currentCandidate = currentCandidate;
00127        this.candidates = candidates;
00128        this.labelList = labelList;
00129        this.title = title;
00130     }
00131 
00138     public IIIMLookupEvent(int type, int firstCandidate, int lastCandidate,
00139                         int currentCandidate,
00140                         AttributedCharacterIterator[] candidates,
00141                         AttributedCharacterIterator[] labelList,
00142                         AttributedCharacterIterator title) {
00143        super(LOOKUP);
00144        if (type != DRAW) {
00145            throw new IllegalArgumentException();
00146        }
00147        this.type = DRAW;
00148        this.firstCandidate = firstCandidate;
00149        this.lastCandidate = lastCandidate;
00150        this.currentCandidate = currentCandidate;
00151        candidateIterator = candidates;
00152        labelIterator = labelList;
00153        titleIterator = title;
00154     }
00155 
00159     public IIIMLookupEvent(int type, int processType,
00160                         int indexPage) {
00161        super(LOOKUP);
00162        if (type != PROCESS) {
00163            throw new IllegalArgumentException();
00164        }
00165        this.type = PROCESS;
00166        this.processType = processType;
00167        this.indexPage = indexPage;
00168     }
00169 
00170     public final static int START   = 0;
00171     public final static int DONE    = 1;
00172     public final static int DRAW    = 2;
00173     public final static int PROCESS = 3;
00174 
00175     public final static int SERVER_MASTER = 1;
00176     public final static int CLIENT_MASTER = 2;
00177     
00178     public final static int DRAW_HORIZONTALLY = 0;
00179     public final static int DRAW_VERTICALLY   = 1;
00180 
00181     public final static int SERVER_LABEL = 0;
00182     public final static int CLIENT_LABEL = 1;
00183 
00184     public final static int PROCESS_INDEX = 0;
00185     public final static int PROCESS_PAGE = 1;
00186 
00187     public final static int NEXT_PAGE  = 0;
00188     public final static int PREV_PAGE  = 1;
00189     public final static int FIRST_PAGE = 2;
00190     public final static int LAST_PAGE  = 3;
00191 
00221     // START event methods
00222 
00226     public int getMaster() {
00227        return master;
00228     }
00229 
00233     public int getChoicePerWindow() {
00234        return choicePerWindow;
00235     }
00236 
00240     public Dimension getRowColum() {
00241        return rowColum;
00242     }
00243 
00247     public int getDirection() {
00248        return direction;  
00249     }
00250 
00254     public int getLabelOwner() {
00255        return labelOwner;
00256     }
00257 
00258     // DRAW event methods
00259 
00263     public int getFirstCandidate() {
00264        return firstCandidate;
00265     }
00266 
00270     public int getLastCandidate() {
00271        return lastCandidate;
00272     }
00273 
00277     public int getCurrentCandidate() {
00278        return currentCandidate;
00279     }
00280 
00284     public String[] getCandidates() {
00285        if (candidates == null) {
00286            String[] sa = new String[candidateIterator.length];
00287            for (int i = 0; i < sa.length; i++) {
00288               sa[i] = iteratorToString(candidateIterator[i]);
00289            }
00290            candidates = sa;
00291        }
00292        return candidates;
00293     }
00294 
00298     public AttributedCharacterIterator[] getCandidateIterator() {
00299        if (candidateIterator == null) {
00300            AttributedCharacterIterator[] acia =
00301               new AttributedCharacterIterator[candidates.length];
00302            for (int i = 0; i < acia.length; i++) {
00303               acia[i] = new AttributedString(candidates[i]).getIterator();
00304            }
00305            candidateIterator = acia;
00306        }
00307        return candidateIterator;
00308     }
00309 
00313     public String[] getLabelList() {
00314        if (labelList == null) {
00315            String[] sa = new String[labelIterator.length];
00316            for (int i = 0; i < sa.length; i++) {
00317               sa[i] = iteratorToString(labelIterator[i]);
00318            }
00319            candidates = sa;
00320        }
00321        return labelList;
00322     }
00323 
00327     public AttributedCharacterIterator[] getLabelIterator() {
00328        if (labelIterator == null) {
00329            AttributedCharacterIterator[] acia =
00330               new AttributedCharacterIterator[labelList.length];
00331            for (int i = 0; i < acia.length; i++) {
00332               acia[i] = new AttributedString(labelList[i]).getIterator();
00333            }
00334            labelIterator = acia;
00335        }
00336        return labelIterator;
00337     }
00338 
00342     public String getTitle() {
00343        if (title == null) {
00344            title = iteratorToString(titleIterator);
00345        }
00346        return title;
00347     }
00348 
00352     public AttributedCharacterIterator getTitleIterator() {
00353        if (titleIterator == null) {
00354            titleIterator = new AttributedString(title).getIterator();
00355        }
00356        return titleIterator;
00357     }
00358 
00359     // PROCESS event methods
00360 
00364     public int getProcessType() {
00365        return processType;
00366     }
00367 
00372     public int getProcessIndexPage() {
00373        return indexPage;
00374     }
00375 }