Example #1
0
		public SynsetCollection()
		{
			_synsets = new java.util.ArrayList();
			_synsets.addAll(SUMO.WordNet.Intern.nounSUMOHash.keySet());
			java.util.Iterator it = SUMO.WordNet.Intern.verbSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			it = SUMO.WordNet.Intern.adjectiveSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			it = SUMO.WordNet.Intern.adverbSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			_it = _synsets.iterator();
		}
Example #2
0
 public SynsetCollection()
 {
     _synsets = new java.util.ArrayList();
     _synsets.addAll(SUMO.WordNet.Intern.nounSUMOHash.keySet());
     java.util.Iterator it = SUMO.WordNet.Intern.verbSUMOHash.keySet().iterator();
     while (it.hasNext())
     {
         string s = it.next().ToString();
         if (_synsets.contains(s))
         {
             continue;
         }
         _synsets.add(s);
     }
     it = SUMO.WordNet.Intern.adjectiveSUMOHash.keySet().iterator();
     while (it.hasNext())
     {
         string s = it.next().ToString();
         if (_synsets.contains(s))
         {
             continue;
         }
         _synsets.add(s);
     }
     it = SUMO.WordNet.Intern.adverbSUMOHash.keySet().iterator();
     while (it.hasNext())
     {
         string s = it.next().ToString();
         if (_synsets.contains(s))
         {
             continue;
         }
         _synsets.add(s);
     }
     _it = _synsets.iterator();
 }
Example #3
0
 /// <summary>Adds an observer to the list.</summary>
 /// <remarks>
 /// Adds an observer to the list. The observer cannot be null and it must not already
 /// be registered.
 /// </remarks>
 /// <param name="observer">the observer to register</param>
 /// <exception cref="System.ArgumentException">the observer is null</exception>
 /// <exception cref="System.InvalidOperationException">the observer is already registered
 ///     </exception>
 public virtual void registerObserver(T observer)
 {
     if ((object)observer == null)
     {
         throw new System.ArgumentException("The observer is null.");
     }
     lock (mObservers)
     {
         if (mObservers.contains(observer))
         {
             throw new System.InvalidOperationException("Observer " + observer + " is already registered."
                                                        );
         }
         mObservers.add(observer);
     }
 }
Example #4
0
 /**
  * Removes user (public) listener to this list.
  *
  * @param listener - listener to be removed.
  */
 public void removeUserListener(Object listener)
 {
     if (listener == null)
     {
         return;
     }
     // transactionally replace old list
     lock (this)
     {
         if (userList == null || !userList.contains(listener))
         {
             return;
         }
         java.util.ArrayList <T> newList = new java.util.ArrayList <T>(userList);
         newList.remove(listener);
         userList = (newList.size() > 0 ? newList : null);
     }
 }
Example #5
0
        private android.view.View findNextFocus(android.view.ViewGroup root, android.view.View
                                                focused, android.graphics.Rect focusedRect, int direction)
        {
            java.util.ArrayList <android.view.View> focusables = root.getFocusables(direction);
            if (focusables.isEmpty())
            {
                // The focus cannot change.
                return(null);
            }
            if (direction == android.view.View.FOCUS_FORWARD || direction == android.view.View
                .FOCUS_BACKWARD)
            {
                if (focused != null && !focusables.contains(focused))
                {
                    // Add the currently focused view to the list to have it sorted
                    // along with the other views.
                    focusables.add(focused);
                }
                try
                {
                    // Note: This sort is stable.
                    mSequentialFocusComparator.setRoot(root);
                    java.util.Collections.sort(focusables, mSequentialFocusComparator);
                }
                finally
                {
                    mSequentialFocusComparator.recycle();
                }
                int count = focusables.size();
                switch (direction)
                {
                case android.view.View.FOCUS_FORWARD:
                {
                    if (focused != null)
                    {
                        int position = focusables.lastIndexOf(focused);
                        if (position >= 0 && position + 1 < count)
                        {
                            return(focusables.get(position + 1));
                        }
                    }
                    return(focusables.get(0));
                }

                case android.view.View.FOCUS_BACKWARD:
                {
                    if (focused != null)
                    {
                        int position = focusables.indexOf(focused);
                        if (position > 0)
                        {
                            return(focusables.get(position - 1));
                        }
                    }
                    return(focusables.get(count - 1));
                }
                }
                return(null);
            }
            // initialize the best candidate to something impossible
            // (so the first plausible view will become the best choice)
            mBestCandidateRect.set(focusedRect);
            switch (direction)
            {
            case android.view.View.FOCUS_LEFT:
            {
                mBestCandidateRect.offset(focusedRect.width() + 1, 0);
                break;
            }

            case android.view.View.FOCUS_RIGHT:
            {
                mBestCandidateRect.offset(-(focusedRect.width() + 1), 0);
                break;
            }

            case android.view.View.FOCUS_UP:
            {
                mBestCandidateRect.offset(0, focusedRect.height() + 1);
                break;
            }

            case android.view.View.FOCUS_DOWN:
            {
                mBestCandidateRect.offset(0, -(focusedRect.height() + 1));
                break;
            }
            }
            android.view.View closest = null;
            int numFocusables         = focusables.size();

            {
                for (int i = 0; i < numFocusables; i++)
                {
                    android.view.View focusable = focusables.get(i);
                    // only interested in other non-root views
                    if (focusable == focused || focusable == root)
                    {
                        continue;
                    }
                    // get visible bounds of other view in same coordinate system
                    focusable.getDrawingRect(mOtherRect);
                    root.offsetDescendantRectToMyCoords(focusable, mOtherRect);
                    if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect))
                    {
                        mBestCandidateRect.set(mOtherRect);
                        closest = focusable;
                    }
                }
            }
            return(closest);
        }