com.ccg.net
Class LineReceiverMonitor

java.lang.Object
  extended by com.ccg.net.LineReceiverMonitor
All Implemented Interfaces:
Runnable

public class LineReceiverMonitor
extends Object
implements Runnable

A Swing monitor for the LineReceiver class.

This class allows creates a graphical representation of a LineReceiver object. To use this class, uses the following steps:

I really need to create a full working example program for this - one of these days. If you have access to the com.glatmos.disp package, you can check out the NetStatus*.java files to see how this is put to use.

Since:
1.0
Version:
$Revision: 1.2 $
Author:
$Author: pkb $
See Also:
LineReceiver

Constructor Summary
LineReceiverMonitor()
          Constructs a new LineReceiverMonitor.
 
Method Summary
 String formatInteger(long v)
          Produce a integer format for a number.
 String formatTime(long millis)
          Format a date/time stamp.
 String formatTimeSpan(long millis)
          Format a duration (span of time).
 JComponent getComponent()
          Get the graphical component which displays the status information.
 DateFormat getDateFormat()
          Get the date/time formatter to use for time stamps.
 LineReceiver getLineReceiver()
          Get the LineReceiver object which will be associated.
protected  JComponent[] getTabPanels()
          Create and return the array of panels to be displayed.
 void run()
          Does the actual transfer of information.
 void setDateFormat(DateFormat val)
          Set the date/time formatter to use for time stamps.
 void setLineReceiver(LineReceiver val)
          Set the LineReceiver object which will be associated.
 void update()
          Safely transfer values from the object to the AWT component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineReceiverMonitor

public LineReceiverMonitor()
Constructs a new LineReceiverMonitor.

Since:
1.0
See Also:
setLineReceiver(com.ccg.net.LineReceiver), update()
Method Detail

update

public void update()
Safely transfer values from the object to the AWT component.

This method transfers the current values from the associated LineReceiver object in a safe manner. If you call this method outside of the Swing dispatch thread, we will automatically schedule the update to occur as soon as possible.

Derived classes will want to override the run() method.

Since:
1.0

setLineReceiver

public void setLineReceiver(LineReceiver val)
Set the LineReceiver object which will be associated.

Parameters:
val - New LineReceiver value to assign.
See Also:
getLineReceiver()

getLineReceiver

public LineReceiver getLineReceiver()
Get the LineReceiver object which will be associated.

Returns:
Current LineReceiver value assigned.
See Also:
setLineReceiver(com.ccg.net.LineReceiver)

run

public void run()
Does the actual transfer of information.

This method transfers information from the assoicated LineReceiver object to the GUI components. If this isn't possible (they haven't been realized yet), then nothing is done.

This method should ONLY be used by Swing dispatched events. It is safer to use the update() method which works from ALL threads.

However, if you derive a class from this one (perhaps to add your on panel), you will want to override this method (and not the update() method so that you can transfer the values to your component.

Specified by:
run in interface Runnable
Since:
1.0
See Also:
update()

getComponent

public JComponent getComponent()
Get the graphical component which displays the status information.

Returns:
Current JComponent value assigned.
See Also:
update()

getTabPanels

protected JComponent[] getTabPanels()
Create and return the array of panels to be displayed.

This method creates all of the components which will be used to display information. Each entry in the array will appear on its own tabbed pane (however, if you return a array of length 1, then a tabbed pane won't be required).

Derived classes can override the default set of panels and either choose to completely replace them, or add to them.

Returns:
A non-zero array of JComponents where the name of the component will appear on the tab.
Since:
1.0

formatTimeSpan

public String formatTimeSpan(long millis)
Format a duration (span of time).

This method formats a time span such that the units change as the span grows longer (from seconds, to minutes, to hours, to days).

Parameters:
millis - Number of elapsed milliseconds
Returns:
String representation of duration
Since:
1.0

formatInteger

public String formatInteger(long v)
Produce a integer format for a number.

This method is used to format whole numbers.

Parameters:
v - Value to format as a integer
Returns:
String representation of integer
Since:
1.0

formatTime

public String formatTime(long millis)
Format a date/time stamp.

This method can be used to format a date/time stamp. The date/time format can be customized. NOTE, if you pass a value of 0 or less, this method will return "-" (assuming that you don't have a time stamp yet).

Parameters:
millis - Standard Java millisecond time stamp
Returns:
String representation of time, unless millis is less than or equal to zero (in which case you get back "-")
Since:
1.0
See Also:
getDateFormat()

setDateFormat

public void setDateFormat(DateFormat val)
Set the date/time formatter to use for time stamps.

Parameters:
val - New DateFormat value to assign.
See Also:
getDateFormat()

getDateFormat

public DateFormat getDateFormat()
Get the date/time formatter to use for time stamps.

Returns:
Current DateFormat value assigned.
See Also:
setDateFormat(java.text.DateFormat)


Copyright 1998-1998-2006 null. All Rights Reserved.