Skip to content

Commit 84b0baf

Browse files
committed
GUI FX Applications improved (now easier to extend).
1 parent a11804c commit 84b0baf

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

aimax-osm/src/main/java/aimax/osm/gui/fx/IntegratedAimaOsmFxApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import aimax.osm.gui.fx.applications.OsmLRTAStarAgentApp;
66
import aimax.osm.gui.fx.applications.OsmRouteFindingAgentApp;
77
import aimax.osm.gui.fx.applications.OsmRoutePlannerApp;
8-
import aimax.osm.gui.fx.applications.SimpleOsmAgentApp;
8+
import aimax.osm.gui.fx.applications.OsmAgentBaseApp;
99
import javafx.application.Application;
1010
import javafx.scene.Scene;
1111
import javafx.scene.layout.BorderPane;
@@ -39,7 +39,7 @@ public static void defineContent(IntegratedAppPaneBuilder builder) {
3939
IntegratedAimaFxApp.defineContent(builder);
4040

4141
builder.registerApp(OsmRoutePlannerApp.class);
42-
builder.registerApp(SimpleOsmAgentApp.class);
42+
builder.registerApp(OsmAgentBaseApp.class);
4343
builder.registerApp(OsmRouteFindingAgentApp.class);
4444
builder.registerApp(OsmLRTAStarAgentApp.class);
4545
}

aimax-osm/src/main/java/aimax/osm/gui/fx/applications/SimpleOsmAgentApp.java renamed to aimax-osm/src/main/java/aimax/osm/gui/fx/applications/OsmAgentBaseApp.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636

3737
/**
3838
* Simple OSM route finding agent application which can be used as base class
39-
* for more advanced OSM agent applications.
39+
* for more advanced OSM agent applications. For example, by overriding some of
40+
* the factory methods, it is easy to add parameters and change agent as well as
41+
* environment implementations.
4042
*
4143
* @author Ruediger Lunde
4244
*
4345
*/
44-
public class SimpleOsmAgentApp extends IntegrableApplication {
46+
public class OsmAgentBaseApp extends IntegrableApplication {
4547

4648
public static void main(String[] args) {
4749
launch(args);
@@ -62,7 +64,7 @@ public static void main(String[] args) {
6264

6365
@Override
6466
public String getTitle() {
65-
return "Simple OSM Agent App";
67+
return "OSM Agent Base App";
6668
}
6769

6870
/** Loads a map of the city of Ulm, Germany. Override to change the map. */
@@ -110,6 +112,14 @@ protected Agent createAgent(SearchForActions search, List<String> locations) {
110112
return new MapAgent(map, envViewCtrl::notify, search, new String[] { locations.get(1) });
111113
}
112114

115+
/**
116+
* Factory method which creates a new environment based on the current
117+
* parameter settings.
118+
*/
119+
protected MapEnvironment createEnvironment() {
120+
return new MapEnvironment(map);
121+
}
122+
113123
/**
114124
* Defines state view, parameters, and call-back functions and calls the
115125
* simulation pane builder to create layout and controller objects.
@@ -176,7 +186,7 @@ public void simulate() {
176186
}
177187
SearchForActions search = createSearch(locations);
178188
Agent agent = createAgent(search, locations);
179-
env = new MapEnvironment(map);
189+
env = createEnvironment();
180190
env.addEnvironmentView(new TrackUpdater());
181191
env.addAgent(agent, locations.get(0));
182192
if (simPaneCtrl.getParam(PARAM_SEARCH).isPresent())

aimax-osm/src/main/java/aimax/osm/gui/fx/applications/OsmRouteFindingAgentApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @author Ruediger Lunde
2626
*
2727
*/
28-
public class OsmRouteFindingAgentApp extends SimpleOsmAgentApp {
28+
public class OsmRouteFindingAgentApp extends OsmAgentBaseApp {
2929

3030
public static void main(String[] args) {
3131
launch(args);

0 commit comments

Comments
 (0)