edu.buffalo.fs7.qsymbol2
Class GateTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--edu.buffalo.fs7.qsymbol2.GateTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class GateTableModel
extends javax.swing.table.AbstractTableModel

This class holds the actual quantum circuit. Gates are represented by GateContainer objects to allow gate groups. The actual gate information is stored in a mathlib variable of the type Gate and each GateContainer has a reference to a Gate variable. The GateTableModel does not autonomously react to MathlibEvents, but rather the GateTable class is taking care of this.

See Also:
GateTable, GateTableColumnModel, GateContainer, Gate, Serialized Form

Field Summary
protected  java.util.Vector gateContainers
          holds names of gate variables
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
GateTableModel()
          creates a GateTableModel.
 
Method Summary
 void addGateContainer(GateContainer gateContainer)
          adds a GateContainer to the GateTableModel
 void addQubit()
          adds a qubit by adding a '-' to the gate_descr of each gate contained by the gateContainers in this model.
 boolean contains(GateContainer gateContainer)
          checks whether a given gateContainer is contained by the GateTableModel
 java.lang.Class getColumnClass(int c)
          returns always the GateContainer class
 int getColumnCount()
          gets the number of top level gateContainers (= column count)
 java.lang.String getColumnName(int column)
          returns the top level name of the gateContainer in column column
 GateContainer getGateContainer(java.lang.String name)
          returns the gateContainer with the given name, null otherwise
 int getRowCount()
          returns the dimension of the gates (= qubit number)
 java.lang.Object getValueAt(int row, int col)
          returns the gateContainer in the model which corresponds to the column the paramter row is ignored.
 boolean isCellEditable(int row, int col)
          returns true if the cell is a preparation operation
 void moveQubit(int fromRow, int toRow)
          moves a qubit by exchanging the charakters in the gate_descr for each gateContainer
 void removeGateContainer(GateContainer gateContainer)
          removes a given gateContainer
 void removeGateContainer(int column)
          removes a given gateContainer
 void removeQubit(int row)
          remove a qubit, i.e. for each gateContainer in the model the gate_descr is modiefied.
 void setValueAt(java.lang.Object value, int row, int col)
          method is called in the process of editing a cell.
 void tableUpdated()
          wraps the fireTableDataChanged() method....
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gateContainers

protected java.util.Vector gateContainers
holds names of gate variables
Constructor Detail

GateTableModel

public GateTableModel()
creates a GateTableModel. A gate is represented by a GateContainer. The GateContainers are saved in an internal vector, but the gates themselves are Gate objects represented by a variable in the Mathlib class.
Method Detail

addGateContainer

public void addGateContainer(GateContainer gateContainer)
adds a GateContainer to the GateTableModel
Parameters:
gateContainer - the gateContainer object to add

getColumnCount

public int getColumnCount()
gets the number of top level gateContainers (= column count)
Overrides:
getColumnCount in class javax.swing.table.AbstractTableModel

getRowCount

public int getRowCount()
returns the dimension of the gates (= qubit number)
Overrides:
getRowCount in class javax.swing.table.AbstractTableModel

getColumnClass

public java.lang.Class getColumnClass(int c)
returns always the GateContainer class
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel

getColumnName

public java.lang.String getColumnName(int column)
returns the top level name of the gateContainer in column column
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
returns the gateContainer in the model which corresponds to the column the paramter row is ignored.
Overrides:
getValueAt in class javax.swing.table.AbstractTableModel

getGateContainer

public GateContainer getGateContainer(java.lang.String name)
returns the gateContainer with the given name, null otherwise

isCellEditable

public boolean isCellEditable(int row,
                              int col)
returns true if the cell is a preparation operation
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
method is called in the process of editing a cell. It only is invoked for the preparation operation
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

contains

public boolean contains(GateContainer gateContainer)
checks whether a given gateContainer is contained by the GateTableModel

removeGateContainer

public void removeGateContainer(GateContainer gateContainer)
removes a given gateContainer

removeGateContainer

public void removeGateContainer(int column)
removes a given gateContainer

removeQubit

public void removeQubit(int row)
remove a qubit, i.e. for each gateContainer in the model the gate_descr is modiefied. A plausibility check is run afterwards.

moveQubit

public void moveQubit(int fromRow,
                      int toRow)
moves a qubit by exchanging the charakters in the gate_descr for each gateContainer

addQubit

public void addQubit()
adds a qubit by adding a '-' to the gate_descr of each gate contained by the gateContainers in this model.

tableUpdated

public void tableUpdated()
wraps the fireTableDataChanged() method....