|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.buffalo.fs7.qsymbol2.QubitSelectionModel
This class copies a lot of the code of the original DefaultListSelectionModel. It is not necessarily the fine art of object oriented programming, but since the DefaultListSelectionModel declares a lot of the methods and variables private, that was the simplest way to extend the model to "remember" the order of the selection process as needed to encode the gates interactively.
Basically, what was added is a PriorityQueue to keep track of the selection order. The method getIndicesByPriority() returns the indices in the order of selection.
PriorityQueue,
ListSelectionModel, Serialized Form| Field Summary | |
protected boolean |
leadAnchorNotificationEnabled
|
protected javax.swing.event.EventListenerList |
listenerList
|
protected PriorityQueue |
priorityQueue
|
| Fields inherited from interface javax.swing.ListSelectionModel |
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION |
| Constructor Summary | |
QubitSelectionModel()
|
|
| Method Summary | |
void |
addListSelectionListener(javax.swing.event.ListSelectionListener l)
|
void |
addSelectionInterval(int index0,
int index1)
|
void |
clearSelection()
|
java.lang.Object |
clone()
Returns a clone of this selection model with the same selection. |
protected void |
fireValueChanged(boolean isAdjusting)
Notifies listeners that we have ended a series of adjustments. |
protected void |
fireValueChanged(int firstIndex,
int lastIndex)
Notifies ListSelectionListeners that the value
of the selection, in the closed interval firstIndex,
lastIndex, has changed. |
protected void |
fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
|
int |
getAnchorSelectionIndex()
|
java.util.Vector |
getIndicesByPriority()
returns the selection as a vector of Integers. |
int |
getLeadSelectionIndex()
|
java.util.EventListener[] |
getListeners(java.lang.Class listenerType)
Returns an array of all the listeners of the given type that were added to this model. |
int |
getMaxSelectionIndex()
|
int |
getMinSelectionIndex()
|
int |
getSelectionMode()
Returns the selection mode. |
boolean |
getValueIsAdjusting()
|
void |
insertIndexInterval(int index,
int length,
boolean before)
Insert length indices beginning before/after index. |
boolean |
isLeadAnchorNotificationEnabled()
Returns the value of the leadAnchorNotificationEnabled flag.
|
boolean |
isSelectedIndex(int index)
|
boolean |
isSelectionEmpty()
|
void |
removeIndexInterval(int index0,
int index1)
Remove the indices in the interval index0,index1 (inclusive) from the selection model. |
void |
removeListSelectionListener(javax.swing.event.ListSelectionListener l)
|
void |
removeSelectionInterval(int index0,
int index1)
|
void |
setAnchorSelectionIndex(int anchorIndex)
Set the anchor selection index, leaving all selection values unchanged. |
void |
setLeadAnchorNotificationEnabled(boolean flag)
Sets the value of the leadAnchorNotificationEnabled flag. |
void |
setLeadSelectionIndex(int leadIndex)
Sets the lead selection index, ensuring that values between the anchor and the new lead are either all selected or all deselected. |
void |
setSelectionInterval(int index0,
int index1)
|
void |
setSelectionMode(int selectionMode)
Sets the selection mode. |
void |
setValueIsAdjusting(boolean isAdjusting)
|
java.lang.String |
toString()
Returns a string that displays and identifies this object's properties. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected javax.swing.event.EventListenerList listenerList
protected boolean leadAnchorNotificationEnabled
protected PriorityQueue priorityQueue
| Constructor Detail |
public QubitSelectionModel()
| Method Detail |
public int getMinSelectionIndex()
getMinSelectionIndex in interface javax.swing.ListSelectionModelpublic int getMaxSelectionIndex()
getMaxSelectionIndex in interface javax.swing.ListSelectionModelpublic boolean getValueIsAdjusting()
getValueIsAdjusting in interface javax.swing.ListSelectionModelpublic int getSelectionMode()
getSelectionMode in interface javax.swing.ListSelectionModelgetSelectionMode()public void setSelectionMode(int selectionMode)
setSelectionMode in interface javax.swing.ListSelectionModelselectionMode - one of three values:
java.lang.IllegalArgumentException - if selectionMode
is not one of the legal values shown abovesetSelectionMode(int)public boolean isSelectedIndex(int index)
isSelectedIndex in interface javax.swing.ListSelectionModelpublic boolean isSelectionEmpty()
isSelectionEmpty in interface javax.swing.ListSelectionModelpublic void addListSelectionListener(javax.swing.event.ListSelectionListener l)
addListSelectionListener in interface javax.swing.ListSelectionModelpublic void removeListSelectionListener(javax.swing.event.ListSelectionListener l)
removeListSelectionListener in interface javax.swing.ListSelectionModelprotected void fireValueChanged(boolean isAdjusting)
protected void fireValueChanged(int firstIndex,
int lastIndex)
ListSelectionListeners that the value
of the selection, in the closed interval firstIndex,
lastIndex, has changed.
protected void fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
firstIndex - the first index in the intervallastIndex - the last index in the intervalisAdjusting - true if this is the final change in a series of
adjustmentsEventListenerListpublic java.util.EventListener[] getListeners(java.lang.Class listenerType)
public void setLeadAnchorNotificationEnabled(boolean flag)
isLeadAnchorNotificationEnabled()public boolean isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled flag.
When leadAnchorNotificationEnabled is true the model
generates notification events with bounds that cover all the changes to
the selection plus the changes to the lead and anchor indices.
Setting the flag to false causes a narrowing of the event's bounds to
include only the elements that have been selected or deselected since
the last change. Either way, the model continues to maintain the lead
and anchor variables internally. The default is true.leadAnchorNotificationEnabled flagsetLeadAnchorNotificationEnabled(boolean)public void clearSelection()
clearSelection in interface javax.swing.ListSelectionModel
public void setSelectionInterval(int index0,
int index1)
setSelectionInterval in interface javax.swing.ListSelectionModel
public void addSelectionInterval(int index0,
int index1)
addSelectionInterval in interface javax.swing.ListSelectionModel
public void removeSelectionInterval(int index0,
int index1)
removeSelectionInterval in interface javax.swing.ListSelectionModel
public void insertIndexInterval(int index,
int length,
boolean before)
insertIndexInterval in interface javax.swing.ListSelectionModel
public void removeIndexInterval(int index0,
int index1)
removeIndexInterval in interface javax.swing.ListSelectionModelpublic void setValueIsAdjusting(boolean isAdjusting)
setValueIsAdjusting in interface javax.swing.ListSelectionModelpublic java.lang.String toString()
toString in class java.lang.ObjectString representation of this object
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
listenerLists are not duplicated.clone in class java.lang.Objectjava.lang.CloneNotSupportedException - if the selection model does not
both (a) implement the Cloneable interface and (b) define a
clone method.public int getAnchorSelectionIndex()
getAnchorSelectionIndex in interface javax.swing.ListSelectionModelpublic int getLeadSelectionIndex()
getLeadSelectionIndex in interface javax.swing.ListSelectionModelpublic void setAnchorSelectionIndex(int anchorIndex)
setAnchorSelectionIndex in interface javax.swing.ListSelectionModelgetAnchorSelectionIndex(),
setLeadSelectionIndex(int)public void setLeadSelectionIndex(int leadIndex)
If the value at the anchor index is not selected, do the same thing in reverse selecting values in the old range and deslecting values in the new one.
Generate a single event for this change and notify all listeners. For the purposes of generating minimal bounds in this event, do the operation in a single pass; that way the first and last index inside the ListSelectionEvent that is broadcast will refer to cells that actually changed value because of this method. If, instead, this operation were done in two steps the effect on the selection state would be the same but two events would be generated and the bounds around the changed values would be wider, including cells that had been first cleared only to later be set.
This method can be used in the mouseDragged method
of a UI class to extend a selection.
setLeadSelectionIndex in interface javax.swing.ListSelectionModelgetLeadSelectionIndex(),
setAnchorSelectionIndex(int)public java.util.Vector getIndicesByPriority()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||