11package org .getaviz .generator .city .m2m ;
22
3- import org .getaviz .generator .output . OutputColor ;
3+ import org .getaviz .generator .ColorGradient ;
44import org .getaviz .generator .SettingsConfiguration ;
55import org .getaviz .generator .Step ;
66import org .getaviz .generator .database .Labels ;
77import org .getaviz .generator .SettingsConfiguration .BuildingType ;
88import org .getaviz .generator .city .CityUtils ;
99import org .getaviz .generator .SettingsConfiguration .ClassElementsModes ;
1010import org .getaviz .generator .SettingsConfiguration .Original .BuildingMetric ;
11- import org .getaviz .generator .SettingsConfiguration .OutputFormat ;
12-
1311import java .util .HashMap ;
1412import java .util .List ;
1513import java .util .stream .Collectors ;
2523
2624public class City2City implements Step {
2725 private Log log = LogFactory .getLog (this .getClass ());
28- private List <OutputColor > PCKG_colors ;
29- private List <OutputColor > NOS_colors ;
26+ private List <String > PCKG_colors ;
27+ private List <String > NOS_colors ;
3028 private HashMap <Long , double []> properties = new HashMap <>();
3129 private DatabaseConnector connector = DatabaseConnector .getInstance ();
32- private OutputFormat outputFormat ;
3330
34- private OutputColor packageColorStart ;
35- private OutputColor packageColorEnd ;
31+ private String packageColorStart ;
32+ private String packageColorEnd ;
3633
3734 private BuildingType buildingType ;
3835 private String buildingTypeAsString ;
3936 private BuildingMetric originalBuildingMetric ;
40- private OutputColor classColorStart ;
41- private OutputColor classColorEnd ;
42- private OutputColor classColor ;
37+ private String classColorStart ;
38+ private String classColorEnd ;
39+ private String classColor ;
40+ private String floorColor ;
41+ private String chimneyColor ;
4342 private boolean showBuildingBase ;
4443
4544 private double heightMin ;
@@ -69,7 +68,8 @@ public City2City(SettingsConfiguration config) {
6968 this .originalBuildingMetric = config .getOriginalBuildingMetric ();
7069 this .classColorStart = config .getClassColorStart ();
7170 this .classColorEnd = config .getClassColorEnd ();
72- this .outputFormat = config .getOutputFormat ();
71+ this .floorColor = config .getCityFloorColor ();
72+ this .chimneyColor = config .getCityChimneyColor ();
7373 this .heightMin = config .getHeightMin ();
7474 this .widthMin = config .getWidthMin ();
7575 this .classColor = config .getClassColor ();
@@ -98,12 +98,12 @@ public void run() {
9898 }
9999 int packageMaxLevel = connector .executeRead ("MATCH p=(n:District)-[:CONTAINS*]->(m:District) WHERE NOT (m)-[:CONTAINS]->(:District) RETURN length(p) AS length ORDER BY length(p) DESC LIMIT 1" ).
100100 single ().get ("length" ).asInt () + 1 ;
101- PCKG_colors = OutputColor .createColorGradient (packageColorStart , packageColorEnd , packageMaxLevel );
101+ PCKG_colors = ColorGradient .createColorGradient (packageColorStart , packageColorEnd , packageMaxLevel );
102102
103103 if (originalBuildingMetric == BuildingMetric .NOS ) {
104104 int NOS_max = connector .executeRead ("MATCH (n:Building) RETURN max(n.numberOfStatements) AS nos" ).single ().
105105 get ("nos" ).asInt ();
106- NOS_colors = OutputColor .createColorGradient (classColorStart , classColorEnd , NOS_max + 1 );
106+ NOS_colors = ColorGradient .createColorGradient (classColorStart , classColorEnd , NOS_max + 1 );
107107 }
108108
109109 connector .executeRead ("MATCH p=(n:Model:City)-[:CONTAINS*]->(m:District) RETURN p" ).forEachRemaining ((result ) -> setDistrictAttributes (result .get ("p" ).asPath ()));
@@ -144,7 +144,7 @@ public void run() {
144144 }
145145
146146 private void setDistrictAttributes (Path districtPath ) {
147- String color = PCKG_colors .get (districtPath .length () - 1 ). toString () ;
147+ String color = PCKG_colors .get (districtPath .length () - 1 );
148148 connector .executeWrite (
149149 String .format ("MATCH (n) WHERE ID(n) = %d SET n.height = %f, n.color = \' %s\' " , districtPath .end ().id (),
150150 heightMin , color ));
@@ -183,9 +183,9 @@ private void setBuildingAttributesOriginal(Node building, int methodCounter, int
183183 height = methodCounter ;
184184 }
185185 if (originalBuildingMetric == BuildingMetric .NOS ) {
186- color = NOS_colors .get (building .get ("numberOfStatements" ).asInt (0 )). toString () ;
186+ color = NOS_colors .get (building .get ("numberOfStatements" ).asInt (0 ));
187187 } else {
188- color = classColor . toString () ;
188+ color = classColor ;
189189 }
190190 connector .executeWrite (cypherSetBuildingSegmentAttributes (building .id (), width , length , height , color ));
191191 }
@@ -213,7 +213,7 @@ private void setBuildingAttributesPanels(Node building, int methodCounter, int d
213213 length = widthMin * areaUnit + panelHorizontalMargin * 2 ;
214214 }
215215
216- connector .executeWrite (cypherSetBuildingSegmentAttributes (building .id (), width , length , height , classColor . toString () ));
216+ connector .executeWrite (cypherSetBuildingSegmentAttributes (building .id (), width , length , height , classColor ));
217217 }
218218
219219 private void setBuildingAttributesBricks (Node building , int methodCounter , int dataCounter ) {
@@ -226,7 +226,7 @@ private void setBuildingAttributesBricks(Node building, int methodCounter, int d
226226 } else {
227227 height = 0 ;
228228 }
229- color = classColor . toString () ;
229+ color = classColor ;
230230 // Setting width, height & sideCapacity
231231 switch (brickLayout ) {
232232 case STRAIGHT : {
@@ -278,7 +278,7 @@ private void setBuildingAttributesFloors(Node building, int methodCounter, int d
278278 } else {
279279 height = methodCounter ;
280280 }
281- connector .executeWrite (cypherSetBuildingSegmentAttributes (building .id (), width , length , height , classColor . toString () ));
281+ connector .executeWrite (cypherSetBuildingSegmentAttributes (building .id (), width , length , height , classColor ));
282282 }
283283
284284 private void setBuildingSegmentAttributes (Long segment ) {
@@ -444,12 +444,8 @@ private void calculateFloors(Node building) {
444444 Record record = floors .next ();
445445 long floor = record .get ("f" ).asNode ().id ();
446446 floorCounter ++;
447- String color = 20 / 255.0 + " " + 133 / 255.0 + " " + 204 / 255.0 ;
448- if (outputFormat == OutputFormat .AFrame ) {
449- color = "#1485CC" ;
450- }
451447 String statement = cypherSetBuildingSegmentAttributes (floor , bWidth * 1.1 , bLength * 1.1 ,
452- bHeight / (floorNumberValue + 2 ) * 0.80 , color );
448+ bHeight / (floorNumberValue + 2 ) * 0.80 , floorColor );
453449 statement +=
454450 String .format ("CREATE (n)-[:HAS]->(p:City:Position {x: %f, y: %f, z: %f})" , bPosX ,
455451 (bPosY - ( bHeight / 2 ) ) + bHeight / ( floorNumberValue + 2 ) * floorCounter , bPosZ );
@@ -476,11 +472,7 @@ private void calculateChimneys(Node building) {
476472 " RETURN c" );
477473 while (chimneys .hasNext ()) {
478474 long chimney = chimneys .next ().get ("c" ).asNode ().id ();
479- String color = 255 / 255.0 + " " + 252 / 255.0 + " " + 25 / 255.0 ;
480- if (outputFormat == OutputFormat .AFrame ) {
481- color = "#FFFC19" ;
482- }
483- connector .executeWrite (cypherSetBuildingSegmentAttributes (chimney , 0.5 , 0.5 , 1.0 , color ));
475+ connector .executeWrite (cypherSetBuildingSegmentAttributes (chimney , 0.5 , 0.5 , 1.0 , chimneyColor ));
484476 if (chimneyCounter % 4 == 0 ) {
485477 courner1 .add (chimney );
486478 }
0 commit comments