Cytoscape 2.8.0 API

cytoscape.util.swing
Class WidestStringComboBoxModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by cytoscape.util.swing.WidestStringComboBoxModel
All Implemented Interfaces:
WidestStringProvider, Serializable, ComboBoxModel, ListModel, MutableComboBoxModel

public class WidestStringComboBoxModel
extends DefaultComboBoxModel
implements WidestStringProvider

Author:
Noel Ruddock This ComboBoxModel tracks the widest string getLabel(Object anObject) should be overridden to derive the String from an Object in the model when getString() doesn't provide what will be displayed.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
WidestStringComboBoxModel()
          Class Constructor.
WidestStringComboBoxModel(Object[] items)
          Class Constructor specifying an array of Objects to form the model.
WidestStringComboBoxModel(Vector<?> v)
          Class Constructor specifying a vector of Objects to form the model.
 
Method Summary
 void addElement(Object anObject)
          Adds the given object to the model.
protected  String getLabel(Object anObject)
          Returns the String corresponding to the parameter object for use in calculating the width of popup required.
 String getWidest()
          Returns the longest display String for the objects in this model.
 void insertElementAt(Object anObject, int index)
          Inserts an object into the model at the given index.
 void removeAllElements()
          Removes all objects from the model.
 void removeElement(Object anObject)
          Removes the given object from the model.
 void removeElementAt(int index)
          Removes the object at the specified index from the model.
 void resetWidest()
          Invalidates the cached longest String.
 
Methods inherited from class javax.swing.DefaultComboBoxModel
getElementAt, getIndexOf, getSelectedItem, getSize, setSelectedItem
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

WidestStringComboBoxModel

public WidestStringComboBoxModel()
Class Constructor.


WidestStringComboBoxModel

public WidestStringComboBoxModel(Object[] items)
Class Constructor specifying an array of Objects to form the model.

Parameters:
items -

WidestStringComboBoxModel

public WidestStringComboBoxModel(Vector<?> v)
Class Constructor specifying a vector of Objects to form the model.

Parameters:
v -
Method Detail

addElement

public void addElement(Object anObject)
Adds the given object to the model. Additionally updates cached longest String.

Specified by:
addElement in interface MutableComboBoxModel
Overrides:
addElement in class DefaultComboBoxModel
Parameters:
anObject - the object to be added to the model

insertElementAt

public void insertElementAt(Object anObject,
                            int index)
Inserts an object into the model at the given index. Additionally updates cached longest String.

Specified by:
insertElementAt in interface MutableComboBoxModel
Overrides:
insertElementAt in class DefaultComboBoxModel
Parameters:
anObject - the object to be added to the model
index - the index at which the given object is to be added

removeAllElements

public void removeAllElements()
Removes all objects from the model. Additionally updates cached longest String.

Overrides:
removeAllElements in class DefaultComboBoxModel

removeElement

public void removeElement(Object anObject)
Removes the given object from the model. Additionally updates cached longest String.

Specified by:
removeElement in interface MutableComboBoxModel
Overrides:
removeElement in class DefaultComboBoxModel
Parameters:
anObject - the object to be removed from the model

removeElementAt

public void removeElementAt(int index)
Removes the object at the specified index from the model. Additionally updates cached longest String.

Specified by:
removeElementAt in interface MutableComboBoxModel
Overrides:
removeElementAt in class DefaultComboBoxModel

resetWidest

public void resetWidest()
Invalidates the cached longest String.

Specified by:
resetWidest in interface WidestStringProvider

getWidest

public String getWidest()
Returns the longest display String for the objects in this model. If the cached longest String is not valid, the longest String is determined and cached.

Specified by:
getWidest in interface WidestStringProvider
Returns:
the longest display String for the objects in this model

getLabel

protected String getLabel(Object anObject)
Returns the String corresponding to the parameter object for use in calculating the width of popup required. This method should be overridden when the toString method of whatever objects are stored in the model, doesn't return a suitable String. Should return an empty string when anObject == null.

Parameters:
anObject -
Returns:
the string that will be displayed for anObject. "" is returned when the passed object is null

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.