## Class vsearch

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

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

      public class vsearch
      extends javax.swing.JPanel
      implements TestInterface

  Visual search test for little pebl clone
  v0.7
  Test runs on design which can be changed from parameters
  Target Char X | O
  Target Color Green | White
  Size 10 | 20 | 30
  Targets 0 | 1 | 5
  Repeats 5
  combinations(target,color,size,targets) = 2*2*3*3*5
  = 180 trials
  debug value false/true if debug-printing is neccessary.
  results are saved into resultX.txt (X is the subject number
  given by main window)
  6.3.2012 Graphical interface and basic idea ready v0.1
  7.3.2012 More Graphical interface and class structures v0.2
  8.3.2012 Class structures and scenario setting v0.4
  9.3.2012 First working clone version v0.6
  9.3.2012 Results saving is available v0.7
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `vsearch.DesignContainer` Contains the trials included in this design.
    `static class` | `vsearch.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 which tells how far from the edge the symbols are placed.
    `static int` | `BOARDER_W` The boarder's width which tells how far from the edge the symbols are placed.
    `static int` | `BREAK_INTERVAL` The amount of trials which is followed by a break window.
    `static java.lang.String[]` | `colors` Different colors to use in test, default {"white","green"}
    `int` | `currentTrial` The current trial number on going.
    `static boolean` | `debug` Debugmode: false - no debug, true - debug
    `static vsearch.DesignContainer` | `design` design is the object of DesignContainer and holds the information and functions to do the actual test.
    `static java.lang.String[]` | `foils` Different kinds of foils to use in trials ie.
    `static boolean` | `mClicksor` Takes care that mouse press won't piss on next window..
    `static int` | `POINT_FINDER_LOOP_LOAD` How many times the algorithm tries to generate new point for each symbol.
    `int` | `PRINT_BREAK` Sentence starting with PRINT_ tells what mode the test is currently doing. if printMode is set to this the program draws break-text and waits till the user is ready.
    `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_OUTRO` Sentence starting with PRINT_ tells what mode the test is currently doing. if printMode is set to this the program draws outro text to mark the end of the test.
    `int` | `PRINT_SEARCH_SET` Sentence starting with PRINT_ tells what mode the test is currently doing. if printMode is set to this it brings the trial to be shown so that user can search target.
    `int` | `PRINT_SEARCH_TARGET` Sentence starting with PRINT_ tells what mode the test is currently doing. If printMode is set to this the target will be shown for the user for a period of time to help him recognize what must be searched next.
    `int` | `PRINT_SEARCH_WAIT_REPLAY` Sentence starting with PRINT_ tells what mode the test is currently doing. if printMode is set to this the program will wait until user chooses his answer from the circles.
    `int` | `printMode` This variable is the printMode which tells what phase the test is going through at the moment.
    `static int` | `repeats` Amount of repeats in the design
    `static java.awt.Robot` | `robot` Robot class for moving mouse to center without user's effort..
    `static int` | `SCREEN_H` Screen height
    `static int` | `SCREEN_W` Screen width
    `int` | `SHOW_TARGET_WAIT_TIME` How long the target is shown in the middle of screen before the current actual trial is shown.
    `static int[]` | `sizes` Different sizes of various trials.
    `static java.lang.String` | `subjectGuy` Holds the subject-number.
    `static java.lang.String[]` | `targChars` Target characters ie.
    `static int[]` | `targets` Amount of targets in trials.

    - ### 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
    `vsearch()` vSearch class construcor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static double` | `distance(double x1, double y1, double x2, double y2)` This function tells the distance between two points.
    `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` | `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

    - #### POINT_FINDER_LOOP_LOAD

          public static int POINT_FINDER_LOOP_LOAD

      How many times the algorithm tries to generate new point for each symbol. It chooses the best distance anyway.

    - #### 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 which tells how far from the edge the symbols are placed. This makes the random area smaller or bigger.

    - #### BOARDER_H

          public static int BOARDER_H

      The boarder's height which tells how far from the edge the symbols are placed. This makes the random area smaller or bigger.

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

          public int PRINT_SEARCH_TARGET

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      If printMode is set to this the target will be shown for the user for a period of time to help him recognize what must be searched next.
      See Also:
        `printMode`

    - #### PRINT_SEARCH_SET

          public int PRINT_SEARCH_SET

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      if printMode is set to this it brings the trial to be shown so that user can search target.
      See Also:
        `printMode`

    - #### PRINT_SEARCH_WAIT_REPLAY

          public int PRINT_SEARCH_WAIT_REPLAY

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      if printMode is set to this the program will wait until user chooses his answer from the circles.
      See Also:
        `printMode`

    - #### PRINT_BREAK

          public int PRINT_BREAK

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      if printMode is set to this the program draws break-text and waits till the user is ready.
      See Also:
        `printMode`

    - #### PRINT_OUTRO

          public int PRINT_OUTRO

      Sentence starting with PRINT_ tells what mode the test is currently doing.
      if printMode is set to this the program draws outro text to mark the end of the test.
      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_GREETING`, `PRINT_SEARCH_TARGET`, `PRINT_SEARCH_SET`, `PRINT_SEARCH_WAIT_REPLAY`, `PRINT_BREAK`, `PRINT_OUTRO`

    - #### robot

          public static java.awt.Robot robot

      Robot class for moving mouse to center without user's effort..

    - #### mClicksor

          public static boolean mClicksor

      Takes care that mouse press won't piss on next window..

    - #### repeats

          public static int repeats

      Amount of repeats in the design

    - #### targChars

          public static java.lang.String[] targChars

      Target characters ie. {"X","O"}

    - #### colors

          public static java.lang.String[] colors

      Different colors to use in test, default {"white","green"}

    - #### sizes

          public static int[] sizes

      Different sizes of various trials.

    - #### targets

          public static int[] targets

      Amount of targets in trials.

    - #### foils

          public static java.lang.String[] foils

      Different kinds of foils to use in trials ie. letters {"U","D","G","C","Q"}

    - #### BREAK_INTERVAL

          public static int BREAK_INTERVAL

      The amount of trials which is followed by a break window.

    - #### SHOW_TARGET_WAIT_TIME

          public int SHOW_TARGET_WAIT_TIME

      How long the target is shown in the middle of screen before the current actual trial is shown.

    - #### subjectGuy

          public static java.lang.String subjectGuy

      Holds the subject-number.

    - #### design

          public static vsearch.DesignContainer design

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

  - ### Constructor Detail

    - #### vsearch

          public vsearch()

      vSearch class construcor. Mouse listener and user's mouse events and timing settings. If need to change events happened after mouse clicks you're in right place.
      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

    - #### distance

          public static double distance(double x1,
                        double y1,
                        double x2,
                        double y2)

      This function tells the distance between two points. Here it's used mostly for recognizing if the user clicked on symbol. In this case the input is mouse coordinates and symbol's coordinates.
      Parameters:
        `x1` - X-coordinate of point1 as double.
        `y1` - Y-coordinate of point1 as double.
        `x2` - X-coordinate of point2 as double.
        `y2` - Y-coordinate of point2 as double.
      Returns:
        The distance between points as double.

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