|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.azalient.base.BaseInternals
com.azalient.api.BasePlugin
public abstract class BasePlugin
A template for a Commuter Plugin, using a listener/event model.
To create a plugin:
public class TestPlugin extends BasePlugin
implements ModelEventViewLegend // implement the event handlers corresponding to the events you want to be sent to this plugin
{
// In the constructor, register for the events you want to be sent to this plugin.
// There are both model events, corresponding to significant transitions in the model loading and handling cycle,
// and agent events, which correspond to significant events in the life cycle of an agent (vehicle, pedestrian)
// in any simulation
private JFrame frame = new XFrame("Test Plugin User Interface");
public TestPlugin()
{
// This is an example of a listener - it does not have to be included
addModelEventViewLegendListener(this);
frame.getContentPane().add(new JLabel("Add your own controls here, to allow user interaction with your plugin."));
frame.pack();
}
// This is the implementation of the event handler registered above
public void viewLegend(IDrawing drw)
{
drw.colour(Color.WHITE.getRGB());
drw.string("Test Plugin", 0.5, 0.5, 0, 0.5);
}
// This is called for all plugins, after the model "document" has been loaded
public void pluginOpen()
{
}
// called when a network document" is closed
public void pluginClose()
{
frame.setVisible(false);
frame.dispose();
}
// called when "File/Save" is selected, to save any data in the plugin
public void pluginSave() {}
// called when the "Configure..." button is pressed on the Plugins tab
public Window pluginWindow()
{
return frame;
}
}
| Field Summary |
|---|
| Fields inherited from class com.azalient.base.BaseInternals |
|---|
PKG_PLUGIN |
| Fields inherited from interface com.azalient.api.event.StatusListener |
|---|
BAD, N, OK, STARTED, UNKNOWN |
| Method Summary | |
|---|---|
void |
addAgentEventArriveListener(AgentEventArrive listener)
Call this in the constructor to register your plugin, so that it is notified when an agent arrives at its destination. |
void |
addAgentEventDepartListener(AgentEventDepart listener)
Call this in the constructor to register your plugin, so that it is notified when an agent departs from its origin. |
void |
addAgentEventLaneListener(AgentEventLane listener)
Call this in the constructor to register your plugin, so that it is notified when a vehicle changes lane |
void |
addAgentEventLinkListener(AgentEventLink listener)
Call this in the constructor to register your plugin, so that it is notified when a vehicle changes link |
void |
addAgentEventLoopListener(AgentEventLoop listener)
Call this in the constructor to register your plugin, so that it is notified when a vehicle changes the state of a loop. |
void |
addAgentEventMoveListener(AgentEventMove listener)
Call this in the constructor to register your plugin, so that it is notified for every agent at every simulation time step, when it moves. |
void |
addAgentEventOccupantInListener(AgentEventOccupantIn listener)
Call this in the constructor to register your plugin, so that it is notified when a driver or passenger gets into a private vehicle |
void |
addAgentEventOccupantOutListener(AgentEventOccupantOut listener)
Call this in the constructor to register your plugin, so that it is notified when a driver or passenger gets out of a private vehicle |
void |
addAgentEventPassengerOffListener(AgentEventPassengerOff listener)
Call this in the constructor to register your plugin, so that it is notified when a passenger gets off a public transport vehicle |
void |
addAgentEventPassengerOnListener(AgentEventPassengerOn listener)
Call this in the constructor to register your plugin, so that it is notified when a passenger gets onto a public transport vehicle |
void |
addAgentEventSignListener(AgentEventSign listener)
Call this in the constructor to register your plugin, so that it is notified when a vehicle passes a sign. |
void |
addAgentEventStandListener(AgentEventStand listener)
Call this in the constructor to register your plugin, so that it is notified when a public transport vehicle arrives at a stand. |
void |
addAgentEventStopListener(AgentEventStop listener)
Call this in the constructor to register your plugin, so that it is notified when a vehicle stops, where stopping is defined by calibration parameters |
void |
addAgentEventTestArrivalListener(AgentEventTestArrival listener)
Call this in the constructor to register your plugin, so that it can be an active plugin that influences destination choice. |
void |
addAgentEventTestRouteListener(AgentEventTestRoute listener)
Call this in the constructor to register your plugin, so that it can be an active plugin that influences route choice. |
void |
addAgentEventTimeStepListener(AgentEventTimeStep listener)
Call this in the constructor to register your plugin, so that it is notified for every agent at every simulation time step. |
void |
addAgentEventUnreleasedListener(AgentEventUnreleased listener)
Call this in the constructor to register your plugin, so that it is notified when an agent departs from its origin. |
void |
addAgentEventWalkwayListener(AgentEventWalkway listener)
Call this in the constructor to register your plugin, so that it is notified when a person joins or leaves a walkway |
void |
addModelEventActionSelectionListener(ModelEventActionSelection listener)
Call this in the constructor to register your plugin, so that it is notified when the user makes a selection . |
void |
addModelEventGenericListener(ModelEventGeneric listener)
Call this in the constructor to register your plugin, so that it receives generic event notifications . |
void |
addModelEventResultListener(ModelEventResult listener)
Call this in the constructor to register your plugin, so that it is notified when results are saved . |
void |
addModelEventTimeCompleteListener(ModelEventTimeComplete listener)
Call this in the constructor to register your plugin, so that it is notified when the simulation completes its term. |
void |
addModelEventTimeRewindListener(ModelEventTimeRewind listener)
Call this in the constructor to register your plugin, so that it is notified when the simulation time is rewound to the beginning of the the simulation term . |
void |
addModelEventTimeSecListener(ModelEventTimeSec listener)
Call this in the constructor to register your plugin, so that it is notified on each whole second of simulation time . |
void |
addModelEventTimeStepListener(ModelEventTimeStep listener)
Call this in the constructor to register your plugin, so that it is notified on each simulation time step . |
void |
addModelEventViewLegendListener(ModelEventViewLegend listener)
Call this in the constructor to register your plugin, so that it is notified when drawing engine draws in GL_PROJECTION mode, for a legend or a key that does not move with the view . |
void |
addModelEventViewModelListener(ModelEventViewModel listener)
Call this in the constructor to register your plugin, so that it is notified when drawing engine draws in GL_MODELVIEW mode, the world view of the model . |
boolean |
agentEvent(IAgent agent,
AgentEvent event,
Object data)
This is called by the simulation to fire an agent event. |
void |
centralStatusListener(StatusListener sl)
Set the pointer to the central status listener that is updated when the status of this plugin chages |
void |
closeWindow()
|
void |
deiconifyWindow()
|
void |
enable(boolean v)
Toggle to enable this plugin |
static Window |
featureNotLicensed(String message)
|
static int |
generateUniqueIndex()
|
void |
iconifyWindow()
|
boolean |
isEnabled()
Returns true if this listener is enabled |
static int |
mainProcessUniqueIndex()
|
static int |
maxUniqueIndex()
|
boolean |
modelEvent(ModelEvent event,
Object data)
This is called by the simulation to fire a model event. |
void |
moduleChanged(PageType module)
This is called when a module is changed. |
IModule[] |
moduleDependencies()
Deprecated. |
PageType[] |
moduleTypeDependencies()
Return an array of module page types on which this plugin depends. |
void |
raiseWindow()
Override this to raise a UI window for your Plugin. |
String |
status()
A message describing the current status |
void |
status(Object source,
int status)
This is called when the status of a process changes |
void |
status(Object source,
int status,
String description)
This is called when the status of a process changes |
int |
uniqueIndex()
Each plugin when it is created gives itself a unique index, which can be used to differentiate calls to the userData functions |
| Methods inherited from class com.azalient.base.BaseInternals |
|---|
plugin, pluginIndex, plugins, raiseWindow, readPluginDescriptions, rebuildController, setPluginIndex, showController, unload |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.azalient.api.b.plugins.IPlugin |
|---|
pluginClose, pluginOpen, pluginSave |
| Methods inherited from interface com.azalient.api.a.IBasePlugin |
|---|
pluginClose, pluginOpen, pluginWindow |
| Method Detail |
|---|
public IModule[] moduleDependencies()
moduleDependencies in interface IPluginpublic PageType[] moduleTypeDependencies()
IPlugin
moduleTypeDependencies in interface IPluginpublic void moduleChanged(PageType module)
IPlugin
moduleChanged in interface IPluginpublic void raiseWindow()
raiseWindow in interface IBasePluginpublic void deiconifyWindow()
public void iconifyWindow()
public void closeWindow()
public void centralStatusListener(StatusListener sl)
IBasePlugin
centralStatusListener in interface IBasePlugin
public void status(Object source,
int status,
String description)
StatusListener
status in interface StatusListenersource - the source of the status changestatus - The new statusdescription - a text message description of the new status, for example a reason for failure
public void status(Object source,
int status)
StatusListener
status in interface StatusListenersource - the source of the status changestatus - The new statuspublic String status()
IBasePlugin
status in interface IBasePluginpublic void enable(boolean v)
IBasePlugin
enable in interface IBasePluginpublic boolean isEnabled()
SimulationEventListener
isEnabled in interface IBasePluginisEnabled in interface SimulationEventListenerpublic static int mainProcessUniqueIndex()
public static int generateUniqueIndex()
public static int maxUniqueIndex()
public int uniqueIndex()
uniqueIndex in interface IPluginIdentifierpublic final void addModelEventTimeCompleteListener(ModelEventTimeComplete listener)
You will also need to implement the listener interface in the plugin, the listener cannot be a separate class.
Example code:
public class MyPlugin extends BasePlugin implements ModelEventTimeComplete
{
public MyPlugin()
{
// ...
// in constructor
addModelEventTimeCompleteListener(this);
}
}
public void timeComplete()
{
// add code here that will be executed when the event occurs
}
public final void addModelEventTimeRewindListener(ModelEventTimeRewind listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventTimeStepListener(ModelEventTimeStep listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventTimeSecListener(ModelEventTimeSec listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventActionSelectionListener(ModelEventActionSelection listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventViewLegendListener(ModelEventViewLegend listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventViewModelListener(ModelEventViewModel listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventResultListener(ModelEventResult listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addModelEventGenericListener(ModelEventGeneric listener)
For an example, see {addModelEventTimeCompleteListener(ModelEventTimeComplete)
public final void addAgentEventArriveListener(AgentEventArrive listener)
You will also need to implement the listener interface in the plugin, the listener cannot be a separate class.
Example code:
public class MyPlugin extends BasePlugin implements AgentEventArrive
{
public MyPlugin()
{
// ...
// in constructor
addAgentEventArriveListener(this);
}
}
public void arrive(IAgent agent, IPlace place)
{
// add code here that will be executed when the event occurs
}
public final void addAgentEventDepartListener(AgentEventDepart listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventUnreleasedListener(AgentEventUnreleased listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventTimeStepListener(AgentEventTimeStep listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventMoveListener(AgentEventMove listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventLoopListener(AgentEventLoop listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventSignListener(AgentEventSign listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventStandListener(AgentEventStand listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventStopListener(AgentEventStop listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventPassengerOnListener(AgentEventPassengerOn listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventPassengerOffListener(AgentEventPassengerOff listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventOccupantInListener(AgentEventOccupantIn listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventOccupantOutListener(AgentEventOccupantOut listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventWalkwayListener(AgentEventWalkway listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventLaneListener(AgentEventLane listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventLinkListener(AgentEventLink listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventTestRouteListener(AgentEventTestRoute listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final void addAgentEventTestArrivalListener(AgentEventTestArrival listener)
For an example, see {addAgentEventArriveListener(AgentEventArrive)
public final boolean modelEvent(ModelEvent event,
Object data)
SimulationEventListener
modelEvent in interface SimulationEventListener
public final boolean agentEvent(IAgent agent,
AgentEvent event,
Object data)
SimulationEventListener
agentEvent in interface SimulationEventListenerpublic static Window featureNotLicensed(String message)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||