edu.buffalo.fs7.qsymbol2
Class GatePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.buffalo.fs7.qsymbol2.GatePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, MathlibEventListener, java.awt.MenuContainer, java.io.Serializable

public class GatePanel
extends javax.swing.JPanel
implements java.awt.event.ComponentListener, java.awt.event.ItemListener, java.awt.event.ActionListener, MathlibEventListener

The GatePanel class is the central class in the qsymbol2 package. It is responsible to bring up a quantum circuit (provided by the GateTable class) with qubit controls, step gauge and computation controls. Basically, everything you see besides the toolbar in the jaQuzzi program is provided by this class.

This class is responsible to add and remove qubits (since it has to update the GateTable as well as the QubitPanel) and therefore implements the MathlibEventListener interface.

It as well implements other interfaces to react to changes in the GateTable or QubitPanel.

See Also:
GateTable, QubitPanel, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String avgTimePerGate
          string constant for averageTimerperGate property
protected  java.awt.GridBagConstraints c
           
protected  boolean calcFidelity
          true if the fidelity is to be calculated
static java.lang.String elapsedTime
          string constant for elapsed time property
static java.lang.String fidelity
          string constant for fidelity property
 GateTable gates
          the GateTable
protected  java.awt.GridBagLayout gridbag
           
 QubitPanel inQubits
          holds the qubitPanel for setting init values to the qubits
protected  Mathlib mathlib
          the mathlib
protected  javax.swing.JProgressBar progressBar
           
static java.lang.String qubits
          string constant for qubits variable
static java.lang.String qubitUpdate
          string constant for qubitUpdate property
protected  boolean quietMode
          true if the graphical output is should be supressed
static java.lang.String refQubits
          string constant for second qubits variable in case of calculating fidelity
static java.lang.String remainingTimeEstimate
          string constant for remainingTimeEstimate property
protected  boolean run
          true if a computation thread is running
protected  javax.swing.JButton runButton
           
protected  javax.swing.JLabel statusBar
           
protected  javax.swing.JLabel statusBarLabel
           
static java.lang.String step
          string constant for step property
static java.lang.String stepCount
          string constant for stepCount property
static java.lang.String table
          string constant for table property
protected  javax.swing.JScrollPane viewPort
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GatePanel(Mathlib mathlib, boolean quietMode)
          create a GatePanel class.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          method of the ActionListener interface.
 void addGateContainer()
          generates an add gateContainer event which causes the GatePanel class to modify the GateTable.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          wrapping method
 void addQubit()
          generates an add qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable.
 void addVariable(MathlibEvent e)
          method of the MathlibEventListener interface.
 void adjustRowHeight()
          adjusts the row height so that all qubits fit into the panel.
 void changeVariable(MathlibEvent e)
          method of the MathlibEventListener interface.
 void componentHidden(java.awt.event.ComponentEvent e)
          implementing ComponentListener interface. nothing is done here.
 void componentMoved(java.awt.event.ComponentEvent e)
          implementing ComponentListener interface. nothing is done here.
 void componentResized(java.awt.event.ComponentEvent e)
          implementing ComponentListener interface.
 void componentShown(java.awt.event.ComponentEvent e)
          implementing ComponentListener interface. nothing is done here.
protected  javax.swing.JToolBar createToolbar2()
          creates the computation controll toolbar
 void decreaseColumnWidth()
          method to decrease the column width of the columns in the GateTable.
protected  void fireTimingProperties()
          update the timing properties.
 double getCircuitProperty(java.lang.String property)
          this method retrieves information from a GateProperty object named "circuit_properties" kept as a variable in the mathlib class.
 void increaseColumnWidth()
          method to increase the column width of the columns in the GateTable.
 void insertGateContainer(int col)
          generates an insert gateContainer event which causes the GatePanel class to modify the GateTable.
 void insertQubit(int row)
          generates an insert qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable.
 void itemStateChanged(java.awt.event.ItemEvent e)
          method of the ItemListener interface.
 void qubitUpdate()
          updates the statusbar and sets the icon for the computation control panel correctly.
 void removeGateContainer(int col)
          generates a remove gateContainer event which causes the GatePanel class to modify the GateTable.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          wrapping method
 void removeQubit(int row)
          generates an remove qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable.
 void removeVariable(MathlibEvent e)
          method of the MathlibEventListener interface.
 void renameGateContainer(int col, java.lang.String newName)
          generates a rename gateContainer event which causes the GatePanel class to modify the GateTable.
 void reset()
          resets the gatePanel and the computation
 void resize()
          is a workaround for JAVA bug 4226181, but I think it is not used anymore in the application.
 void run()
          runs a computation.
 void setCircuitProperty(java.lang.String property, double value)
          sets a property to a GateProperty object "circuit_properties" kept as a variable in the mathlib class.
 void setFidelity(boolean calcFidelity)
          method sets whether the fidelity of during a calculation should be calculated or not.
 void stepBackward()
          wraps the stepBackward method of the GateTable class.
 void stepForward()
          wraps the stepForward method of the GateTable class.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

qubits

public static final java.lang.String qubits
string constant for qubits variable

refQubits

public static final java.lang.String refQubits
string constant for second qubits variable in case of calculating fidelity

fidelity

public static final java.lang.String fidelity
string constant for fidelity property

elapsedTime

public static final java.lang.String elapsedTime
string constant for elapsed time property

step

public static final java.lang.String step
string constant for step property

stepCount

public static final java.lang.String stepCount
string constant for stepCount property

avgTimePerGate

public static final java.lang.String avgTimePerGate
string constant for averageTimerperGate property

remainingTimeEstimate

public static final java.lang.String remainingTimeEstimate
string constant for remainingTimeEstimate property

table

public static final java.lang.String table
string constant for table property

qubitUpdate

public static final java.lang.String qubitUpdate
string constant for qubitUpdate property

gridbag

protected java.awt.GridBagLayout gridbag

c

protected java.awt.GridBagConstraints c

inQubits

public QubitPanel inQubits
holds the qubitPanel for setting init values to the qubits

statusBarLabel

protected javax.swing.JLabel statusBarLabel

statusBar

protected javax.swing.JLabel statusBar

runButton

protected javax.swing.JButton runButton

run

protected boolean run
true if a computation thread is running

calcFidelity

protected boolean calcFidelity
true if the fidelity is to be calculated

progressBar

protected javax.swing.JProgressBar progressBar

viewPort

protected javax.swing.JScrollPane viewPort

gates

public GateTable gates
the GateTable

mathlib

protected Mathlib mathlib
the mathlib

quietMode

protected boolean quietMode
true if the graphical output is should be supressed
Constructor Detail

GatePanel

public GatePanel(Mathlib mathlib,
                 boolean quietMode)
create a GatePanel class. A mathlib object needs to be provides as well as the operation mode.
Method Detail

createToolbar2

protected javax.swing.JToolBar createToolbar2()
creates the computation controll toolbar

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
implementing ComponentListener interface. nothing is done here.
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
implementing ComponentListener interface. nothing is done here.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
implementing ComponentListener interface. nothing is done here.
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
implementing ComponentListener interface. The row height is adjusted to fit the qubits into the window.
Specified by:
componentResized in interface java.awt.event.ComponentListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
method of the ItemListener interface. This is implemented to react to changes of the qubit controls.
Specified by:
itemStateChanged in interface java.awt.event.ItemListener
See Also:
QubitPanel

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
method of the ActionListener interface. Here, the computation control center events are processed.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

run

public void run()
runs a computation. Depending on the operation mode, a thread is started or the comutation is done linearly.
See Also:
GateTable.gotoStep(Braket, Braket, int)

getCircuitProperty

