|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectt3.portfolios.PortfolioServer
public class PortfolioServer
Represents a Portfolio server, which uses a RemoteHRDServer and provides facilities such as portfolios and event handling.
Notes on the event model:
Keyboard events are dispatched to whichever portfolio was last pressed on by any PID of the person owning the keyboard.
Point input device (PID) events are generated when PID's state changes. Normally events are sent to the portfolio whose tile is underneath the PID, and may bubble up the portfolio hierarchy from there.
However, it is also possible to put the PID temporarily into FDOP (Follow Drag Outside Portfolio mode) by specifying a single portfolio to whom all events from that PID will be directed until a specified button is released.
The PID event system is further complicated because each portfolio has a PortfolioCommonBehaviour class which can filter events out of the stream to provide common functionality such as dragging portfolios.
The PID event system proceeds as follows:
When we dispatch an event to a portfolio, we first call a method on the portfolio's PortfolioCommonBehaviour object. If this returns true then the PortfolioCommonBehaviour object is deemed to have handled the event. Only if it returns false do we call a method on the Portfolio object itself.
Threading notes:
When you write code in portfolio callback methods, you don't need to worry about multithreading and locking. T3 ensures that the thread running your method will have the correct locks and that at the end of your method, any updates will be passed through to the clients.
If, however, you wish to call T3 methods outside of portfolio callback methods, i.e. from your own thread, then you must call performActionAsynchronouslyByCurrentThread, passing your code as a runnable object. This ensures that when your code runs, it runs in the currently executing thread and has the requisite locks, and finishes by instructing T3 to pass changes through to the clients. Furthermore, if you create a thread that exists for a period of time, such as an animator, then you must ensure that this thread runs with low priority and yields regularly. If not then it can prevent the T3 client threads at the server from responding to client requests for updates. Consequently, the animator thread produces updates at a high rate, but the client threads never run and so these updates never get sent through to the clients. If you wish to use animations, then the AnimatorThread or AnimatorJobsThread will handle all this for you.
If you use SwingFramePortfolio then there are further threading constraints. See its javadoc for details.
Field Summary | |
---|---|
java.util.List<Portfolio> |
allPortfoliosInOrderBackFirstReadOnly
|
java.util.Map<PointInputDevice,PointInputDeviceData> |
pidToPidDataReadOnly
|
RootPortfolio |
rootPortfolio
|
Constructor Summary | |
---|---|
PortfolioServer(java.net.ServerSocket s,
java.net.ServerSocket i,
boolean alwaysServerPush)
Creates a Portfolio server, including a root portfolio and a RemoteHRD server, which starts listening on the specified socket. |
Method Summary | |
---|---|
void |
enterFDOPmodeForPointInputDevice(Portfolio p,
PointInputDevice pointInputDevice,
int button,
double PORTxWhenFDOPmodeEntered,
double PORTyWhenFDOPmodeEntered)
Called by a portfolio when it wishes to enter FDOP mode. |
void |
fatalError(java.lang.Throwable e)
Call this if a fatal error occurs and you wish to kill the server. |
Portfolio |
getKeyboardFocusForPerson(Person person)
Returns the portfolio that currently receives keyboard input events from a specified person's keyboard. |
PointInputDeviceData |
getPidDataForPid(PointInputDevice pid)
Returns the PointInputDeviceData for a specified PointInputDevice. |
static boolean |
isButtonDown(int buttons,
int buttonNumber)
Returns true iff bit buttonNumber is set in buttons. |
void |
leaveFDOPmodeForPointInputDevice(PointInputDevice pid)
Called by a portfolio when it wishes to leave FDOP mode. |
void |
notifyPortfolioWhenPidPressedOutside(Portfolio p,
PointInputDevice pointInputDevice)
|
void |
performActionAsynchronouslyByCurrentThread(java.lang.Runnable r)
|
void |
sendLogMessageToAllClients(java.lang.String message)
|
void |
setKeyboardFocusForPerson(Portfolio p,
Person person)
Sets the portfolio to which keyboard input events from a specified person will be sent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.Map<PointInputDevice,PointInputDeviceData> pidToPidDataReadOnly
public final java.util.List<Portfolio> allPortfoliosInOrderBackFirstReadOnly
public final RootPortfolio rootPortfolio
Constructor Detail |
---|
public PortfolioServer(java.net.ServerSocket s, java.net.ServerSocket i, boolean alwaysServerPush)
globalPortfolioDragMode
- Specifies how Portfolios are dragged around the surface.s
- Socket on which RemoteHRDServer should listen for clients.i
- Socket on which RemoteHRDServer should listen for inputsources.alwaysServerPush
- See RemoteHRDServer.Method Detail |
---|
public void sendLogMessageToAllClients(java.lang.String message)
public void performActionAsynchronouslyByCurrentThread(java.lang.Runnable r)
public void notifyPortfolioWhenPidPressedOutside(Portfolio p, PointInputDevice pointInputDevice)
public void enterFDOPmodeForPointInputDevice(Portfolio p, PointInputDevice pointInputDevice, int button, double PORTxWhenFDOPmodeEntered, double PORTyWhenFDOPmodeEntered)
p
- pointInputDevice
- button
- PORTxWhenFDOPmodeEntered
- PORTyWhenFDOPmodeEntered
- public void leaveFDOPmodeForPointInputDevice(PointInputDevice pid)
pid
- public void setKeyboardFocusForPerson(Portfolio p, Person person)
p
- person
- public Portfolio getKeyboardFocusForPerson(Person person)
person
-
public PointInputDeviceData getPidDataForPid(PointInputDevice pid)
pid
-
public void fatalError(java.lang.Throwable e)
e
- public static boolean isButtonDown(int buttons, int buttonNumber)
buttons
- buttonNumber
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |