Commit 81be0b1d authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev_GUI' into 'dev'

Open source release of CityDoctorGUI and other extensions.

See merge request !6
parents 12d96d95 5a4d0a74
Pipeline #10056 passed with stage
in 1 minute and 6 seconds
package de.hft.stuttgart.citydoctor2.gui;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.check.Checker;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
public class ValidationView extends View {
private static final Logger logger = LogManager.getLogger(ValidationView.class);
private Image viewLogo;
private MainWindow mainWindow;
private CityDoctorController controller;
public ValidationView(MainWindow mainWindow, CityDoctorController controller) {
this.mainWindow = mainWindow;
this.controller = controller;
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/error_stat32x32.png")) {
viewLogo = new Image(inStream);
} catch (IOException e) {
logger.catching(e);
}
}
@Override
public Node getMainScreen() {
return mainWindow.getMainContainer();
}
@Override
public Optional<HBox> getToolbar() {
return Optional.of(mainWindow.getMainToolbar().getToolBar());
}
@Override
public void onHide() {
Platform.runLater(() -> {
mainWindow.unselectEverything();
mainWindow.getMeshGroup().getChildren().clear();
mainWindow.clearHighlights();
mainWindow.getErrorTree().getRoot().getChildren().clear();
mainWindow.getPolygonsView().getRoot().getChildren().clear();
mainWindow.getVertexView().getRoot().getChildren().clear();
mainWindow.getEdgeView().getRoot().getChildren().clear();
});
}
@Override
public void onShow(CityDoctorModel model, Checker checker) {
if (model == null) {
return;
}
controller.buildTrees();
controller.updateFeatureTrees();
}
@Override
public Image getViewLogo() {
return viewLogo;
}
@Override
public void initializeView(MainWindow mainWindow) {
// already initialized
}
}
package de.hft.stuttgart.citydoctor2.gui;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import javafx.scene.input.MouseEvent;
public class VertexClickDispatcher implements ClickDispatcher {
private Vertex v;
public VertexClickDispatcher(Vertex v) {
this.v = v;
}
@Override
public void click(MouseEvent me, ClickHandler handler) {
handler.onVertexClick(v, me);
}
}
package de.hft.stuttgart.citydoctor2.gui;
import org.locationtech.proj4j.ProjCoordinate;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.gui.tree.Renderable;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TreeView;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
public class VertexClickHandler implements ClickHandler {
private TreeView<Renderable> errorView;
private Renderer renderer;
private Stage stage;
private ParserConfiguration config;
public VertexClickHandler(TreeView<Renderable> errorView, Renderer renderer, Stage stage) {
this.errorView = errorView;
this.renderer = renderer;
this.stage = stage;
}
public void setConfig(ParserConfiguration config) {
this.config = config;
}
@Override
public void onPolygonClick(Polygon p, MouseEvent me) {
if (me.getButton() == MouseButton.PRIMARY) {
errorView.getSelectionModel().clearSelection();
renderer.highlight(p);
} else if (me.getButton() == MouseButton.SECONDARY) {
MenuItem mi = new MenuItem(p.getGmlId().getGmlString());
ContextMenu cMenu = new ContextMenu(mi);
cMenu.show(stage, me.getScreenX(), me.getScreenY());
}
}
@Override
public void onVertexClick(Vertex v, MouseEvent me) {
if (me.getButton() == MouseButton.SECONDARY) {
MenuItem mi1 = new CustomMenuItem(new Label("Vertex"));
double x = v.getX();
double y = v.getY();
if (config.getOriginalTransform() != null) {
ProjCoordinate p1 = new ProjCoordinate();
ProjCoordinate p2 = new ProjCoordinate();
p1.x = v.getX();
p1.y = v.getY();
config.getOriginalTransform().transform(p1, p2);
x = p2.x;
y = p2.y;
}
MenuItem mi2 = new MenuItem("x = " + x);
MenuItem mi3 = new MenuItem("y = " + y);
MenuItem mi4 = new MenuItem("z = " + v.getZ());
ContextMenu cMenu = new ContextMenu(mi1, mi2, mi3, mi4);
cMenu.show(stage, me.getScreenX(), me.getScreenY());
}
}
}
package de.hft.stuttgart.citydoctor2.gui;
import java.util.Optional;
import de.hft.stuttgart.citydoctor2.check.Checker;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
public abstract class View {
private boolean firstTime = true;
public abstract Optional<HBox> getToolbar();
public abstract Node getMainScreen();
public abstract Image getViewLogo();
public abstract void initializeView(MainWindow mainWindow);
public void fireOnShowEvent(CityDoctorModel model, Checker checker, MainWindow mainWindow) {
if (firstTime) {
firstTime = false;
initializeView(mainWindow);
}
onShow(model, checker);
}
public abstract void onHide();
public abstract void onShow(CityDoctorModel model, Checker checker);
}
package de.hft.stuttgart.citydoctor2.gui;
import java.util.LinkedHashSet;
import java.util.Set;
public class ViewRegistration {
private static Set<View> registeredViews = new LinkedHashSet<>();
private static View currentActiveView;
private ViewRegistration() {
// only static use
}
public static void registerView(View v) {
registeredViews.add(v);
}
public static Set<View> getRegisteredViews() {
return registeredViews;
}
static void setCurrentActiveView(View v) {
currentActiveView = v;
}
public static View getCurrentActiveView() {
return currentActiveView;
}
}
package de.hft.stuttgart.citydoctor2.gui;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import javafx.application.Platform;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.util.StringConverter;
public class WriteReportDialog {
private static Logger logger = LogManager.getLogger(WriteReportDialog.class);
private Stage stage;
private CityDoctorController controller;
private MainWindow mainWindow;
@FXML
private CheckBox pdfCheckBox;
@FXML
private TextField pdfFileField;
@FXML
private Button selectPdfBtn;
@FXML
private CheckBox xmlCheckBox;
@FXML
private TextField xmlFileField;
@FXML
private Button selectXmlFile;
@FXML
private Button cancelBtn;
@FXML
private Button writeBtn;
@FXML
private BarChart<String, Number> barChart;
@FXML
private Button saveImageBtn;
@FXML
private Label errorStatisticsLabel;
public WriteReportDialog(Stage parent, CityDoctorController controller, MainWindow mainWindow) throws IOException {
FXMLLoader loader = new FXMLLoader(WriteReportDialog.class.getResource("WriteReportDialog.fxml"));
loader.setController(this);
VBox box = loader.load();
this.controller = controller;
this.mainWindow = mainWindow;
stage = new Stage();
stage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("icons/CityDoctor-Logo-rot_klein.jpg")));
stage.setScene(new Scene(box));
stage.initOwner(parent);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("Write Reports");
stage.setOnHidden(we -> barChart.getData().clear());
setMaximumWidthOfBarChartColumns();
}
private void setMaximumWidthOfBarChartColumns() {
double maxBarWidth = 40;
double minCategoryGap = 10;
// setting maximum width of columns in bar chart
// from https://stackoverflow.com/questions/27302875/set-bar-chart-column-width-size
stage.getScene().widthProperty().addListener((obs, n, n1) -> {
if (barChart.getData().isEmpty())
return;
setCategoryWidthWhenWindowIsBigger(maxBarWidth, n, n1);
if (n != null && (n1.doubleValue() < n.doubleValue()) && barChart.getCategoryGap() > minCategoryGap) {
double barWidth;
CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis();
do {
double catSpace = xAxis.getCategorySpacing();
double avilableBarSpace = catSpace - (minCategoryGap + barChart.getBarGap());
barWidth = Math.min(maxBarWidth,
(avilableBarSpace / barChart.getData().size()) - barChart.getBarGap());
avilableBarSpace = (barWidth + barChart.getBarGap()) * barChart.getData().size();
barChart.setCategoryGap(catSpace - avilableBarSpace - barChart.getBarGap());
} while (barWidth < maxBarWidth && barChart.getCategoryGap() > minCategoryGap);
}
});
}
private void setCategoryWidthWhenWindowIsBigger(double maxBarWidth, Number n, Number n1) {
if (n != null && (n1.doubleValue() > n.doubleValue())) {
double barWidth;
CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis();
do {
double catSpace = xAxis.getCategorySpacing();
double avilableBarSpace = catSpace - (barChart.getCategoryGap() + barChart.getBarGap());
barWidth = (avilableBarSpace / barChart.getData().size()) - barChart.getBarGap();
if (barWidth > maxBarWidth) {
avilableBarSpace = (maxBarWidth + barChart.getBarGap()) * barChart.getData().size();
barChart.setCategoryGap(catSpace - avilableBarSpace - barChart.getBarGap());
}
} while (barWidth > maxBarWidth);
}
}
public void initialize() {
writeBtn.setText(Localization.getText("WriteReportDialog.writeBtn"));
cancelBtn.setText(Localization.getText("WriteReportDialog.cancelBtn"));
errorStatisticsLabel.setText(Localization.getText("WriteReportDialog.errorStatisticsLabel"));
saveImageBtn.setText(Localization.getText("WriteReportDialog.saveImageBtn"));
selectPdfBtn.setText(Localization.getText("WriteReportDialog.selectPdfBtn"));
selectXmlFile.setText(Localization.getText("WriteReportDialog.selectXmlFile"));
barChart.getXAxis().setLabel(Localization.getText("WriteReportDialog.xAxisLabel"));
barChart.getYAxis().setLabel(Localization.getText("WriteReportDialog.yAxisLabel"));
// formatter to display only whole numbers
NumberAxis yAxis = (NumberAxis) barChart.getYAxis();
yAxis.setTickLabelFormatter(new StringConverter<>() {
@Override
public String toString(Number object) {
if (object.doubleValue() % 1 < 0.00000001) {
return String.valueOf(object.intValue());
} else {
return "";
}
}
@Override
public Number fromString(String string) {
return Integer.parseInt(string);
}
});
saveImageBtn.setOnAction(ae -> {
FileChooser chooser = new FileChooser();
chooser.setInitialDirectory(new File("."));
chooser.getExtensionFilters().add(new ExtensionFilter("PNG-Image", "*.png"));
String fName = controller.getFileName();
fName = fName.substring(0, fName.lastIndexOf('.'));
chooser.setInitialFileName(fName + "_errors.png");
File imageFile = chooser.showSaveDialog(stage);
if (imageFile != null) {
WritableImage snapshot = barChart.snapshot(new SnapshotParameters(), null);
try {
ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), "png", imageFile);
} catch (IOException e) {
logger.error("Failed to save image", e);
mainWindow.showExceptionDialog(e);
}
}
});
pdfCheckBox.selectedProperty().addListener((obs, oldV, newV) -> {
selectPdfBtn.setDisable(!newV);
pdfFileField.setDisable(!newV);
});
xmlCheckBox.selectedProperty().addListener((obs, oldV, newV) -> {
selectXmlFile.setDisable(!newV);
xmlFileField.setDisable(!newV);
});
selectPdfBtn.setOnAction(ae -> {
FileChooser chooser = new FileChooser();
chooser.setTitle("Select PDF File");
chooser.getExtensionFilters().add(new ExtensionFilter("PDF-Files", ".pdf"));
File pdfFile = chooser.showSaveDialog(stage);
if (pdfFile != null) {
pdfFileField.setText(pdfFile.getAbsolutePath());
}
});
selectXmlFile.setOnAction(ae -> {
FileChooser chooser = new FileChooser();
chooser.setTitle("Select XML File");
chooser.getExtensionFilters().add(new ExtensionFilter("XML-Files", ".xml"));
File xmlFile = chooser.showSaveDialog(stage);
if (xmlFile != null) {
xmlFileField.setText(xmlFile.getAbsolutePath());
}
});
initWriteButton();
cancelBtn.setOnAction(ae -> stage.close());
}
private void initWriteButton() {
writeBtn.setOnAction(ae -> {
stage.setOnCloseRequest(Event::consume);
cancelBtn.setDisable(true);
writeBtn.setDisable(true);
Thread t = new Thread(() -> {
try {
if (pdfCheckBox.isSelected()) {
String file = pdfFileField.getText();
File pdfFile = new File(file);
File parentFile = pdfFile.getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
controller.writePdfReport(pdfFile);
}
if (xmlCheckBox.isSelected()) {
String file = xmlFileField.getText();
File xmlFile = new File(file);
File parentFile = xmlFile.getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
controller.writeXmlReport(xmlFile);
}
} finally {
Platform.runLater(() -> {
stage.setOnCloseRequest(null);
cancelBtn.setDisable(false);
writeBtn.setDisable(false);
stage.close();
});
}
});
t.start();
});
}
public void show() {
XYChart.Series<String, Number> series = controller.createErrorSeries();
barChart.getData().clear();
barChart.getData().add(series);
stage.show();
}
}
package de.hft.stuttgart.citydoctor2.gui.filter;
import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
public class TypeFilterSelection {
private final FeatureType type;
private final String name;
public TypeFilterSelection(FeatureType type, String name) {
this.type = type;
this.name = name;
}
public FeatureType getType() {
return type;
}
@Override
public String toString() {
return name;
}
}
package de.hft.stuttgart.citydoctor2.gui.filter;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
public abstract class ViewFilter {
private boolean enabled = true;
protected abstract boolean useGeometry(CityObject co, Geometry geom);
public boolean allowedToUse(CityObject co, Geometry geom) {
if (!enabled) {
return false;
}
return useGeometry(co, geom);
}
public boolean isEnabled() {
return enabled;
}
public void enable() {
enabled = true;
}
public void disable() {
enabled = false;
}
public void setEnable(boolean enabled) {
this.enabled = enabled;
}
}
package de.hft.stuttgart.citydoctor2.gui.logger;
import java.io.Serializable;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import org.apache.logging.log4j.core.layout.PatternLayout;
import javafx.application.Platform;
import javafx.scene.control.TextArea;
@Plugin(name="GuiLogger", category="Core", elementType="appender", printObject=true)
public class GuiLogger extends AbstractAppender {
private static TextArea area;
private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
private final Lock readLock = rwLock.readLock();
private static final int CAPACITY = 20000;
private final StringBuilder buffer = new StringBuilder(CAPACITY);
private Thread daemonLoggerThread;
private boolean dirty = false;
public static void setTextArea(TextArea area) {
GuiLogger.area = area;
}
@PluginFactory
public static GuiLogger createAppender(
@PluginAttribute("name") String name,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter) {
if (name == null) {
LOGGER.error("No name provided for GuiLogger");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
GuiLogger guiLogger = new GuiLogger(name, filter, layout, ignoreExceptions, new Property[0]);
guiLogger.daemonLoggerThread = new Thread(() -> {
while (!Thread.interrupted()) {
if (guiLogger.dirty) {
Platform.runLater(() -> {
// set text doesn't scroll
// workaround with clear -> append
area.clear();
area.appendText(guiLogger.buffer.toString());
});
guiLogger.dirty = false;
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
});
guiLogger.daemonLoggerThread.setDaemon(true);
guiLogger.daemonLoggerThread.start();
return guiLogger;
}
protected GuiLogger(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
}
@Override
public void append(LogEvent event) {
if (area == null) {
return;
}
readLock.lock();
try {
String s = new String(getLayout().toByteArray(event));
int capacityLeft = CAPACITY - buffer.length();
if (capacityLeft < s.length()) {
int delete = s.length() - capacityLeft;
buffer.delete(0, delete - 1);
}
buffer.append(s);
dirty = true;
} finally {
readLock.unlock();
}
}
}
package de.hft.stuttgart.citydoctor2.gui.table;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
public class ErrorStat {
private final SimpleObjectProperty<ErrorId> errorId = new SimpleObjectProperty<>();
private final SimpleIntegerProperty count = new SimpleIntegerProperty();
public ErrorStat(ErrorId errorId) {
this(errorId, 0);
}
public ErrorStat(ErrorId errorId, int count) {
this.errorId.set(errorId);
this.count.set(count);
}
public int getCount() {
return count.get();
}
public IntegerProperty getCountProperty() {
return count;
}
public ObjectProperty<ErrorId> getErrorIdProperty() {
return errorId;
}
public void setCount(int count) {
this.count.set(count);
}
public void incrementCount() {
count.set(count.get() + 1);
}
public ErrorId getErrorId() {
return errorId.get();
}
public void setErrorId(ErrorId errorId) {
this.errorId.set(errorId);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "ErrorStat [errorId=" + errorId + ", count=" + count + "]";
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBoundarySurfacesNode extends Renderable {
private final List<BoundarySurface> boundarySurfaces;
public AllBoundarySurfacesNode(List<BoundarySurface> boundarySurfaces) {
this.boundarySurfaces = boundarySurfaces;
}
@Override
public String getText() {
return "Boundary Surfaces";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
@Override
public void refreshTextColor() {
boolean isValidated = false;
for (BoundarySurface bs : boundarySurfaces) {
if (bs.isValidated()) {
isValidated = true;
}
if (bs.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
if (isValidated) {
setStatus(CheckStatus.OK);
} else {
setStatus(CheckStatus.NOT_CHECKED);
}
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgeConstructiveElementsNode extends Renderable {
private final List<BridgeConstructiveElement> constructiveElements;
public AllBridgeConstructiveElementsNode(List<BridgeConstructiveElement> constructiveElements) {
this.constructiveElements = constructiveElements;
}
@Override
public String getText() {
return "Constructive Elements";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
@Override
public void refreshTextColor() {
boolean isValidated = false;
for (BridgeConstructiveElement bce : constructiveElements) {
if (bce.isValidated()) {
isValidated = true;
}
if (bce.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
if (isValidated) {
setStatus(CheckStatus.OK);
} else {
setStatus(CheckStatus.NOT_CHECKED);
}
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgePartsNode extends Renderable {
private final List<BridgeObject> bridgeParts;
public AllBridgePartsNode(List<BridgeObject> bridgeParts) {
this.bridgeParts = bridgeParts;
}
@Override
public String getText() {
return "Bridge Parts";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
@Override
public void refreshTextColor() {
boolean wasChecked = false;
for (BridgeObject bp : bridgeParts) {
if (bp.isValidated()) {
wasChecked = true;
if (bp.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
}
if (wasChecked) {
setStatus(CheckStatus.OK);
} else {
setStatus(CheckStatus.NOT_CHECKED);
}
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgesNode extends Renderable {
private final List<BridgeObject> bridges;
public AllBridgesNode(List<BridgeObject> bridges) {
this.bridges = bridges;
}
@Override
public void refreshTextColor() {
// no color changes
}
@Override
public String getText() {
return "Bridges";
}
@Override
public void visit(Renderer renderer) {
renderer.renderBridges(bridges);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBuildingPartsNode extends Renderable {
private final List<BuildingPart> buildingParts;
public AllBuildingPartsNode(List<BuildingPart> buildingParts) {
this.buildingParts = buildingParts;
}
@Override
public String getText() {
return "Building Parts";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
@Override
public void refreshTextColor() {
boolean wasChecked = false;
for (BuildingPart bp : buildingParts) {
if (bp.isValidated()) {
wasChecked = true;
if (bp.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
}
if (wasChecked) {
setStatus(CheckStatus.OK);
} else {
setStatus(CheckStatus.NOT_CHECKED);
}
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBuildingsNode extends Renderable {
private final List<Building> buildings;
public AllBuildingsNode(List<Building> buildings) {
this.buildings = buildings;
}
@Override
public void refreshTextColor() {
// no color changes
}
@Override
public String getText() {
return "Buildings";
}
@Override
public void visit(Renderer renderer) {
renderer.renderBuildings(buildings);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllInstallationsNode extends Renderable {
private final List<Installation> buildingInstallations;
public AllInstallationsNode(List<Installation> bis) {
this.buildingInstallations = bis;
}
@Override
public String getText() {
return "Building Installations";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
@Override
public void refreshTextColor() {
boolean wasChecked = false;
for (Installation bp : buildingInstallations) {
if (bp.isValidated()) {
wasChecked = true;
if (bp.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
}
if (wasChecked) {
setStatus(CheckStatus.OK);
} else {
setStatus(CheckStatus.NOT_CHECKED);
}
}
}
\ No newline at end of file
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllOpeningsNode extends Renderable {
private final List<Opening> openings;
public AllOpeningsNode(List<Opening> openings) {
this.openings = openings;
}
@Override
public void refreshTextColor() {
for (Opening bp : openings) {
if (bp.containsAnyError()) {
setStatus(CheckStatus.ERROR);
return;
}
}
setStatus(CheckStatus.OK);
}
@Override
public String getText() {
return "Openings";
}
@Override
public void visit(Renderer renderer) {
renderer.clearCurrentRender();
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllTerrainNode extends Renderable {
private final List<CityObject> land;
public AllTerrainNode(List<CityObject> land) {
this.land = land;
}
@Override
public void refreshTextColor() {
// no use
}
@Override
public String getText() {
return "Terrain";
}
@Override
public void visit(Renderer renderer) {
renderer.renderTerrain(land);
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllTinNode extends Renderable {
public AllTinNode(List<TinObject> components) {
// TODO Auto-generated constructor stub
}
@Override
public void refreshTextColor() {
// TODO Auto-generated method stub
}
@Override
public String getText() {
return "Components";
}
@Override
public void visit(Renderer renderer) {
// TODO Auto-generated method stub
}
}
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