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