Commit 9ba8a6ef authored by Riegel's avatar Riegel
Browse files

Code cleaning. Ref #69

parent 1d8506eb
Pipeline #10053 passed with stage
in 1 minute and 13 seconds
...@@ -61,11 +61,8 @@ public record HealingID(String idString) { ...@@ -61,11 +61,8 @@ public record HealingID(String idString) {
return false; return false;
HealingID other = (HealingID) obj; HealingID other = (HealingID) obj;
if (idString == null) { if (idString == null) {
if (other.idString != null) return other.idString == null;
return false; } else return idString.equals(other.idString);
} else if (!idString.equals(other.idString))
return false;
return true;
} }
......
...@@ -384,7 +384,7 @@ public class CheckDialog { ...@@ -384,7 +384,7 @@ public class CheckDialog {
private void collectCheckInformationFromTree(ValidationConfiguration config, TreeTableView<TreeRequirement> table) { private void collectCheckInformationFromTree(ValidationConfiguration config, TreeTableView<TreeRequirement> table) {
for (TreeItem<TreeRequirement> ti : table.getRoot().getChildren()) { for (TreeItem<TreeRequirement> ti : table.getRoot().getChildren()) {
Requirement r = ti.getValue().getRequirement(); Requirement r = ti.getValue().getRequirement();
if (ti.getValue().getEnabledProperty().getValue().booleanValue()) { if (ti.getValue().getEnabledProperty().getValue()) {
RequirementConfiguration cc = config.getRequirements().get(r.getId()); RequirementConfiguration cc = config.getRequirements().get(r.getId());
cc.setEnabled(ti.getValue().isEnabled()); cc.setEnabled(ti.getValue().isEnabled());
// collect parameters // collect parameters
...@@ -491,7 +491,7 @@ public class CheckDialog { ...@@ -491,7 +491,7 @@ public class CheckDialog {
return null; return null;
}); });
StringConverter<Boolean> converter = new StringConverter<Boolean>() { StringConverter<Boolean> converter = new StringConverter<>() {
@Override @Override
public String toString(Boolean object) { public String toString(Boolean object) {
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
*/ */
package de.hft.stuttgart.citydoctor2.gui; package de.hft.stuttgart.citydoctor2.gui;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import de.hft.stuttgart.citydoctor2.check.Unit; import de.hft.stuttgart.citydoctor2.check.Unit;
public class GlobalParameter implements Serializable { public class GlobalParameter implements Serializable {
@Serial
private static final long serialVersionUID = 1423983452743345752L; private static final long serialVersionUID = 1423983452743345752L;
private String name; private String name;
...@@ -80,11 +82,8 @@ public class GlobalParameter implements Serializable { ...@@ -80,11 +82,8 @@ public class GlobalParameter implements Serializable {
if (unit != other.unit) if (unit != other.unit)
return false; return false;
if (value == null) { if (value == null) {
if (other.value != null) return other.value == null;
return false; } else return value.equals(other.value);
} else if (!value.equals(other.value))
return false;
return true;
} }
@Override @Override
......
...@@ -55,8 +55,7 @@ public class HighlightController { ...@@ -55,8 +55,7 @@ public class HighlightController {
} }
double edgeSize = scale / 10; double edgeSize = scale / 10;
for (Node n : edges.getChildren()) { for (Node n : edges.getChildren()) {
if (n instanceof Cylinder) { if (n instanceof Cylinder cy) {
Cylinder cy = (Cylinder) n;
cy.setRadius(edgeSize); cy.setRadius(edgeSize);
} }
} }
...@@ -106,7 +105,7 @@ public class HighlightController { ...@@ -106,7 +105,7 @@ public class HighlightController {
highlightPoint(movedBy, v, pointColor); highlightPoint(movedBy, v, pointColor);
} }
for (int i = 0; i < ring.getVertices().size() - 1; i++) { for (int i = 0; i < ring.getVertices().size() - 1; i++) {
Vertex v1 = ring.getVertices().get(i + 0); Vertex v1 = ring.getVertices().get(i);
Vertex v2 = ring.getVertices().get(i + 1); Vertex v2 = ring.getVertices().get(i + 1);
highlightEdge(v1, v2, movedBy); highlightEdge(v1, v2, movedBy);
} }
...@@ -189,21 +188,21 @@ public class HighlightController { ...@@ -189,21 +188,21 @@ public class HighlightController {
clearHighlights(); clearHighlights();
for (int i = 0; i < components.size(); i++) { for (int i = 0; i < components.size(); i++) {
Color extColor; Color extColor;
Color intColor; Color intColor = switch (i % 3) {
// select some color pairs for exterior and inner rings case 1 -> {
switch (i % 3) {
case 1:
extColor = Color.GREEN; extColor = Color.GREEN;
intColor = Color.YELLOW; yield Color.YELLOW;
break; }
case 2: case 2 -> {
extColor = Color.BROWN; extColor = Color.BROWN;
intColor = Color.VIOLET; yield Color.VIOLET;
break; }
default: default -> {
extColor = Color.RED; extColor = Color.RED;
intColor = Color.BLUE; yield Color.BLUE;
} }
};
// select some color pairs for exterior and inner rings
List<Polygon> component = components.get(i); List<Polygon> component = components.get(i);
for (Polygon p : component) { for (Polygon p : component) {
addHighlight(p, currentTriGeom, extColor, intColor); addHighlight(p, currentTriGeom, extColor, intColor);
......
...@@ -560,7 +560,7 @@ public class MainWindow extends Application { ...@@ -560,7 +560,7 @@ public class MainWindow extends Application {
Localization.getText("MainWindow.withErrors")); Localization.getText("MainWindow.withErrors"));
showCityObjectsCombo.getSelectionModel().selectFirst(); showCityObjectsCombo.getSelectionModel().selectFirst();
showCityObjectsCombo.setCellFactory(param -> new ListCell<String>() { showCityObjectsCombo.setCellFactory(param -> new ListCell<>() {
@Override @Override
public void updateItem(String item, boolean empty) { public void updateItem(String item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
...@@ -681,8 +681,7 @@ public class MainWindow extends Application { ...@@ -681,8 +681,7 @@ public class MainWindow extends Application {
MenuItem mi = new MenuItem(Localization.getText("MainWindow.export")); MenuItem mi = new MenuItem(Localization.getText("MainWindow.export"));
mi.setOnAction(ea -> { mi.setOnAction(ea -> {
Renderable render = buildingsView.getSelectionModel().getSelectedItem().getValue(); Renderable render = buildingsView.getSelectionModel().getSelectedItem().getValue();
if (render instanceof BuildingNode) { if (render instanceof BuildingNode node) {
BuildingNode node = (BuildingNode) render;
controller.export(node.getBuilding()); controller.export(node.getBuilding());
} }
}); });
...@@ -756,8 +755,7 @@ public class MainWindow extends Application { ...@@ -756,8 +755,7 @@ public class MainWindow extends Application {
Node node = me.getPickResult().getIntersectedNode(); Node node = me.getPickResult().getIntersectedNode();
if (node != null) { if (node != null) {
Object o = node.getUserData(); Object o = node.getUserData();
if (o instanceof ClickDispatcher) { if (o instanceof ClickDispatcher cd) {
ClickDispatcher cd = (ClickDispatcher) o;
cd.click(me, clickHandler); cd.click(me, clickHandler);
} }
} }
......
...@@ -13,7 +13,7 @@ import org.apache.logging.log4j.Logger; ...@@ -13,7 +13,7 @@ import org.apache.logging.log4j.Logger;
public class Settings { public class Settings {
private static Logger logger = LogManager.getLogger(Settings.class); private static final Logger logger = LogManager.getLogger(Settings.class);
public static final String LAST_OPEN_FOLDER = "lastOpenFolder"; public static final String LAST_OPEN_FOLDER = "lastOpenFolder";
public static final String MAXIMIZED = "maximized"; public static final String MAXIMIZED = "maximized";
......
...@@ -83,7 +83,7 @@ public class TableEditCell<S, T> extends TableCell<S, T> { ...@@ -83,7 +83,7 @@ public class TableEditCell<S, T> extends TableCell<S, T> {
* Convenience converter that does nothing (converts Strings to themselves and * Convenience converter that does nothing (converts Strings to themselves and
* vice-versa...). * vice-versa...).
*/ */
public static final StringConverter<String> IDENTITY_CONVERTER = new StringConverter<String>() { public static final StringConverter<String> IDENTITY_CONVERTER = new StringConverter<>() {
@Override @Override
public String toString(String object) { public String toString(String object) {
......
...@@ -17,7 +17,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Geometry; ...@@ -17,7 +17,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.Opening; import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.OpeningType; import de.hft.stuttgart.citydoctor2.datastructure.OpeningType;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.gui.filter.ViewFilter; import de.hft.stuttgart.citydoctor2.gui.filter.ViewFilter;
import de.hft.stuttgart.citydoctor2.math.Triangle3d; import de.hft.stuttgart.citydoctor2.math.Triangle3d;
import de.hft.stuttgart.citydoctor2.math.UnitVector3d; import de.hft.stuttgart.citydoctor2.math.UnitVector3d;
...@@ -52,9 +51,7 @@ public class TriangulatedGeometry { ...@@ -52,9 +51,7 @@ public class TriangulatedGeometry {
triGeom.meshes = new ArrayList<>(); triGeom.meshes = new ArrayList<>();
List<Vector3d> points = new ArrayList<>(); List<Vector3d> points = new ArrayList<>();
for (Polygon p : polygons) { for (Polygon p : polygons) {
for (Vertex v : p.getExteriorRing().getVertices()) { points.addAll(p.getExteriorRing().getVertices());
points.add(v);
}
} }
triGeom.movedBy = triGeom.findCenter(points); triGeom.movedBy = triGeom.findCenter(points);
...@@ -200,9 +197,7 @@ public class TriangulatedGeometry { ...@@ -200,9 +197,7 @@ public class TriangulatedGeometry {
if (p.isLink()) { if (p.isLink()) {
continue; continue;
} }
for (Vertex v : p.getExteriorRing().getVertices()) { points.addAll(p.getExteriorRing().getVertices());
points.add(v);
}
} }
} }
} }
...@@ -261,8 +256,7 @@ public class TriangulatedGeometry { ...@@ -261,8 +256,7 @@ public class TriangulatedGeometry {
return baseColor; return baseColor;
} }
CityObject parent = p.getParent().getParent(); CityObject parent = p.getParent().getParent();
if (parent instanceof Opening) { if (parent instanceof Opening op) {
Opening op = (Opening) parent;
if (op.getType() == OpeningType.DOOR) { if (op.getType() == OpeningType.DOOR) {
baseColor = Color.ORANGE; baseColor = Color.ORANGE;
} else { } else {
......
...@@ -102,7 +102,7 @@ public class WriteReportDialog { ...@@ -102,7 +102,7 @@ public class WriteReportDialog {
setCategoryWidthWhenWindowIsBigger(maxBarWidth, n, n1); setCategoryWidthWhenWindowIsBigger(maxBarWidth, n, n1);
if (n != null && (n1.doubleValue() < n.doubleValue()) && barChart.getCategoryGap() > minCategoryGap) { if (n != null && (n1.doubleValue() < n.doubleValue()) && barChart.getCategoryGap() > minCategoryGap) {
double barWidth = 0; double barWidth;
CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis(); CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis();
do { do {
double catSpace = xAxis.getCategorySpacing(); double catSpace = xAxis.getCategorySpacing();
...@@ -118,7 +118,7 @@ public class WriteReportDialog { ...@@ -118,7 +118,7 @@ public class WriteReportDialog {
private void setCategoryWidthWhenWindowIsBigger(double maxBarWidth, Number n, Number n1) { private void setCategoryWidthWhenWindowIsBigger(double maxBarWidth, Number n, Number n1) {
if (n != null && (n1.doubleValue() > n.doubleValue())) { if (n != null && (n1.doubleValue() > n.doubleValue())) {
double barWidth = 0; double barWidth;
CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis(); CategoryAxis xAxis = (CategoryAxis) barChart.getXAxis();
do { do {
double catSpace = xAxis.getCategorySpacing(); double catSpace = xAxis.getCategorySpacing();
...@@ -144,7 +144,7 @@ public class WriteReportDialog { ...@@ -144,7 +144,7 @@ public class WriteReportDialog {
// formatter to display only whole numbers // formatter to display only whole numbers
NumberAxis yAxis = (NumberAxis) barChart.getYAxis(); NumberAxis yAxis = (NumberAxis) barChart.getYAxis();
yAxis.setTickLabelFormatter(new StringConverter<Number>() { yAxis.setTickLabelFormatter(new StringConverter<>() {
@Override @Override
public String toString(Number object) { public String toString(Number object) {
......
...@@ -4,8 +4,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.FeatureType; ...@@ -4,8 +4,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
public class TypeFilterSelection { public class TypeFilterSelection {
private FeatureType type; private final FeatureType type;
private String name; private final String name;
public TypeFilterSelection(FeatureType type, String name) { public TypeFilterSelection(FeatureType type, String name) {
this.type = type; this.type = type;
......
...@@ -29,7 +29,7 @@ public class GuiLogger extends AbstractAppender { ...@@ -29,7 +29,7 @@ public class GuiLogger extends AbstractAppender {
private static final int CAPACITY = 20000; private static final int CAPACITY = 20000;
private StringBuilder buffer = new StringBuilder(CAPACITY); private final StringBuilder buffer = new StringBuilder(CAPACITY);
private Thread daemonLoggerThread; private Thread daemonLoggerThread;
private boolean dirty = false; private boolean dirty = false;
......
...@@ -53,13 +53,7 @@ public class ErrorStat { ...@@ -53,13 +53,7 @@ public class ErrorStat {
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); return "ErrorStat [errorId=" + errorId + ", count=" + count + "]";
builder.append("ErrorStat [errorId=");
builder.append(errorId);
builder.append(", count=");
builder.append(count);
builder.append("]");
return builder.toString();
} }
} }
...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBoundarySurfacesNode extends Renderable { public class AllBoundarySurfacesNode extends Renderable {
private List<BoundarySurface> boundarySurfaces; private final List<BoundarySurface> boundarySurfaces;
public AllBoundarySurfacesNode(List<BoundarySurface> boundarySurfaces) { public AllBoundarySurfacesNode(List<BoundarySurface> boundarySurfaces) {
this.boundarySurfaces = boundarySurfaces; this.boundarySurfaces = boundarySurfaces;
......
...@@ -26,7 +26,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -26,7 +26,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgeConstructiveElementsNode extends Renderable { public class AllBridgeConstructiveElementsNode extends Renderable {
private List<BridgeConstructiveElement> constructiveElements; private final List<BridgeConstructiveElement> constructiveElements;
public AllBridgeConstructiveElementsNode(List<BridgeConstructiveElement> constructiveElements) { public AllBridgeConstructiveElementsNode(List<BridgeConstructiveElement> constructiveElements) {
this.constructiveElements = constructiveElements; this.constructiveElements = constructiveElements;
......
...@@ -26,7 +26,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -26,7 +26,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgePartsNode extends Renderable { public class AllBridgePartsNode extends Renderable {
private List<BridgeObject> bridgeParts; private final List<BridgeObject> bridgeParts;
public AllBridgePartsNode(List<BridgeObject> bridgeParts) { public AllBridgePartsNode(List<BridgeObject> bridgeParts) {
this.bridgeParts = bridgeParts; this.bridgeParts = bridgeParts;
......
...@@ -7,7 +7,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -7,7 +7,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBridgesNode extends Renderable { public class AllBridgesNode extends Renderable {
private List<BridgeObject> bridges; private final List<BridgeObject> bridges;
public AllBridgesNode(List<BridgeObject> bridges) { public AllBridgesNode(List<BridgeObject> bridges) {
this.bridges = bridges; this.bridges = bridges;
......
...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBuildingPartsNode extends Renderable { public class AllBuildingPartsNode extends Renderable {
private List<BuildingPart> buildingParts; private final List<BuildingPart> buildingParts;
public AllBuildingPartsNode(List<BuildingPart> buildingParts) { public AllBuildingPartsNode(List<BuildingPart> buildingParts) {
this.buildingParts = buildingParts; this.buildingParts = buildingParts;
......
...@@ -7,7 +7,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -7,7 +7,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllBuildingsNode extends Renderable { public class AllBuildingsNode extends Renderable {
private List<Building> buildings; private final List<Building> buildings;
public AllBuildingsNode(List<Building> buildings) { public AllBuildingsNode(List<Building> buildings) {
this.buildings = buildings; this.buildings = buildings;
......
...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllInstallationsNode extends Renderable { public class AllInstallationsNode extends Renderable {
private List<Installation> buildingInstallations; private final List<Installation> buildingInstallations;
public AllInstallationsNode(List<Installation> bis) { public AllInstallationsNode(List<Installation> bis) {
this.buildingInstallations = bis; this.buildingInstallations = bis;
......
...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer; ...@@ -8,7 +8,7 @@ import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class AllOpeningsNode extends Renderable { public class AllOpeningsNode extends Renderable {
private List<Opening> openings; private final List<Opening> openings;
public AllOpeningsNode(List<Opening> openings) { public AllOpeningsNode(List<Opening> openings) {
this.openings = openings; this.openings = openings;
......
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