uk.ac.rdg.resc.jstyx.gridservice.client
Class StreamViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by uk.ac.rdg.resc.jstyx.gridservice.client.StreamViewer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
Direct Known Subclasses:
TextStreamViewer

public abstract class StreamViewer
extends javax.swing.JFrame

Class representing a viewer for an output stream from a Styx Grid Service instance. Subclasses only need to implement the newDataArrived() method, which is called when new data are read from the stream. Subclasses may override eof (which is called when end-of-stream is reached) and streamError (which is called if an error occurs). See TextStreamViewer for an example of a very simple StreamViewer.

Author:
Jon Blower $Revision: 335 $ $Date: 2005-08-01 17:38:05 +0100 (Mon, 01 Aug 2005) $ $Log$ Revision 1.8 2005/08/01 16:38:05 jonblower Implemented simple parameter handling Revision 1.7 2005/06/13 13:55:42 jonblower Adapted LB viewer for JStyx framework Revision 1.6 2005/06/10 07:54:49 jonblower Added code to convert event-based StreamViewer to InputStream-based one Revision 1.5 2005/05/27 21:22:39 jonblower Further development of caching stream readers Revision 1.4 2005/05/27 17:05:07 jonblower Changes to incorporate GeneralCachingStreamReader Revision 1.3 2005/05/27 07:44:07 jonblower Continuing to implement Stream viewers Revision 1.2 2005/05/26 21:33:40 jonblower Added method for viewing streams in a window Revision 1.1 2005/05/26 16:47:43 jonblower Initial import
See Also:
Serialized Form

Nested Class Summary
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.io.InputStream is
           
protected  long offset
           
protected  CachedStreamReader reader
           
protected  boolean started
           
 
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
StreamViewer()
           
 
Method Summary
 java.io.InputStream getInputStream()
           
 long getPosition()
          Gets the current position of the stream (i.e.
 void newData(byte[] data, int size)
          Called by CachedStreamReader when a chunk of data is read from stream
abstract  void newDataArrived(byte[] data, int size)
          Called when new data arrive from the server
 void readError(java.lang.Exception e)
           
 void reset()
          Resets the stream to the start, so we can start reading from the beginning again.
 void setPosition(long pos)
          Sets the position of the stream to the given offset (i.e.
 void setStreamReader(CachedStreamReader reader)
          Sets the CStyxFile that represents the stream
 void start()
          Sends a message to start reading from the stream and makes the GUI visible.
 void stop()
          Sends a message to stop reading from this stream.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, 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, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

reader

protected CachedStreamReader reader

offset

protected long offset

started

protected boolean started

is

protected java.io.InputStream is
Constructor Detail

StreamViewer

public StreamViewer()
Method Detail

setStreamReader

public void setStreamReader(CachedStreamReader reader)
Sets the CStyxFile that represents the stream


start

public void start()
Sends a message to start reading from the stream and makes the GUI visible. If we have already started reading from the stream, this does nothing.


stop

public void stop()
Sends a message to stop reading from this stream. The stream position will not be reset: use reset() for this. After calling this, we can continue reading from the stream by calling start(). Note that one more chunk of data might arrive after calling this (if there was a read message outstanding at the time of calling this).


setPosition

public void setPosition(long pos)
Sets the position of the stream to the given offset (i.e. number of bytes after the beginning of the file).


getPosition

public long getPosition()
Gets the current position of the stream (i.e. the position of the next byte that will arrive)


reset

public void reset()
Resets the stream to the start, so we can start reading from the beginning again. Exactly equivalent to setPosition(0)


newDataArrived

public abstract void newDataArrived(byte[] data,
                                    int size)
Called when new data arrive from the server


newData

public final void newData(byte[] data,
                          int size)
Called by CachedStreamReader when a chunk of data is read from stream


readError

public void readError(java.lang.Exception e)

getInputStream

public java.io.InputStream getInputStream()
Returns:
An InputStream that can be used to read from this stream. This InputStream must be consumed in a separate thread to avoid blocking.


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.