public double getCircuitProperty(java.lang.String property)
this method retrieves information from a GateProperty object named "circuit_properties" kept as a variable in the mathlib class. It returns null if the desired property is not specified. This method applies only to properties of numerical value.
Parameters:
property - name of the property, e.g. "mode"
Returns:
double value

setCircuitProperty

public void setCircuitProperty(java.lang.String property,
                               double value)
sets a property to a GateProperty object "circuit_properties" kept as a variable in the mathlib class. It creates the variable if necessary. This method only applies to numerical properties.

stepForward

public void stepForward()
wraps the stepForward method of the GateTable class. This is done to obtain more precise timing information in case of interactive stepping (graphics require more time).
See Also:
GateTable.stepForward(Braket, Braket)

stepBackward

public void stepBackward()
wraps the stepBackward method of the GateTable class. This is done to obtain more precise timing information in case of interactive stepping (graphics require more time).
See Also:
GateTable.stepBackward(Braket, Braket)

setFidelity

public void setFidelity(boolean calcFidelity)
method sets whether the fidelity of during a calculation should be calculated or not. If the boolean parameter is set to true, an additional Braket object is created in order to provide the possibility to calculate the ideal state and the non-ideal state at the same time.

addQubit

public void addQubit()
generates an add qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable. This method is the preferred method to add a qubit

insertQubit

public void insertQubit(int row)
generates an insert qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable. This method is the preferred method to inesert a qubit.

removeQubit

public void removeQubit(int row)
generates an remove qubit event which causes the GatePanel class to modify the QubitPanel and the GateTable. This method is the preferred method to remove a qubit.

insertGateContainer

public void insertGateContainer(int col)
generates an insert gateContainer event which causes the GatePanel class to modify the GateTable. This method is the preferred method to insert a gateContainer.

addGateContainer

public void addGateContainer()
generates an add gateContainer event which causes the GatePanel class to modify the GateTable. This method is the preferred method to add a gateContainer.

removeGateContainer

public void removeGateContainer(int col)
generates a remove gateContainer event which causes the GatePanel class to modify the GateTable. This method is the preferred method to remove a gateContainer.

renameGateContainer

public void renameGateContainer(int col,
                                java.lang.String newName)
generates a rename gateContainer event which causes the GatePanel class to modify the GateTable. This method is the preferred method to rename a gateContainer. Renaming is quite complex since the renaming of a gate group requires the renaming of all the contained gate variables.

addVariable

public void addVariable(MathlibEvent e)
method of the MathlibEventListener interface. This method reacts to an add qubit event.
Specified by:
addVariable in interface MathlibEventListener

changeVariable

public void changeVariable(MathlibEvent e)
method of the MathlibEventListener interface. This method reacts to an change qubit event.
Specified by:
changeVariable in interface MathlibEventListener

removeVariable

public void removeVariable(MathlibEvent e)
method of the MathlibEventListener interface. This method reacts to an remove qubit event.
Specified by:
removeVariable in interface MathlibEventListener

increaseColumnWidth

public void increaseColumnWidth()
method to increase the column width of the columns in the GateTable. It also adjusts the width of the TexQBrick class.

decreaseColumnWidth

public void decreaseColumnWidth()
method to decrease the column width of the columns in the GateTable. It also adjusts the width of the TexQBrick class.

adjustRowHeight

public void adjustRowHeight()
adjusts the row height so that all qubits fit into the panel.

resize

public void resize()
is a workaround for JAVA bug 4226181, but I think it is not used anymore in the application.

reset

public void reset()
resets the gatePanel and the computation

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
wrapping method
Overrides:
addPropertyChangeListener in class javax.swing.JComponent

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
wrapping method
Overrides:
removePropertyChangeListener in class javax.swing.JComponent

fireTimingProperties

protected void fireTimingProperties()
update the timing properties.

qubitUpdate

public void qubitUpdate()
updates the statusbar and sets the icon for the computation control panel correctly.