home *** CD-ROM | disk | FTP | other *** search
- Save Format v2.3(19971110)
- @begin Form "Form_SortableVector"
-
- @begin Object "Powersoft Java AWT 1.10::java.awt.Frame"
- DesignName Form_SortableVector;
- @begin ClassProperties
- @begin-code BaseClassList
-
- extends java.awt.Frame
-
- @end-code;
- @begin CPMethod "loadVector"
- @begin CPPrototype "Prototype for LoadVectorMethod"
- @begin-code SourceCode "Prototype for LoadVectorMethod"
-
- // Not used for Java classes
-
- @end-code;
- @end;
- @begin CPDefinition "LoadVectorMethod"
- @begin-code SourceCode "LoadVectorMethod"
-
- //
- // LoadVectorMethod
- //
-
- void loadVector()
- {
- _nameVector.clear();
- for ( int t = 0; t<ELEMENTS; t += 1 )
- _nameVector.append( _nameList[t] );
- }
-
- @end-code;
- @end;
- @end;
- @begin CPMethod "sequentialSearch"
- @begin CPPrototype "Prototype for SequentialSearchMethod"
- @begin-code SourceCode "Prototype for SequentialSearchMethod"
-
- // Not used for Java classes
-
- @end-code;
- @end;
- @begin CPDefinition "SequentialSearchMethod"
- @begin-code SourceCode "SequentialSearchMethod"
-
- //
- // SequentialSearchMethod
- //
-
- public int sequentialSearch(String searchName)
- {
- Enumeration e;
- int count = 0;
-
- e = _nameVector.getElements();
-
- while ( e.hasMoreElements() )
- {
- String currentElement = ( String ) e.nextElement();
- if ( currentElement.equals( searchName ) )
- {
- return count;
- }
- count++;
- }
- return -1;
- }
-
- @end-code;
- @end;
- @end;
- @begin CPMethod "updateListbox"
- @begin CPPrototype "Prototype for updateListboxMethod"
- @begin-code SourceCode "Prototype for updateListboxMethod"
-
- // Not used for Java classes
-
- @end-code;
- @end;
- @begin CPDefinition "updateListboxMethod"
- @begin-code SourceCode "updateListboxMethod"
-
- //
- // updateListboxMethod
- //
-
- public void updateListbox()
- {
- Enumeration e;
-
- lb_nameList.clear();
-
- e = _nameVector.getElements();
-
- while ( e.hasMoreElements () )
- {
- String currentElement = ( String ) e.nextElement();
- lb_nameList.addItem( currentElement );
- }
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Properties
- @begin DesignProperties
- Style "cf0000";
- ResID 0;
- DesignRect 59,36,293,224;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- LayoutManager "powersoft.powerj.ui.ResizePercentageLayout";
- FormPositionType "DesignTime";
- foreground "java.awt.Color.black";
- background "java.awt.Color.lightGray";
- SerializationData "";
- title "Sortable Vector";
- @end;
- @end;
- @begin Events
- @begin Event "powersoft.powerj.event.Object.objectCreated"
- @begin-code SourceCode "powersoft.powerj.event.Object.objectCreated"
-
- public boolean Form_SortableVector_objectCreated(powersoft.powerj.event.EventData event)
- {
- loadVector();
- updateListbox();
-
- return false;
- }
-
- @end-code;
- @end;
- @begin Event "java.awt.event.Window.windowClosing"
- @begin-code SourceCode "java.awt.event.Window.windowClosing"
-
- public void Form_SortableVector_windowClosing(java.awt.event.WindowEvent event)
- {
- setVisible( false );
- destroy();
- }
-
- @end-code;
- @end;
- @end;
- @begin UserFunctions
- @begin UserFunction "Form_SortableVector()"
- @begin Definition
- @begin-code SourceCode "Form_SortableVector()"
-
- public Form_SortableVector()
- {
- super();
- }
-
- @end-code;
- @end;
- @end;
- @begin UserFunction "unhandledEvent( String listenerName, String methodName, java.lang.Object event )"
- @begin Prototype
- FunctionScope 1;
- @begin-code SourceCode "Prototype for unhandledEvent( String listenerName, String methodName, java.lang.Object event )"
-
- // Placeholder for Prototype for unhandledEvent( String listenerName, String methodName, java.lang.Object event )
- // you should move the prototype here from the Class Contents section
-
- @end-code;
- @end;
- @begin Definition
- @begin-code SourceCode "unhandledEvent( String listenerName, String methodName, java.lang.Object event )"
-
- public void unhandledEvent( String listenerName, String methodName, java.lang.Object event )
- {
-
- }
-
- @end-code;
- @end;
- @end;
- @begin UserFunction "processEvent(java.awt.AWTEvent event)"
- @begin Definition
- @begin-code SourceCode "processEvent(java.awt.AWTEvent event)"
-
- public void processEvent(java.awt.AWTEvent event)
- {
-
- defaultProcessEvent(event);
- }
-
- @end-code;
- @end;
- @end;
- @begin UserFunction "getContentPane()"
- @begin Definition
- @begin-code SourceCode "getContentPane()"
-
- public java.awt.Container getContentPane()
- {
- return this;
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin CodeBlocks
- @begin CodeBlock "HppPrefix"
- FunctionScope 1;
- @begin-code SourceCode "Imports()"
-
- // add your custom import statements here
- import java.util.Enumeration;
- import powersoft.powerj.util.SortableVector;
- import powersoft.powerj.util.StringUtility;
- import powersoft.powerj.util.CompareRoutine;
-
- @end-code;
- @end;
- @begin CodeBlock "ClassContents"
- FunctionScope 1;
- @begin-code SourceCode "Data Members()"
-
- // add your data members here
- final int ELEMENTS = 28;
- SortableVector _nameVector = new SortableVector();
- String _sortType = new String( "none" );
- String[] _nameList =
- {
- "John",
- "Brad",
- "Jim",
- "Greg",
- "Dan",
- "Dave",
- "Wesley",
- "Eric",
- "Chris",
- "Geno",
- "Rob",
- "David",
- "Ivan",
- "Waldo",
- "Mark",
- "Kevin",
- "Paul",
- "Bill",
- "Eugene",
- "Tim",
- "Asif",
- "Michael",
- "Thorsten",
- "Graham",
- "Jack",
- "Lisa",
- "Anthony",
- "Brian"
- };
-
- @end-code;
- @end;
- @begin CodeBlock "GeneratedClassContents"
- FunctionScope 1;
- @begin-code SourceCode "GeneratedClassContents()"
-
-
- @end-code;
- @end;
- @begin CodeBlock "CppPrefix"
- FunctionScope 6;
- GeneratedFunction 1;
- @begin-code SourceCode "Not Applicable for Java()"
-
-
- @end-code;
- @end;
- @end;
- @begin Objects
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuBar"
- DesignName menu_SortableVector;
- @begin Properties
- @begin DesignProperties
- Style "50000103";
- ResID 0;
- DesignRect 219,195,16,15;
- @end;
- @begin ObjectProperties
- SerializationData "";
- @end;
- @end;
- @begin Objects
- @begin Object "Powersoft Java AWT 1.10::java.awt.Menu"
- DesignName Sort;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Sort";
- SerializationData "";
- @end;
- @end;
- @begin Objects
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName AlphaSort;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Alpha Sort";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_AlphaSort_actionPerformed(java.awt.event.ActionEvent event)
- {
- CompareRoutine routine = StringUtility.getCompareRoutine( false );
- _nameVector.setCompareRoutine( routine );
-
- _sortType = "alpha";
- _nameVector.sort();
- updateListbox();
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName NameLengthSort;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Name Length Sort";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_NameLengthSort_actionPerformed(java.awt.event.ActionEvent event)
- {
- // use our own StringLengthSort Class
- _nameVector.setCompareRoutine( new StringLengthSort() );
- _sortType = "namelength";
- _nameVector.sort();
- updateListbox();
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName Scramble;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Scramble";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_Scramble_actionPerformed(java.awt.event.ActionEvent event)
- {
- _nameVector = new SortableVector();
- loadVector();
- updateListbox();
- _sortType = "none";
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.Menu"
- DesignName Name;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Name";
- SerializationData "";
- @end;
- @end;
- @begin Objects
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName AddWaldo;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Add Waldo";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_AddWaldo_actionPerformed(java.awt.event.ActionEvent event)
- {
- if ( _sortType.equals( "none" ) )
- {
- _nameVector.insert(
- ( int )( Math.random() * _nameVector.getCount() ),
- "Waldo"
- );
- }
- else
- {
- _nameVector.insert( "Waldo" );
- }
- updateListbox();
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName RemoveWaldo;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Remove Waldo";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_RemoveWaldo_actionPerformed(java.awt.event.ActionEvent event)
- {
- int position = -1;
-
- if ( !_sortType.equals( "alpha" ) )
- {
- position = sequentialSearch( "Waldo" );
- }
- else
- {
- position = _nameVector.binarySearch( "Waldo" );
- }
-
- if ( position > -1 )
- {
- _nameVector.removeAt(position);
- updateListbox();
- }
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName FindWaldo;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Find Waldo";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_FindWaldo_actionPerformed(java.awt.event.ActionEvent event)
- {
- int position = 0;
-
- if ( !_sortType.equals( "alpha" ) )
- {
- position = sequentialSearch( "Waldo" ) + 1;
- }
- else
- {
- position = ( _nameVector.binarySearch( "Waldo" ) + 1 );
- }
-
- if ( position != 0 )
- {
- textf_messages.setText( "Waldo found at position " + position + "." );
- }
- else
- {
- textf_messages.setText( "Waldo not found." );
- }
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.MenuItem"
- DesignName RemoveThirdName;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- DesignRect 0,0,0,0;
- @end;
- @begin ObjectProperties
- label "Remove Third Name";
- SerializationData "";
- @end;
- @end;
- @begin Events
- @begin Event "java.awt.event.Action.actionPerformed"
- @begin-code SourceCode "java.awt.event.Action.actionPerformed"
-
- public void menu_SortableVector_RemoveThirdName_actionPerformed(java.awt.event.ActionEvent event)
- {
- if ( _nameVector.getCount() > 2 )
- {
- _nameVector.removeAt( 2 );
- updateListbox();
- }
- }
-
- @end-code;
- @end;
- @end;
- @end;
- @end;
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.List"
- DesignName lb_nameList;
- @begin Properties
- @begin DesignProperties
- ResID 0;
- TabIndex 1;
- DesignRect 5,40,275,135;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- dataTrackRow "0";
- foreground "java.awt.Color.black";
- background "java.awt.Color.white";
- SerializationData "";
- @end;
- @begin ComponentProperties "lb_nameList"
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.TextField"
- DesignName textf_messages;
- @begin Properties
- @begin DesignProperties
- Style "800";
- ResID 0;
- TabIndex 2;
- DesignRect 5,180,275,13;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- foreground "java.awt.Color.black";
- background "java.awt.Color.white";
- SerializationData "";
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.Label"
- DesignName label_1;
- @begin Properties
- @begin DesignProperties
- ResID 100;
- TabIndex 3;
- DesignRect 5,5,275,10;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- text "This sample demonstrates some of the use of the SortableVector class.";
- foreground "java.awt.Color.black";
- background "java.awt.Color.lightGray";
- SerializationData "";
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.Label"
- DesignName label_2;
- @begin Properties
- @begin DesignProperties
- ResID 100;
- TabIndex 4;
- DesignRect 5,15,275,10;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- text "The menu items perform operations on the vector and display the results";
- foreground "java.awt.Color.black";
- background "java.awt.Color.lightGray";
- SerializationData "";
- @end;
- @end;
- @end;
- @begin Object "Powersoft Java AWT 1.10::java.awt.Label"
- DesignName label_3;
- @begin Properties
- @begin DesignProperties
- ResID 100;
- TabIndex 5;
- DesignRect 5,25,275,10;
- @end;
- @begin ObjectProperties
- font "Dialog-Plain-12";
- text "in the list box below.";
- foreground "java.awt.Color.black";
- background "java.awt.Color.lightGray";
- SerializationData "";
- @end;
- @end;
- @end;
- @end;
- @end;
- @end;
-