The Physiologist's Friend Simulation API

ch.unizh.ini.friend.gui
Class TangentScreen

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ch.unizh.ini.friend.gui.TangentScreen
All Implemented Interfaces:
SpikeListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class TangentScreen
extends JPanel
implements SpikeListener

Represents the plotting "tangent screen" -- the screen on which experimentalists display stimuli to characterize or measure cell responses.

The stimulus appears in this tangent screen. You set the stimulus using setStimulus(ch.unizh.ini.friend.stimulus.Stimulus). You set the simulation using setSimulationSetup(ch.unizh.ini.friend.simulation.SimulationSetup).

The Stimulus that is shown in the TangentScreen is scaled to the size of the screen to maintain an aspect ratio of 1:1. The minimum dimension of the TangentScrren sets the scaling of both x and y coordinates of the stimulus.

This component manages the popup menu for the selection of stimulus color, rotation, etc. It also handles the mouse wheel actions on the stimulus.

Version:
$Revision: 1.36 $
Author:
tobi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ColorChooser colorChooser
          Color-chooser to select the forground and background color of the (color) stimulus.
static float SCREEN_DIMENSION
          Dimension of tangent screen in our user (stimulus) coordinates.
 
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
TangentScreen(SimulationSetup simulationSetup)
          Creates new form TangentScreen.
 
Method Summary
 void addMarker()
          add a marker to the tangent screen
 void clearMarkers()
          clear all markers
 void clearSpikeImage()
          clears recorded spikes and markers
 int getSpikeMemoryDepth()
           
 Stimulus getStimulus()
          get the displayed stimulus
 boolean isPhotoreceptorsShown()
          are photoreceptor locations being shown?
 boolean isSpikeFadeEnabled()
           
 boolean isSpikeFillEnabled()
           
 boolean isStimulusControlEnabled()
          is mouse/keyboard control of stimulus enabled?
 void paintComponent(Graphics g)
          Draws the background and stimulus in the tangent screen.
 void refillFrame()
          resize this TangentScreen to fill the parent container
 void setPhotoreceptorsShown(boolean flag)
          enable showing the locations of the photoreceptors
 void setSimulationSetup(SimulationSetup setup)
          sets the SimulationSetup
 void setSpikeFadeEnabled(boolean fade)
           
 void setSpikeFillEnabled(boolean f)
           
 void setSpikeMemoryDepth(int n)
           
 void setStimulus(Stimulus s)
          set the stimulus displayed.
 void setStimulusControlEnabled(boolean f)
          set mouse/keyboard control of stimulus enabled
 void spikeOccurred(SpikeEvent e)
          called by spike source (SpikeReporter) when a spike is detected
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCREEN_DIMENSION

public static final float SCREEN_DIMENSION
Dimension of tangent screen in our user (stimulus) coordinates. Coordinates start at 0,0 in center of screen and increase upwards and to right. Limits are -SCREEN_DIMENSION and +SCREEN_DIMENSION in both x and y. The value of SCREEN_DIMENSION is 10.0f.

Even if the Panel is resized to a non-square size, the stimulus aspect ratio 1:1 is maintained.

See Also:
Constant Field Values

colorChooser

protected ColorChooser colorChooser
Color-chooser to select the forground and background color of the (color) stimulus.

Constructor Detail

TangentScreen

public TangentScreen(SimulationSetup simulationSetup)
Creates new form TangentScreen.

Parameters:
simulationSetup - the simulationSetup passed to FriendGUI
Method Detail

setSimulationSetup

public void setSimulationSetup(SimulationSetup setup)
sets the SimulationSetup

Parameters:
setup - the SimulationSetup

setStimulus

public void setStimulus(Stimulus s)
set the stimulus displayed. This method also disables and enables the foreground and background brightness menu items when the Stimulus is and is not an instance of ColorStimulus.

Parameters:
s - the Stimulus

getStimulus

public Stimulus getStimulus()
get the displayed stimulus

Returns:
the Stimulus

setPhotoreceptorsShown

public void setPhotoreceptorsShown(boolean flag)
enable showing the locations of the photoreceptors


isPhotoreceptorsShown

public boolean isPhotoreceptorsShown()
are photoreceptor locations being shown?


setStimulusControlEnabled

public void setStimulusControlEnabled(boolean f)
set mouse/keyboard control of stimulus enabled


isStimulusControlEnabled

public boolean isStimulusControlEnabled()
is mouse/keyboard control of stimulus enabled?


refillFrame

public void refillFrame()
resize this TangentScreen to fill the parent container


paintComponent

public void paintComponent(Graphics g)
Draws the background and stimulus in the tangent screen. You don't call this, it is called by the graphics pipeline automagically after repaint().

Overrides:
paintComponent in class JComponent

setSpikeMemoryDepth

public void setSpikeMemoryDepth(int n)
Parameters:
n - the number of spikes to display when recording

getSpikeMemoryDepth

public int getSpikeMemoryDepth()
Returns:
the number of spikes to display when recording

setSpikeFadeEnabled

public void setSpikeFadeEnabled(boolean fade)
Parameters:
fade - enables fading of spike-triggered stimuli

isSpikeFadeEnabled

public boolean isSpikeFadeEnabled()
Returns:
spike-triggered stimuli fading enabled

isSpikeFillEnabled

public boolean isSpikeFillEnabled()
Returns:
spike-triggered stimuli are filled in

setSpikeFillEnabled

public void setSpikeFillEnabled(boolean f)
Parameters:
f - filling in spike-triggered stimuli

addMarker

public void addMarker()
add a marker to the tangent screen


clearMarkers

public void clearMarkers()
clear all markers


spikeOccurred

public void spikeOccurred(SpikeEvent e)
called by spike source (SpikeReporter) when a spike is detected

Specified by:
spikeOccurred in interface SpikeListener
Parameters:
e - the spike event

clearSpikeImage

public void clearSpikeImage()
clears recorded spikes and markers


http://www.ini.unizh.ch/~tobi/friend