Commit 596ded22 authored by Riegel's avatar Riegel
Browse files

Rework focusing method

parent d2f701da
...@@ -14,15 +14,18 @@ import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException; ...@@ -14,15 +14,18 @@ import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException; import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ProgressListener; import de.hft.stuttgart.citydoctor2.parser.ProgressListener;
import de.hft.stuttgart.citydoctor2.utils.Localization; import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.utils.Pair;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.embed.swing.SwingFXUtils; import javafx.embed.swing.SwingFXUtils;
import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.*; import javafx.scene.*;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.skin.VirtualFlow;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage; import javafx.scene.image.WritableImage;
...@@ -1147,43 +1150,40 @@ public class MainWindow extends Application { ...@@ -1147,43 +1150,40 @@ public class MainWindow extends Application {
} }
public void showCityObjectDetail(CityObject co) { public void showCityObjectDetail(CityObject co) {
Pair<Tab, TreeView<Renderable>> tabPair = getFeatureTabOf(co);
Tab featureTab = tabPair.getValue0();
TreeView<Renderable> featureView = tabPair.getValue1();
featurePane.getSelectionModel().select(featureTab);
searchField.setText(co.getGmlId().getGmlString());
searchBtn.fire();
featureView.getSelectionModel().select(0);
featureView.getSelectionModel().getSelectedItem().getValue().visit(renderer);
}
private Pair<Tab,TreeView<Renderable>> getFeatureTabOf(CityObject co) {
FeatureType coType = co.getFeatureType(); FeatureType coType = co.getFeatureType();
TreeView<Renderable> featureView;
Tab featureTab;
if (coType == FeatureType.BUILDING){ if (coType == FeatureType.BUILDING){
featureView = buildingsView; return new Pair<>(buildingsTab, buildingsView);
featureTab = buildingsTab;
} else if (coType == FeatureType.VEGETATION){ } else if (coType == FeatureType.VEGETATION){
featureView = vegetationView; return new Pair<>(vegetationTab, vegetationView);
featureTab = vegetationTab;
} else if (coType == FeatureType.TRANSPORTATION){ } else if (coType == FeatureType.TRANSPORTATION){
featureView = transView; return new Pair<>(transportationTab,transView);
featureTab = transportationTab;
} else if (coType == FeatureType.TUNNEL){ } else if (coType == FeatureType.TUNNEL){
featureView = tunnelView; return new Pair<>(tunnelTab, tunnelView);
featureTab = tunnelTab;
} else if (coType == FeatureType.BRIDGE){ } else if (coType == FeatureType.BRIDGE){
featureView = bridgeView; return new Pair<>(bridgeTab, bridgeView);
featureTab = bridgeTab;
} else if (coType == FeatureType.WATER){ } else if (coType == FeatureType.WATER){
featureView = waterView; return new Pair<>(waterTab, waterView);
featureTab = waterTab;
} else if (coType == FeatureType.LAND){ } else if (coType == FeatureType.LAND){
featureView = terrainView; return new Pair<>(terrainTab, terrainView);
featureTab = terrainTab;
} else if (coType == FeatureType.CITY_FURNITURE){ } else if (coType == FeatureType.CITY_FURNITURE){
featureView = cityFurnitureView; return new Pair<>(cityFurnitureTab, cityFurnitureView);
featureTab = cityFurnitureTab;
} else if (coType == FeatureType.GENERIC_CITY_OBJECT){ } else if (coType == FeatureType.GENERIC_CITY_OBJECT){
featureView = otherObjectsView; return new Pair<>(otherObjectsTab, otherObjectsView);
featureTab = otherObjectsTab;
} else { } else {
throw new IllegalArgumentException("unknown feature type: " + coType); throw new IllegalArgumentException("unknown feature type: " + coType);
} }
featurePane.getSelectionModel().select(featureTab);
searchField.setText(co.getGmlId().getGmlString());
searchBtn.fire();
renderer.render(co);
} }
public MainToolBar getMainToolbar() { public MainToolBar getMainToolbar() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment