+ setupDrawMapEnabled();
+ setupBackgroundColor();
+ setupColoringObjects();
+ setupColorBarOptions();
+ setupSizingObjects();
+ setupSizeBarOptions();
+ setupShowElevationServerBoundingBox();
+
+ // add listeners
+ DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
+ if (listeners != null) {
+ for (DistrictDiagramViewerListener listener : listeners) {
+ listener.diagramLoaded(getRuntime(), canvasContext);
+ }
+ }
+ }
+
+ @Override
+ public void dispose() {
+ DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
+ if (listeners != null) {
+ Resource runtime = getRuntime();
+ for (DistrictDiagramViewerListener listener : listeners) {
+ listener.diagramDisposed(runtime, canvasContext);
+ }
+ }
+ super.dispose();
+ }
+
+ private void setupDrawMapEnabled() {
+ sessionContext.getSession().asyncRequest(new DrawMapEnabledRequest(getInputResource()), new DrawMapEnabledListener(
+ result -> canvasContext.getEventQueue().queueEvent(new CommandEvent(canvasContext, System.currentTimeMillis(), result ? Commands.MAP_ENABLE : Commands.MAP_DISABLE)),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ private void setupBackgroundColor() {
+ sessionContext.getSession().asyncRequest(new MapBackgroundColorRequest(getInputResource()), new MapBackgroundColorListener(
+ result -> queueBackgroundColorChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ private void queueBackgroundColorChangeEvent(RGB.Integer result) {
+ if (result != null) {
+ Color backgroundColor = new Color(result.red, result.green, result.blue);
+ canvasContext.getDefaultHintContext().setHint(MapCommands.KEY_MAP_BACKGROUND_COLOR, backgroundColor);
+ canvasContext.getEventQueue().queueEvent(new CommandEvent(canvasContext, System.currentTimeMillis(), MapCommands.MAP_BACKGROUND_COLOR_CHANGE));
+ }
+ }
+
+ private void setupColoringObjects() {
+ sessionContext.getSession().asyncRequest(new ColoringObjectsRequest(getInputResource()), new ColoringObjectsListener(
+ result -> queueColoringObjectsChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+
+ private void setupColorBarOptions() {
+ sessionContext.getSession().asyncRequest(new ColorBarOptionsRequest(getInputResource()), new ColorBarOptionsListener(
+ result -> queueColorBarOptionsChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ private void setupSizingObjects() {
+ sessionContext.getSession().asyncRequest(new SizingObjectsRequest(getInputResource()), new SizingObjectsListener(
+ result -> queueSizingObjectsChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ private void setupSizeBarOptions() {
+ sessionContext.getSession().asyncRequest(new SizeBarOptionsRequest(getInputResource()), new SizeBarOptionsListener(
+ result -> queueSizeBarOptionsChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ private void setupShowElevationServerBoundingBox() {
+ sessionContext.getSession().asyncRequest(new ShowElevationServerRequest(getInputResource()), new ShowElevationServerListener(
+ result -> queueShowElevationServerChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
+ public static final Key KEY_MAP_COLOR_BAR_OPTIONS = new KeyOf(ColorBarOptions.class, "colorBarOptions");
+ public static final Command MAP_COLOR_BAR_OPTIONS_CHANGE = new Command("colorBarOptionsChange");
+ public static final Key KEY_MAP_SIZE_BAR_OPTIONS = new KeyOf(SizeBarOptions.class, "sizeBarOptions");
+ public static final Command MAP_SIZE_BAR_OPTIONS_CHANGE = new Command("sizeBarOptionsChange");
+
+ public static final Key KEY_MAP_COLORING_OBJECTS = new KeyOf(Map.class, "coloringObjects");
+ public static final Command MAP_COLORING_OBJECTS_CHANGE = new Command("coloringObjectsChange");
+
+ public static final Key KEY_MAP_SIZING_OBJECTS = new KeyOf(Map.class, "sizingObjects");
+ public static final Command MAP_SIZING_OBJECTS_CHANGE = new Command("sizingObjectsChange");
+
+ public static final Key KEY_SHOW_ELEVATION_SERVER = new KeyOf(Boolean.class, "showElevationServer");
+ public static final Command SHOW_ELEVATION_SERVER_CHANGE = new Command("showElevationServerChange");
+
+ private void queueColoringObjectsChangeEvent(Map<String, DynamicColorContribution> result) {
+ queueEventInternal(KEY_MAP_COLORING_OBJECTS, MAP_COLORING_OBJECTS_CHANGE, result);
+ }