|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Frame javax.swing.JFrame psychWithJava.FullScreen
public class FullScreen
FullScreen
class provides methods to display visual stimuli
and interact with the observer in full screen exclusive mode (FSEM).
FullScreen
is capable of chosing the best available display
mode and
strategy on a particular software (OS) and hardware. By default the
user does not
have to change any of these strategies. However it provides
methods for expert users who wish to modify those strategies. Requires Java
SE 5.0 or higher.
Methods provided include: displayImage()
to display images,
displayText()
to display text, and
getKeyPressed()
to get observer's keyboard responses. Because it
is inherited from the Java core class JFrame
, all its methods
are available, such as setForeground()
.
See Psychophysics Programming with Java for more information and sample demo programs.
FullScreen
class utilizes the
Full screen exclusive mode (FSEM) is a feature of Java (after J2SE 1.4)
that allows
programmers to suspend the windowing system of the underlying OS, and
directly access the video card and draw on the screen. If exclusive full
screen is not supported, a regular window is positioned at upper left corner
(0,0) and resized
to fit the whole screen to mimic full screen exclusive mode. Whether in full
screen exclusive mode or not, FullScreen
uses active
rendering as opposed to passive rendering - in passive rendering the
underlying OS may intervene and send directives to the rendering program,
whereas in active rendering the program itself is responsible of drawing and
re-drawing the contents on the screen without the intervention of
OS's directives.
For more details, developers can see JSE API definitions at http://java.sun.com. See also Java 2D API, Full-Screen Exclusive Mode API tutorial, Programmer's Guide to the Java 2D API, Painting in AWT and Swing, Trail: 2D Graphics, and Java 2D new features in J2SE 5.0.
Note: Java 2D API (and rest of the entire platform) is improved with JSE 5.0,
and the FullScreen
requires at least edition 5.0.
Java SE 5.0 and 6.0 is available on all
platforms (Linux, Mac OS X (only Tiger and later), and MS Windows).
Note: Real full screen exclusive mode is not supported on Linux in Java SE
5.0, but it simulates the exclusive mode. However this situation is fixed
in edition 6. Now FSEM
on Linux works fine especially with opengl pipeline enabled.
To enable opengl pipeline user must specify the following
system property on the command line:
-Dsun.java2d.opengl=True
. More information is available
at Psychophysics programming with Java.
Matlab and Mathematica development:
It is possible to create Java objects from within Matlab and Mathematica. You
can, therefore, create a Java object in Matlab or Mathematica and
invoke its methods. In other words, if you choose, you could use this package
with Matlab or Mathematica as a tool for psychophysics programming in a way much
like the well known "Psychtoolbox" package.
See
Psychophysics Programming with Java for more information.
NormalWindow
,
BitsPP
,
Serialized FormNested Class Summary | |
---|---|
class |
FullScreen.KeyPressed
A class to handle key pressing events. |
class |
FullScreen.KeyReleased
A class to handle key releasing events. |
class |
FullScreen.KeyTyped
A class to handle key typing events. |
Nested classes/interfaces inherited from class javax.swing.JFrame |
---|
javax.swing.JFrame.AccessibleJFrame |
Nested classes/interfaces inherited from class java.awt.Frame |
---|
java.awt.Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
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 inherited from class javax.swing.JFrame |
---|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
FullScreen()
Constructs a FullScreen object on the default screen. |
|
FullScreen(int displayID)
Constructs a FullScreen object on the screen designated with displayID. |
Method Summary | |
---|---|
void |
blankScreen()
Blanks the whole screen using the current background color. |
void |
closeScreen()
Closes the full screen exclusive mode screen. |
void |
displayImage(java.awt.image.BufferedImage bi)
Displays a BufferedImage at the center of the screen. |
void |
displayImage(int x,
int y,
java.awt.image.BufferedImage bi)
Displays a BufferedImage at the specified position. |
void |
displayText(int x,
int y,
java.lang.String text)
Displays text at the specified position. |
void |
displayText(java.lang.String text)
Displays text at the center of the screen. |
void |
flushKeyPressed()
Clears the keyPressed queue. |
void |
flushKeyReleased()
Clears the keyReleased queue. |
void |
flushKeyTyped()
Clears the keyTyped queue. |
java.awt.Color |
getBackground()
Returns the current background color. |
java.awt.DisplayMode |
getDisplayMode()
Returns the current DisplayMode. |
java.awt.DisplayMode[] |
getDisplayModes()
Returns all available DisplayModes on client's system. |
FullScreen.KeyPressed |
getKeyPressed()
Returns the top element in keyPressed queue or null if queue is empty. |
FullScreen.KeyPressed |
getKeyPressed(long wt)
Returns a KeyPressed object, which contains fields for the key pressed and when it is pressed within a specified wait time (wt). |
FullScreen.KeyReleased |
getKeyReleased()
Returns the top element in keyReleased queue or null if queue is empty. |
FullScreen.KeyReleased |
getKeyReleased(long wt)
Returns a KeyReleased object, which contains fields for the key released and when it is released within a specified wait time (wt). |
FullScreen.KeyTyped |
getKeyTyped()
Returns the key typed by the observer. |
FullScreen.KeyTyped |
getKeyTyped(long wt)
Returns a KeyTyped object, which contains fields for the key typed and when it is typed within a specified wait time (wt). |
int |
getNBuffers()
Returns number of video buffers (including the front (visible) one) currently used by this FullScreen object. |
void |
hideCursor()
Renders the cursor invisible. |
boolean |
isDisplayChangeSupported()
Returns whether or not DisplayMode change is available on client's system. |
boolean |
isDisplayModeAvailable(java.awt.DisplayMode dm)
Returns whether or not given DisplayMode is applicable to client's screen. |
boolean |
isFullScreenSupported()
Returns whether or not Full Screen Exclusive Mode (FSEM) is supported on client's system. |
void |
keyPressed(java.awt.event.KeyEvent ke)
|
void |
keyReleased(java.awt.event.KeyEvent ke)
|
void |
keyTyped(java.awt.event.KeyEvent ke)
|
java.lang.String |
reportDisplayMode()
Returns the current screen resolution, vertical synchronization rate and color depth in a readable form. |
java.lang.String[] |
reportDisplayModes()
Reports all available DisplayMode parameters in a readable format. |
void |
setBackground(java.awt.Color bg)
Sets the background color. |
void |
setDisplayMode(java.awt.DisplayMode dm)
Sets a new DisplayMode: secreen resolution, vertical synchronization rate, and color depth. |
void |
setNBuffers(int n)
Sets number of video buffers (including the front (visible) one). |
void |
showCursor()
Renders the cursor visible using default cursor |
void |
updateScreen()
Updates the entire screen by bringing the back video buffer front (if there is no back video buffer it has no effect). |
Methods inherited from class javax.swing.JFrame |
---|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Constructor Detail |
---|
public FullScreen(int displayID)
closeScreen()
.
displayID
- a numerical id indicating the screen devicesetDisplayMode(DisplayMode)
,
setNBuffers(int)
,
closeScreen()
public FullScreen()
closeScreen()
.
setDisplayMode(DisplayMode)
,
setNBuffers(int)
,
closeScreen()
Method Detail |
---|
public void keyTyped(java.awt.event.KeyEvent ke)
keyTyped
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent ke)
keyReleased
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent ke)
keyPressed
in interface java.awt.event.KeyListener
public void setNBuffers(int n)
n
- number of buffers requested; must not be less than 1getNBuffers()
public int getNBuffers()
setNBuffers(int)
public void updateScreen()
displayImage(int, int, BufferedImage)
,
displayText(int, int, String)
,
blankScreen()
public void displayImage(java.awt.image.BufferedImage bi)
bi
- BufferedImage to displaydisplayImage(int, int, BufferedImage)
,
updateScreen()
public void displayImage(int x, int y, java.awt.image.BufferedImage bi)
x
- horizontal offset of the upper left corner of the image from the
upper left corner of the screeny
- vertical offset of the upper left corner of the image from the
upper left corner of the screenbi
- BufferedImage to displaydisplayImage(BufferedImage)
,
updateScreen()
public void displayText(java.lang.String text)
text
- a text message to displaydisplayText(int, int, String)
,
updateScreen()
public void displayText(int x, int y, java.lang.String text)
x
- horizontal offset of the upper left corner of the text from the
upper left corner of the screeny
- vertical offset of the upper left corner of the text from the
upper left corner of the screentext
- a text message to displaydisplayText(String)
,
updateScreen()
public void blankScreen()
updateScreen()
public java.awt.Color getBackground()
getBackground
in class java.awt.Component
setBackground(Color)
public void setBackground(java.awt.Color bg)
setBackground
in class java.awt.Component
bg
- new background colorgetBackground()
public void hideCursor()
showCursor()
public void showCursor()
hideCursor()
public void closeScreen()
FullScreen(int)
,
FullScreen()
public FullScreen.KeyTyped getKeyTyped(long wt)
If the wait time wt is positive: This method either (i) returns the top element in the keyTyped queue immediately if there is at least one element in the keyTyped event queue or (ii) waits up to wt for an element to become available. If no key is typed within wait time wt it returns null.
If the wait time wt is zero: Returns the top element in the keyTyped event queue or null if queue is empty.
If the wait time wt is negative: This method either returns the top element in the queue or if the queue is empty it waits indefinitely until the observer types a character.
In all cases, the element returned is removed from the event queue.
General principles of event handling in FullScreen: FullScreen captures the key events in a separate Thread and stores them in Thread safe BlockingQueue objects. Any time observer types, presses or releases a key, that key and the time of the event are inserted to the end (tail) of the respective queue. When one of the getKeyTyped(), getKeyPressed() or getKeyReleased() methods is invoked, the top (head) of the respective queue is retrieved and removed from the queue. The character typed, or the key pressed or released can be retrieved using getKey(), and the time of that event can be retrieved using getWhen() methods. flushKeyTyped(), flushKeyPressed() and flushKeyReleased() methods clear respective queues.
For more information and examples see Psychophysics programming with Java.
wt
- time in milliseconds to wait for a response
getKeyTyped()
,
flushKeyTyped()
,
FullScreen.KeyTyped
public FullScreen.KeyTyped getKeyTyped()
The element returned is removed from the event queue. See also general principles of event handling in FullScreen above.
For more information and examples see Psychophysics programming with Java.
getKeyTyped(long)
,
flushKeyTyped()
,
FullScreen.KeyTyped
public void flushKeyTyped()
For more information and examples see Psychophysics programming with Java.
getKeyTyped(long)
public FullScreen.KeyPressed getKeyPressed(long wt)
If the wait time wt is positive: This method either (i) returns the top element in the keyPressed queue immediately if there is at least one element in the keyPressed event queue or (ii) waits up to wt for an element to become available. If no key is pressed within wait time wt it returns null.
If the wait time wt is zero: Returns the top element in the keyPressed event queue or null if queue is empty.
If the wait time wt is negative: This method either returns the top element in the queue or if the queue is empty it waits indefinitely until the observer pressed a key.
In all cases, the element returned is removed from the event queue. See also general principles of event handling in FullScreen above.
For more information and examples see Psychophysics programming with Java.
wt
- time in milliseconds to wait for a response
getKeyPressed()
,
flushKeyPressed()
,
FullScreen.KeyPressed
public FullScreen.KeyPressed getKeyPressed()
The element returned is removed from the event queue. See also general principles of event handling in FullScreen above.
For more information and examples see Psychophysics programming with Java.
getKeyPressed(long)
,
flushKeyPressed()
,
FullScreen.KeyPressed
public void flushKeyPressed()
For more information and examples see Psychophysics programming with Java.
getKeyPressed(long)
public FullScreen.KeyReleased getKeyReleased(long wt)
If the wait time wt is positive: This method either (i) returns the top element in the keyReleased queue immediately if there is at least one element in the keyTyped event queue or (ii) waits up to wt for an element to become available. If no key is released within wait time wt it returns null.
If the wait time wt is zero: Returns the top element in the keyReleased event queue or null if queue is empty.
If the wait time wt is negative: This method either returns the top element in the queue or if the queue is empty it waits indefinitely until the observer releases a key.
In all cases, the element returned is removed from the event queue. See also general principles of event handling in FullScreen above.
For more information and examples see Psychophysics programming with Java.
wt
- time in milliseconds to wait for a response
getKeyReleased()
,
flushKeyReleased()
,
FullScreen.KeyReleased
public FullScreen.KeyReleased getKeyReleased()
The element returned is removed from the event queue. See also general principles of event handling in FullScreen above.
For more information and examples see Psychophysics programming with Java.
getKeyReleased(long)
,
flushKeyReleased()
,
FullScreen.KeyReleased
public void flushKeyReleased()
For more information and examples see Psychophysics programming with Java.
getKeyReleased(long)
public boolean isFullScreenSupported()
public void setDisplayMode(java.awt.DisplayMode dm)
dm
- new display mode to applyisDisplayChangeSupported()
,
isDisplayModeAvailable(DisplayMode)
public boolean isDisplayModeAvailable(java.awt.DisplayMode dm)
dm
- DisplayMode to check
public java.lang.String reportDisplayMode()
public java.awt.DisplayMode getDisplayMode()
public boolean isDisplayChangeSupported()
public java.lang.String[] reportDisplayModes()
public java.awt.DisplayMode[] getDisplayModes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |