|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--wonderly.jeaprs.ClientImpl
This class is the base class that most JeAPRS clients should subclass. This class provides default behavior and implementations of needed methods that will make JeAPRS have a more uniform behavior.
Field Summary | |
protected java.util.Hashtable |
actions
The actions defined for this client |
protected wonderly.jeaprs.aprs.data.APRS |
APRS
|
protected boolean |
dirty
|
protected wonderly.jeaprs.aprs.packet.APRSEventListener |
evLis
The event listener object that we have created |
protected java.util.Vector |
ins
The event generator that we are currently getting events from |
protected wonderly.jeaprs.ClientImpl |
me
A reference to ourselves for inner classes to use. |
protected java.lang.String |
name
The name of this client |
protected java.util.Vector |
outs
The outout stream that we write APRS messages to |
protected boolean |
stopped
Is this client stopped? |
protected java.io.OutputStream |
strmLis
|
Constructor Summary | |
ClientImpl()
|
Method Summary | |
void |
addAPRSEventGenerator(wonderly.jeaprs.aprs.packet.APRSEventGenerator gen)
Sets the input event generator that this client is to use This default implementation removes the listener object from any previously registered generator, attaches the listener object to the passed generator (if non-null). |
void |
addAPRSOutputStream(wonderly.jeaprs.TNC out)
Used to set the currently used output stream |
abstract void |
buildActions()
Put code in here to register all of the actions that you want to use. |
protected javax.swing.JMenuBar |
buildMenu()
Override this default implementation (which returns null to indicate no menu bar is to be used) to create your clients menu bar. |
abstract javax.swing.JPanel |
buildPanel(javax.swing.JFrame parent)
Builds the applications user interface. |
abstract wonderly.jeaprs.aprs.packet.APRSEventListener |
createEventListener()
This method needs to be implemented by subclasses and should return an APRSEventListener implementation that is applicable
for their client. |
abstract java.io.OutputStream |
createStreamListener()
This method needs to be implemented by subclasses and should return an OutputStream implementation that is applicable
for their client. |
protected javax.swing.Action |
getAction(java.lang.String name)
This method is a convienence method that returns actions that have been stored in the actions Hashtable. |
wonderly.jeaprs.aprs.packet.APRSEventGenerator[] |
getAPRSEventGenerators()
Used to get the current input event stream generator |
wonderly.jeaprs.TNC[] |
getAPRSOutputStreams()
Used to get the output stream this client is using |
java.lang.String |
getName()
Returns the set name of this client @see setName(String) |
wonderly.jeaprs.aprs.APRSUIFactory |
getUIFactory()
This default method returns a reference to an inner class that implements the APRSUIFactory interface. |
boolean |
isDirty()
|
boolean |
isInputUser()
If this client needs an event generator, this should return true. |
boolean |
isOutputUser()
If this client needs an output stream, this should return true. |
void |
removeAPRSEventGenerator(wonderly.jeaprs.aprs.packet.APRSEventGenerator gen)
Remove the client as a listener to the passed APRSEventGenerator. |
void |
removeAPRSOutputStream(wonderly.jeaprs.TNC out)
Used to set the currently used output stream |
void |
setDirty(boolean how)
Set whether this client needs to have its properties saved |
void |
setName(java.lang.String name)
Sets the name of this client |
void |
start()
Starts this client 'running' or whatever it needs when the user opens the client via the menus. |
void |
stop()
Stops the client when the user closes the window or deactivates it via the menus |
java.lang.String |
toString()
Returns name of Client for display in lists |
void |
write(wonderly.jeaprs.ByteString from,
wonderly.jeaprs.ByteString path,
byte[] arr)
Write the indicated packet to all TNCs configured for output for this client. |
void |
write(wonderly.jeaprs.ByteString from,
wonderly.jeaprs.ByteString path,
wonderly.jeaprs.ByteString str)
Write the indicated packet to all TNCs configured for output for this client. |
void |
write(wonderly.jeaprs.ByteString from,
wonderly.jeaprs.ByteString to,
wonderly.jeaprs.ByteString path,
byte[] arr)
Write the indicated packet to all TNCs configured for output for this client. |
void |
write(wonderly.jeaprs.ByteString from,
wonderly.jeaprs.ByteString to,
wonderly.jeaprs.ByteString path,
wonderly.jeaprs.ByteString str)
Write the indicated packet to all TNCs configured for output for this client. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient java.util.Vector outs
protected transient java.util.Vector ins
protected transient wonderly.jeaprs.aprs.packet.APRSEventListener evLis
protected transient java.io.OutputStream strmLis
protected transient wonderly.jeaprs.ClientImpl me
protected transient java.util.Hashtable actions
protected boolean stopped
protected java.lang.String name
protected transient wonderly.jeaprs.aprs.data.APRS APRS
protected boolean dirty
Constructor Detail |
public ClientImpl()
Method Detail |
public void write(wonderly.jeaprs.ByteString from, wonderly.jeaprs.ByteString path, wonderly.jeaprs.ByteString str)
from
- the from call to use in the packetpath
- the path to assign to the packet.str
- the packet payload.public void write(wonderly.jeaprs.ByteString from, wonderly.jeaprs.ByteString to, wonderly.jeaprs.ByteString path, wonderly.jeaprs.ByteString str)
from
- the from call to use in the packetto
- the to call to use in the packets headerpath
- the path to assign to the packet.str
- the packet payload.public void write(wonderly.jeaprs.ByteString from, wonderly.jeaprs.ByteString path, byte[] arr)
from
- the from call to use in the packetpath
- the path to assign to the packet.arr
- the packet payload.public void write(wonderly.jeaprs.ByteString from, wonderly.jeaprs.ByteString to, wonderly.jeaprs.ByteString path, byte[] arr)
from
- the from call to use in the packetto
- the to call to use in the packets headerpath
- the path to assign to the packet.arr
- the packet payload.public void setName(java.lang.String name)
setName
in interface Client
public java.lang.String getName()
getName
in interface Client
public void start()
start
in interface Client
public void stop()
stop
in interface Client
public java.lang.String toString()
Client
toString
in interface Client
toString
in class java.lang.Object
public boolean isOutputUser()
isOutputUser
in interface Client
public boolean isInputUser()
isInputUser
in interface Client
public void addAPRSOutputStream(wonderly.jeaprs.TNC out)
addAPRSOutputStream
in interface Client
public void removeAPRSOutputStream(wonderly.jeaprs.TNC out)
removeAPRSOutputStream
in interface Client
public wonderly.jeaprs.TNC[] getAPRSOutputStreams()
getAPRSOutputStreams
in interface Client
public void addAPRSEventGenerator(wonderly.jeaprs.aprs.packet.APRSEventGenerator gen)
addAPRSEventGenerator
in interface Client
createEventListener()
public void removeAPRSEventGenerator(wonderly.jeaprs.aprs.packet.APRSEventGenerator gen)
removeAPRSEventGenerator
in interface Client
gen
- the generator to stop listening too.public abstract wonderly.jeaprs.aprs.packet.APRSEventListener createEventListener()
APRSEventListener
implementation that is applicable
for their client. Many times, a simple inner class is all that is
needed as in.
return new APRSEventAdapter() { public void message( APRSPacket pkt, APRSMessage msg ) { // Do something with message } };This will create a new object that is an instance of the
APRSEventAdapter
class. That class implements the APRSEventListener
interface
with empty methods so that you can just override the methods that you want
APRS packets for, and not have to deal with implementing all methods.
Just return null here if you don't need an event listener.
APRSEventAdapter
,
APRSEventListener
public abstract java.io.OutputStream createStreamListener()
OutputStream
implementation that is applicable
for their client. This stream will be written to as data comes through
a TNC
implementatation, receiving copies of the text lines
received by the TNC
implementation. A simple mechanism is
typically to use a thread and a PipedInputStream
and PipedOutputStream
pair to receive the data and process it.
Just return null if you don't need raw stream events.
public OutputStream createStreamListener() throws IOException { final PipedOutputStream pipe = new PipedOutputStream(); final PipedInputStream is = new PipedInputStream(pipe); new Thread("TNC Stream listener") { public void run() { try { BufferedReader rd = new BufferedReader( new InputStreamReader(is) ); String str; while( (str = rd.readLine()) != null ) { System.out.println( "Got TNC line: "+str ); } System.out.println("End of TNC Stream, exiting"); } finally { try { is.close(); pipe.close(); } catch( Exception ex ) { JeAPRS.getUI().reportException(ex); } } } }.start(); return pipe; }
public wonderly.jeaprs.aprs.packet.APRSEventGenerator[] getAPRSEventGenerators()
Client
getAPRSEventGenerators
in interface Client
public wonderly.jeaprs.aprs.APRSUIFactory getUIFactory()
APRSUIFactory
interface. It relies on subclasses
implementing the buildPanel(JFrame)
that returns their
application UI. It also uses the buildMenu()
methods return
value to attach a JMenu to a JFrame or JInternalFrame if such is needed
getUIFactory
in interface Client
buildPanel(JFrame)
,
buildMenu()
public boolean isDirty()
isDirty
in interface Client
public void setDirty(boolean how)
Client
setDirty
in interface Client
public abstract javax.swing.JPanel buildPanel(javax.swing.JFrame parent)
buildMenu()
method can be used to create a menu bar
if neededed.
buildMenu()
protected javax.swing.JMenuBar buildMenu()
protected javax.swing.Action getAction(java.lang.String name)
actions
Hashtable. If an action is not defined,
then an empty, disabled action is created and returned. This allows the
UI elements to be easily populated, and those that are not implemented
yet will be disabled so the user won't feel like they don't work.
buildActions()
public abstract void buildActions()
actions.put( "MyAction", act = new AbstractAction( "MyAction" ) { public void actionPerformed( ActionEvent ev ) { //...do something here } }); act.putValue( Action.NAME, "MyAction" );
getAction(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |