Commit c748a058 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Rename functions and fields

parent 8edfe8d6
Pipeline #12217 passed with stage
in 2 minutes and 12 seconds
......@@ -125,7 +125,7 @@ public class CityDoctorModel {
public Stream<CityObject> createFeatureStream() {
return Stream.of(getBuildings(), getVegetation(), getBridges(), getLand(), getTransportation(),
getTunnels(), getWater(), getCityFurniture(), getGenericCityObjects()).flatMap(co -> co);
getTunnels(), getWater(), getCityFurniture(), getOtherCityObjects()).flatMap(co -> co);
}
public List<GmlId> getFeatureIds() {
......@@ -347,20 +347,20 @@ public class CityDoctorModel {
return cityfurniture.size();
}
public void addGenericCityObject(GenericCityObject coGenericCityObject) {
genericObjects.add(coGenericCityObject.getGmlId());
cache.put(coGenericCityObject);
public void addOtherCityObject(CityObject otherCityObject) {
genericObjects.add(otherCityObject.getGmlId());
cache.put(otherCityObject);
}
public Stream<GenericCityObject> getGenericCityObjects() {
return genericObjects.stream().map(co -> (GenericCityObject) cache.get(co));
public Stream<CityObject> getOtherCityObjects() {
return genericObjects.stream().map(cache::get);
}
public List<GmlId> getGenericCityObjectIds() {
public List<GmlId> getOtherCityObjectsIds() {
return genericObjects;
}
public int getGenericCityObjectCount(){
public int getOtherCityObjectsCount(){
return genericObjects.size();
}
......
......@@ -227,6 +227,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
finishCityObjectConstruction(oco);
model.addOtherCityObject(oco);
}
@Override
......
......@@ -92,7 +92,7 @@ public class CityGMLWriterUtils {
storeCityObjects(model.getTransportation(), gmlFactory, model, cModel, val);
storeCityObjects(model.getWater(), gmlFactory, model, cModel, val);
storeCityObjects(model.getCityFurniture(), gmlFactory, model, cModel, val);
storeCityObjects(model.getGenericCityObjects(), gmlFactory, model, cModel, val);
storeCityObjects(model.getOtherCityObjects(), gmlFactory, model, cModel, val);
storeCityObjects(model.getTunnels(), gmlFactory, model, cModel, val);
writer.write(cModel);
......
......@@ -325,11 +325,11 @@ public class CityDoctorModelTest {
}
@Test
public void testAddGenericCityObject() {
public void testAddOtherCityObject() {
GenericCityObject gen = Mockito.mock(GenericCityObject.class);
Mockito.when(gen.getGmlId()).thenReturn(new GmlId("g"));
model.addGenericCityObject(gen);
assertEquals(gen, model.getGenericCityObjects().toList().get(0));
model.addOtherCityObject(gen);
assertEquals(gen, model.getOtherCityObjects().toList().get(0));
}
@Test
......@@ -362,7 +362,7 @@ public class CityDoctorModelTest {
model.addLand(land);
model.addWater(water);
model.addCityFurniture(cf);
model.addGenericCityObject(generic);
model.addOtherCityObject(generic);
assertEquals(9, model.getNumberOfFeatures());
......@@ -547,11 +547,11 @@ public class CityDoctorModelTest {
GenericCityObject gco2 = Mockito.mock(GenericCityObject.class);
Mockito.when(gco2.getGmlId()).thenReturn(new GmlId("gco2"));
model.addGenericCityObject(gco1);
assertEquals(gco1, model.getGenericCityObjects().toList().get(0));
model.addOtherCityObject(gco1);
assertEquals(gco1, model.getOtherCityObjects().toList().get(0));
model.replaceFeature(gco1, gco2);
assertEquals(gco2, model.getGenericCityObjects().toList().get(0));
assertEquals(1, model.getGenericCityObjects().toList().size());
assertEquals(gco2, model.getOtherCityObjects().toList().get(0));
assertEquals(1, model.getOtherCityObjects().toList().size());
}
@Test(expected = IllegalStateException.class)
......
......@@ -67,7 +67,7 @@ public class CityDoctorController {
private AtomicInteger waterChunkNr = new AtomicInteger(0);
private AtomicInteger landChunkNr = new AtomicInteger(0);
private AtomicInteger cityFurnitureChunkNr = new AtomicInteger(0);
private AtomicInteger genericCityObjectsChunkNr = new AtomicInteger(0);
private AtomicInteger otherCityObjectsChunkNr = new AtomicInteger(0);
......@@ -164,7 +164,7 @@ public class CityDoctorController {
mainWindow.setDisableOfFeatureTab(FeatureType.WATER, model.getWaterCount() == 0);
mainWindow.setDisableOfFeatureTab(FeatureType.LAND, model.getLandCount() == 0);
mainWindow.setDisableOfFeatureTab(FeatureType.CITY_FURNITURE, model.getCityFurnitureCount() == 0);
mainWindow.setDisableOfFeatureTab(FeatureType.GENERIC_CITY_OBJECT, model.getGenericCityObjectCount() == 0);
mainWindow.setDisableOfFeatureTab(FeatureType.OTHER_CITY_OBJECT, model.getOtherCityObjectsCount() == 0);
}
public void buildTrees() {
......@@ -190,7 +190,7 @@ public class CityDoctorController {
waterChunkNr.set(0);
landChunkNr.set(0);
cityFurnitureChunkNr.set(0);
genericCityObjectsChunkNr.set(0);
otherCityObjectsChunkNr.set(0);
}
private void buildLand(CityDoctorModel model) {
......@@ -235,18 +235,18 @@ public class CityDoctorController {
}
private void buildGenericCityObjects(CityDoctorModel model) {
if (model.getGenericCityObjectCount() == 0) {
if (model.getOtherCityObjectsCount() == 0) {
return;
}
TreeView<Renderable> otherObjectsView = mainWindow.getGenericCityObjectView();
TreeView<Renderable> otherObjectsView = mainWindow.getOtherCityObjectView();
TreeItem<Renderable> otherObjectsRoot = new TreeItem<>(new CityObjectGroupNode(Collections.emptyList(),
"Generic CityObjects", Color.DARKGRAY));
otherObjectsRoot.setExpanded(true);
otherObjectsView.setRoot(otherObjectsRoot);
Supplier<Stream<GenericCityObject>> supply = model::getGenericCityObjects;
buildGenericCityObjectTreeFromList(supply, otherObjectsView.getRoot());
addMoreButtonForGenericCityObjects( otherObjectsView, otherObjectsRoot, genericCityObjectsChunkNr, supply,
model.getGenericCityObjectCount());
Supplier<Stream<CityObject>> supply = model::getOtherCityObjects;
buildOtherCityObjectsTreeFromList(supply, otherObjectsView.getRoot());
addMoreButtonForOtherCityObjects( otherObjectsView, otherObjectsRoot, otherCityObjectsChunkNr, supply,
model.getOtherCityObjectsCount());
}
private void buildWater(CityDoctorModel model) {
......@@ -528,13 +528,13 @@ public class CityDoctorController {
}
}
private void addMoreButtonForGenericCityObjects(TreeView<Renderable> view, TreeItem<Renderable> root,
AtomicInteger chunkCounter, Supplier<Stream<GenericCityObject>> supply, int featureCount){
private void addMoreButtonForOtherCityObjects(TreeView<Renderable> view, TreeItem<Renderable> root,
AtomicInteger chunkCounter, Supplier<Stream<CityObject>> supply, int featureCount){
if ((chunkCounter.get() + 1) * MAX_FEATURES_PER_CHUNK < featureCount) {
AddMoreButtonRunnable run = new AddMoreButtonRunnable(featureCount, view, root, chunkCounter) {
@Override
public void buildNodeTreeCall() {
buildGenericCityObjectTreeFromList(supply, root);
buildOtherCityObjectsTreeFromList(supply, root);
updateTree(root);
}
};
......@@ -590,7 +590,7 @@ public class CityDoctorController {
mainWindow.getWaterView().setRoot(null);
mainWindow.getTerrainView().setRoot(null);
mainWindow.getCityFurnitureView().setRoot(null);
mainWindow.getGenericCityObjectView().setRoot(null);
mainWindow.getOtherCityObjectView().setRoot(null);
mainWindow.getErrorTree().getRoot().getChildren().clear();
mainWindow.getAttributeView().getRoot().getChildren().clear();
mainWindow.getGlobalErrorsView().getItems().clear();
......@@ -697,8 +697,8 @@ public class CityDoctorController {
});
}
private void buildGenericCityObjectTreeFromList(Supplier<Stream<GenericCityObject>> supply, TreeItem<Renderable> root) {
int genericObjectChunk = genericCityObjectsChunkNr.get();
private void buildOtherCityObjectsTreeFromList(Supplier<Stream<CityObject>> supply, TreeItem<Renderable> root) {
int genericObjectChunk = otherCityObjectsChunkNr.get();
supply.get().skip((long) genericObjectChunk * MAX_FEATURES_PER_CHUNK).limit(MAX_FEATURES_PER_CHUNK).forEach(gen ->{
buildTopLevelCityObjectNode(gen, root);
});
......@@ -1105,7 +1105,7 @@ public class CityDoctorController {
updateTree(mainWindow.getCityFurnitureView().getRoot());
updateTree(mainWindow.getTransportationView().getRoot());
updateTree(mainWindow.getWaterView().getRoot());
updateTree(mainWindow.getGenericCityObjectView().getRoot());
updateTree(mainWindow.getOtherCityObjectView().getRoot());
updateTree(mainWindow.getTunnelView().getRoot());
renderer.updateErrors();
}
......@@ -1228,7 +1228,7 @@ public class CityDoctorController {
case WATER -> filterWaterTree(searchString);
case LAND -> filterLandTree(searchString);
case CITY_FURNITURE -> filterCityFurnitureTree(searchString);
case GENERIC_CITY_OBJECT -> filterGenericCityObjectTree(searchString);
case OTHER_CITY_OBJECT -> filterOtherCityObjectsTree(searchString);
}
......@@ -1325,15 +1325,15 @@ public class CityDoctorController {
addMoreButtonForCityFurniture(cityFurnitureView, root, cityFurnitureChunkNr, foundCityFurniture, featureCount);
}
private void filterGenericCityObjectTree(String searchString) {
Supplier<Stream<GenericCityObject>> foundGenericCityObject = () -> model.getGenericCityObjects().
private void filterOtherCityObjectsTree(String searchString) {
Supplier<Stream<CityObject>> foundGenericCityObject = () -> model.getOtherCityObjects().
filter(co ->featureFilter(co, searchString));
int featureCount = (int) foundGenericCityObject.get().count();
TreeView<Renderable> genericCityObjectView = mainWindow.getGenericCityObjectView();
TreeView<Renderable> genericCityObjectView = mainWindow.getOtherCityObjectView();
TreeItem<Renderable> root = genericCityObjectView.getRoot();
root.getChildren().clear();
buildGenericCityObjectTreeFromList(foundGenericCityObject, root);
addMoreButtonForGenericCityObjects(genericCityObjectView, root, genericCityObjectsChunkNr,
buildOtherCityObjectsTreeFromList(foundGenericCityObject, root);
addMoreButtonForOtherCityObjects(genericCityObjectView, root, otherCityObjectsChunkNr,
foundGenericCityObject, featureCount);
}
......@@ -1484,8 +1484,8 @@ public class CityDoctorController {
addMoreButtonForCityFurniture(cityFurnitureView, root, cityFurnitureChunkNr, supply, foundCityFurniture.size());
}
public void fillTreeViewWithErrorGenericCityObjects() {
TreeView<Renderable> genericCityObjectsView = mainWindow.getGenericCityObjectView();
public void fillTreeViewWithErrorOtherCityObjects() {
TreeView<Renderable> genericCityObjectsView = mainWindow.getOtherCityObjectView();
TreeItem<Renderable> root = genericCityObjectsView.getRoot();
if (model == null) {
return;
......@@ -1496,14 +1496,14 @@ public class CityDoctorController {
mainWindow.resetSearchBar();
root.getChildren().clear();
resetFeatureChunks();
List<GmlId> foundGenericCityObjects = model.getCache().getErrorFeatureIds();
List<GmlId> idList = model.getGenericCityObjectIds();
foundGenericCityObjects.removeIf(gmlId -> (!idList.contains(gmlId)));
List<GmlId> foundOtherCityObjects = model.getCache().getErrorFeatureIds();
List<GmlId> idList = model.getOtherCityObjectsIds();
foundOtherCityObjects.removeIf(gmlId -> (!idList.contains(gmlId)));
Supplier<Stream<GenericCityObject>> supply = () -> model.getCache().getStream(foundGenericCityObjects).map(co -> (GenericCityObject) co);
buildGenericCityObjectTreeFromList(supply, root);
Supplier<Stream<CityObject>> supply = () -> model.getCache().getStream(foundOtherCityObjects).map(co -> (GenericCityObject) co);
buildOtherCityObjectsTreeFromList(supply, root);
updateTree(root);
addMoreButtonForGenericCityObjects(genericCityObjectsView, root, genericCityObjectsChunkNr, supply, foundGenericCityObjects.size());
addMoreButtonForOtherCityObjects(genericCityObjectsView, root, otherCityObjectsChunkNr, supply, foundOtherCityObjects.size());
}
public void fillTreeViewWithErrorTransportation() {
......@@ -1647,7 +1647,7 @@ public class CityDoctorController {
fillTreeViewWithErrorTunnel();
fillTreeViewWithErrorWater();
fillTreeViewWithErrorCityFurniture();
fillTreeViewWithErrorGenericCityObjects();
fillTreeViewWithErrorOtherCityObjects();
} else {
throw new IllegalStateException("Unknown filter index selected: " + newV);
}
......
......@@ -639,7 +639,7 @@ public class MainWindow extends Application {
selectedTab = FeatureType.CITY_FURNITURE;
break;
case 8:
selectedTab = FeatureType.GENERIC_CITY_OBJECT;
selectedTab = FeatureType.OTHER_CITY_OBJECT;
break;
default:
throw new IllegalStateException("Unknown tab index: " + index);
......@@ -673,7 +673,7 @@ public class MainWindow extends Application {
case CITY_FURNITURE:
cityFurnitureTab.setDisable(value);
break;
case GENERIC_CITY_OBJECT:
case OTHER_CITY_OBJECT:
otherObjectsTab.setDisable(value);
break;
default:
......@@ -1015,7 +1015,7 @@ public class MainWindow extends Application {
return attributeView;
}
public TreeView<Renderable> getGenericCityObjectView() {
public TreeView<Renderable> getOtherCityObjectView() {
return otherObjectsView;
}
......@@ -1161,7 +1161,7 @@ public class MainWindow extends Application {
case WATER -> new Pair<>(waterTab, waterView);
case LAND -> new Pair<>(terrainTab, terrainView);
case CITY_FURNITURE -> new Pair<>(cityFurnitureTab, cityFurnitureView);
case GENERIC_CITY_OBJECT -> new Pair<>(otherObjectsTab, otherObjectsView);
case OTHER_CITY_OBJECT -> new Pair<>(otherObjectsTab, otherObjectsView);
default -> throw new IllegalArgumentException("unknown feature type: " + coType);
};
}
......
......@@ -92,7 +92,7 @@ public class TriangulatedGeometry {
addPolygonDataFromCityObjects(model.getVegetation(), triGeom, Color.LIGHTGREEN, filters);
addPolygonDataFromCityObjects(model.getWater(), triGeom, Color.LIGHTSKYBLUE, filters);
addPolygonDataFromCityObjects(model.getCityFurniture(), triGeom, Color.BLUEVIOLET, filters);
addPolygonDataFromCityObjects(model.getGenericCityObjects(), triGeom, Color.BLACK, filters);
addPolygonDataFromCityObjects(model.getOtherCityObjects(), triGeom, Color.BLACK, filters);
return triGeom;
}
......
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