## Class fourchoice

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - fourchoice

- All Implemented Interfaces:
    java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, TestInterface

      public class fourchoice
      extends javax.swing.JPanel
      implements TestInterface, java.awt.event.KeyListener

  Fourchoice
  Data are saved to fourchoice-X.txt
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `fourchoice.DesignContainer` Contains the trials included in this design.
    `static class` | `fourchoice.Trial` This class resembles one trial of the study experiment.

    - ### Nested classes/interfaces inherited from class javax.swing.JPanel

      `javax.swing.JPanel.AccessibleJPanel`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `javax.swing.JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BOARDER_H` The boarder's height to help drawing boarder.
    `static int` | `BOARDER_W` The boarder's width to help drawing boarder.
    `int` | `currentTrial` The current trial number on going.
    `static boolean` | `debug` Debugmode: false - no debug, true - debug
    `static fourchoice.DesignContainer` | `design` design is the object of DesignContainer and holds the information and functions to do the actual test.
    `int` | `PRINT_CHOOSE_KEYS` Sentence starting with PRINT_ tells what mode the test is currently doing. Print the key selection-mode first
    `int` | `PRINT_GREETING` Sentence starting with PRINT_ tells what mode the test is currently doing. Print greeting is the mode when test starts and the greeting text is printed.
    `int` | `PRINT_TRIAL` Sentence starting with PRINT_ tells what mode the test is currently doing. If printMode is set to this the trial is shown and we'r waiting for user keypress.
    `int` | `printMode` This variable is the printMode which tells what phase the test is going through at the moment.
    `static int[]` | `quads` Different quad-markings
    `static int` | `repeats` Amount of repeats in the design
    `static int` | `SCREEN_H` Screen height
    `static int` | `SCREEN_W` Screen width
    `static java.lang.String` | `subjectGuy` Holds the subject-number.

    - ### 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

    Constructors
    Constructor and Description
    `fourchoice()` fourchoice class construcor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getRandomNumber(int range)` Generates a random number from given range.
    `static long` | `getScreenTimeMs()` Returns the screentime which is the time past after resetScreenTime() was called.
    `static long` | `getTestTimeMs()` Returns the test time which is the time past after resetTestTime() was called.
    `void` | `ghostWriter(java.lang.String str, int x, int y, int w, int h, java.awt.Graphics g)` Draws a text to screen into specified x,y position and the paragraph size For example "Thank you for taking part in the study" inthe middle.
    `void` | `keyPressed(java.awt.event.KeyEvent e)`
    `void` | `keyReleased(java.awt.event.KeyEvent e)`
    `void` | `keyTyped(java.awt.event.KeyEvent e)`
    `void` | `paint(java.awt.Graphics g)` This function draws according the current situation of the test.
    `static void` | `resetScreenTime()` Resets screen time.
    `static void` | `resetTestTime()` Resets test time.
    `static void` | `runTest(java.lang.String subjectNumber)` Nothing overwhelming..

    - ### 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, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, 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, 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, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### debug

          public static boolean debug

      Debugmode: false - no debug, true - debug

    - #### SCREEN_W

          public static int SCREEN_W

      Screen width

    - #### SCREEN_H

          public static int SCREEN_H

      Screen height

    - #### BOARDER_W

          public static int BOARDER_W

      The boarder's width to help drawing boarder.

    - #### BOARDER_H

          public static int BOARDER_H

      The boarder's height to help drawing boarder.

    - #### PRINT_CHOOSE_KEYS

          public int PRINT_CHOOSE_KEYS

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      Print the key selection-mode first
      See Also:
        `printMode`

    - #### PRINT_GREETING

          public int PRINT_GREETING

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      Print greeting is the mode when test starts and the greeting text is printed.
      See Also:
        `printMode`

    - #### PRINT_TRIAL

          public int PRINT_TRIAL

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      If printMode is set to this the trial is shown and we'r waiting for user keypress.
      See Also:
        `printMode`

    - #### currentTrial

          public int currentTrial

      The current trial number on going. ie. it can be from 0 to 180.

    - #### printMode

          public int printMode

      This variable is the printMode which tells what phase the test is going through at the moment.
      See Also:
        `PRINT_TRIAL`

    - #### repeats

          public static int repeats

      Amount of repeats in the design

    - #### quads

          public static int[] quads

      Different quad-markings

    - #### subjectGuy

          public static java.lang.String subjectGuy

      Holds the subject-number.

    - #### design

          public static fourchoice.DesignContainer design

      design is the object of DesignContainer and holds the information and functions to do the actual test.

  - ### Constructor Detail

    - #### fourchoice

          public fourchoice()

      fourchoice class construcor. Keypresses are captured wheeeere?
      See Also:
        `MouseAdapter`

  - ### Method Detail

    - #### getRandomNumber

          public static int getRandomNumber(int range)

      Generates a random number from given range.
      Parameters:
        `range` - which should be positive number ie. 100
      Returns:
        Randomly generated number from range ie. 0-100

    - #### runTest

          public static void runTest(java.lang.String subjectNumber)

      Nothing overwhelming.. Start function for the test. Subject number will be given also via this. The test-file is started to write in this function as also the design object which is DesignContainer's object will be set up here. This function should be called when starting the test and the subject's number is known. This is called from the start menu.
      Parameters:
        `subjectNumber` - subject's individual number
      See Also:
        `Thread`

    - #### resetScreenTime

          public static void resetScreenTime()

      Resets screen time. Should be called when the time taking starts. For example when trial starts each time.
      See Also:
        `getScreenTimeMs()`, `resetTestTime()`, `getTestTimeMs()`

    - #### getScreenTimeMs

          public static long getScreenTimeMs()

      Returns the screentime which is the time past after resetScreenTime() was called. For example get the time of last trial.
      Returns:
        the time in milliseconds after resetScreenTime() was called.
      See Also:
        `resetScreenTime()`, `resetTestTime()`, `getTestTimeMs()`

    - #### resetTestTime

          public static void resetTestTime()

      Resets test time. Should be used right after the total test begins.
      See Also:
        `getScreenTimeMs()`, `resetScreenTime()`, `getTestTimeMs()`

    - #### getTestTimeMs

          public static long getTestTimeMs()

      Returns the test time which is the time past after resetTestTime() was called. For example get the time when person started doing the test.
      Returns:
        the time in milliseconds after resetTestTime() was called.
      See Also:
        `resetScreenTime()`, `resetTestTime()`, `getScreenTimeMs()`

    - #### paint

          public void paint(java.awt.Graphics g)

      This function draws according the current situation of the test. The drawn window is managed with global printMode-attribute. printMode attribute is changed according the time and user input. Some draw functions are used from the current All drawing is done here.
      Overrides:
        `paint` in class `javax.swing.JComponent`
      Parameters:
        `g` - The Graphics to draw.
      See Also:
        `printMode`

    - #### ghostWriter

          public void ghostWriter(java.lang.String str,
                         int x,
                         int y,
                         int w,
                         int h,
                         java.awt.Graphics g)

      Draws a text to screen into specified x,y position and the paragraph size For example "Thank you for taking part in the study" inthe middle. Text is printed in a reader friendly way and not cutted stupidly..
      Parameters:
        `str` - String that contains the text to print.
        `x` - The starting X-position of text to print.
        `y` - The starting Y-position of text to print.
        `w` - The width of the area for printing.
        `h` - The heigth of the text-area.
        `g` - This holds the graphic-class where text is drawn.
      See Also:
        `Graphics`

    - #### keyPressed

          public void keyPressed(java.awt.event.KeyEvent e)

      Specified by:
        `keyPressed` in interface `java.awt.event.KeyListener`

    - #### keyReleased

          public void keyReleased(java.awt.event.KeyEvent e)

      Specified by:
        `keyReleased` in interface `java.awt.event.KeyListener`

    - #### keyTyped

          public void keyTyped(java.awt.event.KeyEvent e)

      Specified by:
        `keyTyped` in interface `java.awt.event.KeyListener`