Some codebases include many tiny buildings when visually represented (for example, gardens representing classes under 10 lines of code) that clutter the city layout. Rather than excluding them altogether, this new tool should let the user put those buildings into a new (virtual) container for “small things” so they remain represented int the end, but don’t overwhelm the main city view. The threshold for what counts as “small” is user-defined, and the user also selects which property triggers this grouping. The grouping should be done locally at every depth of the buildable tree.
Example tool run:
<buildableid="8b89726d-bdbb-4b7e-83d3-970ffa195458"name="codemetropolis"type="ground">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes/>
<children>
<buildableid="111aaa22-bbbb-43ab-9ea1-999999abcd11"name="LushGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.4"/>
</attributes>
<children/>
</buildable>
<buildableid="222bbb33-cccc-43ab-9ea1-000000abcd22"name="SparseGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.05"/>
</attributes>
<children>
<buildableid="333ccc44-dddd-43ab-9ea1-aaaaaaabcd33"name="MiniGardenPatch"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.02"/>
</attributes>
<children/>
</buildable>
</children>
</buildable>
<buildableid="444ddd55-eeee-43ab-9ea1-ffffffabcd44"name="CactusGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.2"/>
</attributes>
<children/>
</buildable>
</children>
</buildable>
java -jar GroupSmallBuildablesLocally.jar \
--input originalFlower.xml \
--property flower-ratio \
--threshold 0.1 \
--output groupedFlower.xml
<buildableid="8b89726d-bdbb-4b7e-83d3-970ffa195458"name="codemetropolis"type="ground">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes/>
<children>
<!-- "LushGarden" (0.4) stays as is -->
<buildableid="111aaa22-bbbb-43ab-9ea1-999999abcd11"name="LushGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.4"/>
</attributes>
<children/>
</buildable>
<!-- "CactusGarden" (0.2) also remains a direct child -->
<buildableid="444ddd55-eeee-43ab-9ea1-ffffffabcd44"name="CactusGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.2"/>
</attributes>
<children/>
</buildable>
<!-- New local container for the gardens with flower-ratio < 0.1 -->
<buildableid="localSmallContainer_1"name="SparseGardens"type="virtual">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes/>
<children>
<!-- "SparseGarden" is placed here (0.05 < 0.1) -->
<buildableid="222bbb33-cccc-43ab-9ea1-000000abcd22"name="SparseGarden"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.05"/>
</attributes>
<children>
<!-- Nested container for smaller child "MiniGardenPatch" (0.02) -->
<buildableid="localSmallContainer_2"name="SparseGardens_UnderSparseGarden"type="virtual">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes/>
<children>
<buildableid="333ccc44-dddd-43ab-9ea1-aaaaaaabcd33"name="MiniGardenPatch"type="garden">
<positionx="0"y="0"z="0"/>
<sizex="9"y="9"z="9"/>
<attributes>
<attributename="flower-ratio"value="0.02"/>
</attributes>
<children/>
</buildable>
</children>
</buildable>
</children>
</buildable>
</children>
</buildable>
</children>
</buildable>
Some codebases include many tiny buildings when visually represented (for example, gardens representing classes under 10 lines of code) that clutter the city layout. Rather than excluding them altogether, this new tool should let the user put those buildings into a new (virtual) container for “small things” so they remain represented int the end, but don’t overwhelm the main city view. The threshold for what counts as “small” is user-defined, and the user also selects which property triggers this grouping. The grouping should be done locally at every depth of the buildable tree.
Example tool run: