Skip to content

Commit b451ef3

Browse files
REFACTORING: Experimenting with separating the patterns and the bluePrintBuilders
1 parent 282158e commit b451ef3

File tree

3 files changed

+51
-20
lines changed

3 files changed

+51
-20
lines changed

invasionII/src/main/java/com/mgs/fantasi/structure/BluePrintPatternFactory.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public static <T extends BluePrintPattern> BluePrintPatternBuilder<T> newBluePri
99
return new BluePrintPatternBuilder(name, pattern);
1010
}
1111

12+
public static Blah newBluePrintBuilder(String name) {
13+
return new Blah(name);
14+
}
15+
1216
public static class BluePrintPatternBuilder<T extends BluePrintPattern> {
1317
private final String name;
1418
private final T bluePrintBuilder;
@@ -24,4 +28,30 @@ public T withWireframe(Wireframe wireframe) {
2428
}
2529
}
2630

31+
public static class Blah {
32+
private final String name;
33+
34+
public Blah(String name) {
35+
this.name = name;
36+
}
37+
38+
public Bleh withWireframe(Wireframe wireframe) {
39+
return new Bleh(name, wireframe);
40+
}
41+
}
42+
43+
public static class Bleh {
44+
private final String name;
45+
private final Wireframe wireframe;
46+
47+
public Bleh(String name, Wireframe wireframe) {
48+
this.name = name;
49+
this.wireframe = wireframe;
50+
}
51+
52+
public <T extends BluePrintPattern> T withContent(T pattern) {
53+
pattern.initialise(name, wireframe);
54+
return pattern;
55+
}
56+
}
2757
}

invasionII/src/main/java/com/mgs/fantasi/wireframe/Wireframes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static Wireframe newWireframe(UIPropertiesBuilder uiPropertiesBuilder, Po
1515
return new Wireframe(uiPropertiesBuilder.build(), shape);
1616
}
1717

18-
public static Wireframe newRectangularAllUIPropertiesEmptyWireframe() {
18+
public static Wireframe rectangularWireframe() {
1919
return new Wireframe(allEmptyUIProperties().build(), new NativeRectanguarShape());
2020
}
2121
}

invasionII/src/main/java/com/mgs/invasion/Main.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import static com.mgs.fantasi.properties.UIPropertyFactory.uiProperty;
1919
import static com.mgs.fantasi.structure.BluePrintPatternFactory.newBluePrintBuilder;
20-
import static com.mgs.fantasi.wireframe.Wireframes.newRectangularAllUIPropertiesEmptyWireframe;
20+
import static com.mgs.fantasi.wireframe.Wireframes.rectangularWireframe;
2121

2222
public class Main {
2323
public static void main(String... args) {
@@ -33,26 +33,27 @@ private void go(UIProfile uiProfile) {
3333
UIProperty<Measurement> hexagonMeasurement = uiProperty(Measurements.futureMeasurement(), UIPropertyType.MEASUREMENT);
3434

3535
BluePrint bluePrint =
36-
newBluePrintBuilder("main_frame", new LayeredPattern()).
37-
withWireframe(newRectangularAllUIPropertiesEmptyWireframe()).
38-
withLayer(
39-
newBluePrintBuilder("odd_hexagons", new HexagonRowsPattern()).
40-
withWireframe(newRectangularAllUIPropertiesEmptyWireframe()).
41-
withNumberOfGenerations(numberOfGenerations).
42-
withNumberOfVerticalDivisions(numberOVerticalDivisions).
43-
withHexagonSize(hexagonMeasurement)
44-
).
45-
withLayer(
46-
newBluePrintBuilder("even_hexagons", new HexagonRowsPattern()).
47-
withWireframe(newRectangularAllUIPropertiesEmptyWireframe()).
48-
withNumberOfGenerations(numberOfGenerations).
49-
withNumberOfVerticalDivisions(numberOVerticalDivisions).
50-
withHexagonSize(hexagonMeasurement)
51-
).
52-
buildBlueprint();
36+
newBluePrintBuilder("main_frame").
37+
withWireframe(rectangularWireframe()).
38+
withContent(
39+
new LayeredPattern().
40+
withLayer(
41+
newBluePrintBuilder("odd_hexagons", new HexagonRowsPattern()).
42+
withWireframe(rectangularWireframe()).
43+
withNumberOfGenerations(numberOfGenerations).
44+
withNumberOfVerticalDivisions(numberOVerticalDivisions).
45+
withHexagonSize(hexagonMeasurement)
46+
).
47+
withLayer(
48+
newBluePrintBuilder("even_hexagons", new HexagonRowsPattern()).
49+
withWireframe(rectangularWireframe()).
50+
withNumberOfGenerations(numberOfGenerations).
51+
withNumberOfVerticalDivisions(numberOVerticalDivisions).
52+
withHexagonSize(hexagonMeasurement)
53+
)
54+
).buildBlueprint();
5355
Structure tree = bluePrint.buildStructure();
5456

5557
uiDriver.show(tree, new Dimension(400, 400), uiProfile);
5658
}
57-
5859
}

0 commit comments

Comments
 (0)