diff --git a/.github/config/checks.xml b/.github/config/checks.xml index ec6a8f485..bf65fcacf 100644 --- a/.github/config/checks.xml +++ b/.github/config/checks.xml @@ -28,7 +28,18 @@ - + + + + + + + + + + + + @@ -183,7 +194,11 @@ - + + + + + diff --git a/.github/config/suppressions.xml b/.github/config/suppressions.xml index b8543db99..76fe9fa8f 100644 --- a/.github/config/suppressions.xml +++ b/.github/config/suppressions.xml @@ -10,6 +10,7 @@ + @@ -21,4 +22,14 @@ + + + + + + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9bec19056..929733889 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,12 +15,12 @@ jobs: fetch-depth: 0 - name: Lint code base - uses: dbelyaev/action-checkstyle@v0.9.5 + uses: dbelyaev/action-checkstyle@v3.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-check checkstyle_config: .github/config/checks.xml - fail_on_error: true + fail_level: error update-lint-badges: if: ${{ always() && github.ref == 'refs/heads/main' }} diff --git a/src/arcade/core/gui/GUI.java b/src/arcade/core/gui/GUI.java index 4e1d6d76f..2eb7941ad 100644 --- a/src/arcade/core/gui/GUI.java +++ b/src/arcade/core/gui/GUI.java @@ -371,7 +371,7 @@ public File getPath() { } /** Custom file filter for XML files. */ - private static class XMLFileFilter extends FileFilter { + private static final class XMLFileFilter extends FileFilter { /** * Determines if the file is an XML file. * diff --git a/src/arcade/potts/vis/PottsVisualization.java b/src/arcade/potts/vis/PottsVisualization.java index 9b524964a..d346d80c1 100644 --- a/src/arcade/potts/vis/PottsVisualization.java +++ b/src/arcade/potts/vis/PottsVisualization.java @@ -1,5 +1,6 @@ package arcade.potts.vis; +import java.util.ArrayList; import sim.engine.SimState; import arcade.core.sim.Series; import arcade.core.sim.Simulation; @@ -181,272 +182,424 @@ Drawer[] create3DDrawers() { int hx = (int) Math.round((height + .0) / (length + height) * h); int vx = (int) Math.round((height + .0) / (width + height) * v); - return new Drawer[] { - new PottsDrawer.PottsCells( - panels[0], - "agents:CYTOPLASM:Z", - length, - width, - height, - MAP_CYTOPLASM, - getBox(0, 0, hh * 2, vv * 2)), - new PottsDrawer.PottsCells( - panels[0], - "agents:CYTOPLASM:X", - length, - width, - height, - MAP_CYTOPLASM, - getBox(hh * 2, 0, hx * 2, vv * 2)), - new PottsDrawer.PottsCells( - panels[0], - "agents:CYTOPLASM:Y", - length, - width, - height, - MAP_CYTOPLASM, - getBox(0, vv * 2, hh * 2, vx * 2)), - new PottsDrawer.PottsCells( - panels[0], - "agents:NUCLEUS:Z", - length, - width, - height, - MAP_NUCLEUS, - getBox(0, 0, hh * 2, vv * 2)), - new PottsDrawer.PottsCells( - panels[0], - "agents:NUCLEUS:X", - length, - width, - height, - MAP_NUCLEUS, - getBox(hh * 2, 0, hx * 2, vv * 2)), - new PottsDrawer.PottsCells( - panels[0], - "agents:NUCLEUS:Y", - length, - width, - height, - MAP_NUCLEUS, - getBox(0, vv * 2, hh * 2, vx * 2)), - new PottsDrawer.PottsCells( - panels[1], - "agents:STATE:Z", - length, - width, - height, - MAP_STATE, - getBox(0, 0, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:POPULATION:Z", - length, - width, - height, - MAP_POPULATION, - getBox(h, 0, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:VOLUME:Z", - length, - width, - height, - maps.mapVolume, - getBox(0, v, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:HEIGHT:Z", - length, - width, - height, - maps.mapHeight, - getBox(h, v, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Z", - length, - width, - height, - MAP_OVERLAY, - getBox(0, 0, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Z", - length, - width, - height, - MAP_OVERLAY, - getBox(h, 0, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Z", - length, - width, - height, - MAP_OVERLAY, - getBox(0, v, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Z", - length, - width, - height, - MAP_OVERLAY, - getBox(h, v, hh, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Z", length, width, height, getBox(0, 0, hh, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Z", length, width, height, getBox(h, 0, hh, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Z", length, width, height, getBox(0, v, hh, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Z", length, width, height, getBox(h, v, hh, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:STATE:X", - length, - width, - height, - MAP_STATE, - getBox(hh, 0, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:POPULATION:X", - length, - width, - height, - MAP_POPULATION, - getBox(h + hh, 0, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:VOLUME:X", - length, - width, - height, - maps.mapVolume, - getBox(hh, v, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:HEIGHT:X", - length, - width, - height, - maps.mapHeight, - getBox(h + hh, v, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:X", - length, - width, - height, - MAP_OVERLAY, - getBox(hh, 0, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:X", - length, - width, - height, - MAP_OVERLAY, - getBox(h + hh, 0, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:X", - length, - width, - height, - MAP_OVERLAY, - getBox(hh, v, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:X", - length, - width, - height, - MAP_OVERLAY, - getBox(h + hh, v, hx, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:X", length, width, height, getBox(hh, 0, hx, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:X", length, width, height, getBox(h + hh, 0, hx, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:X", length, width, height, getBox(hh, v, hx, vv)), - new PottsDrawer.PottsGrid( - panels[1], "grid:X", length, width, height, getBox(h + hh, v, hx, vv)), - new PottsDrawer.PottsCells( - panels[1], - "agents:STATE:Y", - length, - width, - height, - MAP_STATE, - getBox(0, vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:POPULATION:Y", - length, - width, - height, - MAP_POPULATION, - getBox(h, vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:VOLUME:Y", - length, - width, - height, - maps.mapVolume, - getBox(0, v + vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:HEIGHT:Y", - length, - width, - height, - maps.mapHeight, - getBox(h, v + vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Y", - length, - width, - height, - MAP_OVERLAY, - getBox(0, vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Y", - length, - width, - height, - MAP_OVERLAY, - getBox(h, vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Y", - length, - width, - height, - MAP_OVERLAY, - getBox(0, v + vv, hh, vx)), - new PottsDrawer.PottsCells( - panels[1], - "agents:OVERLAY:Y", - length, - width, - height, - MAP_OVERLAY, - getBox(h, v + vv, hh, vx)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Y", length, width, height, getBox(0, vv, hh, vx)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Y", length, width, height, getBox(h, vv, hh, vx)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Y", length, width, height, getBox(0, v + vv, hh, vx)), - new PottsDrawer.PottsGrid( - panels[1], "grid:Y", length, width, height, getBox(h, v + vv, hh, vx)), - }; + ArrayList drawers = new ArrayList(); + + add3DPanel0Drawers(drawers, hh, vv, hx, vx); + add3DZDrawers(drawers, h, v, hh, vv); + add3DXDrawers(drawers, h, v, hh, vv, hx); + add3DYDrawers(drawers, h, v, hh, vv, vx); + + return drawers.toArray(new Drawer[0]); + } + + /** + * Creates drawers for panel 0 + * + *

These drawers display cytoplasm and nucleus components for each of the three main + * projection planes (X, Y, and Z). + * + * @param drawers the list to which drawers are added + * @param hh horizontal subdivision factor for the Z projection + * @param vv vertical subdivision factor for the Z projection + * @param hx horizontal subdivision factor for the X projection + * @param vx vertical subdivision factor for the Y projection + */ + private void add3DPanel0Drawers(ArrayList drawers, int hh, int vv, int hx, int vx) { + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:CYTOPLASM:Z", + length, + width, + height, + MAP_CYTOPLASM, + getBox(0, 0, hh * 2, vv * 2))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:CYTOPLASM:X", + length, + width, + height, + MAP_CYTOPLASM, + getBox(hh * 2, 0, hx * 2, vv * 2))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:CYTOPLASM:Y", + length, + width, + height, + MAP_CYTOPLASM, + getBox(0, vv * 2, hh * 2, vx * 2))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:NUCLEUS:Z", + length, + width, + height, + MAP_NUCLEUS, + getBox(0, 0, hh * 2, vv * 2))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:NUCLEUS:X", + length, + width, + height, + MAP_NUCLEUS, + getBox(hh * 2, 0, hx * 2, vv * 2))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[0], + "agents:NUCLEUS:Y", + length, + width, + height, + MAP_NUCLEUS, + getBox(0, vv * 2, hh * 2, vx * 2))); + } + + /** + * Adds drawers for the Z-axis projections on panel 1. + * + *

These drawers render STATE, POPULATION, VOLUME, HEIGHT, and OVERLAY views along the Z + * axis, plus grid overlays for each region. + * + * @param drawers the list to which drawers are added + * @param h half the total horizontal panel width + * @param v half the total vertical panel height + * @param hh scaled horizontal subdivision for Z projections + * @param vv scaled vertical subdivision for Z projections + */ + private void add3DZDrawers(ArrayList drawers, int h, int v, int hh, int vv) { + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:STATE:Z", + length, + width, + height, + MAP_STATE, + getBox(0, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:POPULATION:Z", + length, + width, + height, + MAP_POPULATION, + getBox(h, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:VOLUME:Z", + length, + width, + height, + maps.mapVolume, + getBox(0, v, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:HEIGHT:Z", + length, + width, + height, + maps.mapHeight, + getBox(h, v, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Z", + length, + width, + height, + MAP_OVERLAY, + getBox(0, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Z", + length, + width, + height, + MAP_OVERLAY, + getBox(h, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Z", + length, + width, + height, + MAP_OVERLAY, + getBox(0, v, hh, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Z", + length, + width, + height, + MAP_OVERLAY, + getBox(h, v, hh, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Z", length, width, height, getBox(0, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Z", length, width, height, getBox(h, 0, hh, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Z", length, width, height, getBox(0, v, hh, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Z", length, width, height, getBox(h, v, hh, vv))); + } + + /** + * Adds drawers for the X-axis projections on panel 1. + * + *

These drawers render STATE, POPULATION, VOLUME, HEIGHT, and OVERLAY views along the X + * axis, plus grid overlays for each region. + * + * @param drawers the list to which drawers are added + * @param h half the total horizontal panel width + * @param v half the total vertical panel height + * @param hh scaled horizontal subdivision for Z projections + * @param vv scaled vertical subdivision for Z projections + * @param hx scaled horizontal subdivision for X projections + */ + private void add3DXDrawers(ArrayList drawers, int h, int v, int hh, int vv, int hx) { + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:STATE:X", + length, + width, + height, + MAP_STATE, + getBox(hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:POPULATION:X", + length, + width, + height, + MAP_POPULATION, + getBox(h + hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:VOLUME:X", + length, + width, + height, + maps.mapVolume, + getBox(hh, v, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:HEIGHT:X", + length, + width, + height, + maps.mapHeight, + getBox(h + hh, v, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:X", + length, + width, + height, + MAP_OVERLAY, + getBox(hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:X", + length, + width, + height, + MAP_OVERLAY, + getBox(h + hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:X", + length, + width, + height, + MAP_OVERLAY, + getBox(hh, v, hx, vv))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:X", + length, + width, + height, + MAP_OVERLAY, + getBox(h + hh, v, hx, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:X", length, width, height, getBox(hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:X", length, width, height, getBox(h + hh, 0, hx, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:X", length, width, height, getBox(hh, v, hx, vv))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:X", length, width, height, getBox(h + hh, v, hx, vv))); + } + + /** + * Adds drawers for the Y-axis projections on panel 1. + * + *

These drawers render STATE, POPULATION, VOLUME, HEIGHT, and OVERLAY views along the Y + * axis, plus grid overlays for each region. + * + * @param drawers the list to which drawers are added + * @param h half the total horizontal panel width + * @param v half the total vertical panel height + * @param hh scaled horizontal subdivision for Z projections + * @param vv scaled vertical subdivision for Z projections + * @param vx scaled vertical subdivision for Y projections + */ + private void add3DYDrawers(ArrayList drawers, int h, int v, int hh, int vv, int vx) { + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:STATE:Y", + length, + width, + height, + MAP_STATE, + getBox(0, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:POPULATION:Y", + length, + width, + height, + MAP_POPULATION, + getBox(h, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:VOLUME:Y", + length, + width, + height, + maps.mapVolume, + getBox(0, v + vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:HEIGHT:Y", + length, + width, + height, + maps.mapHeight, + getBox(h, v + vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Y", + length, + width, + height, + MAP_OVERLAY, + getBox(0, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Y", + length, + width, + height, + MAP_OVERLAY, + getBox(h, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Y", + length, + width, + height, + MAP_OVERLAY, + getBox(0, v + vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsCells( + panels[1], + "agents:OVERLAY:Y", + length, + width, + height, + MAP_OVERLAY, + getBox(h, v + vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Y", length, width, height, getBox(0, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Y", length, width, height, getBox(h, vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Y", length, width, height, getBox(0, v + vv, hh, vx))); + + drawers.add( + new PottsDrawer.PottsGrid( + panels[1], "grid:Y", length, width, height, getBox(h, v + vv, hh, vx))); } @Override diff --git a/test/arcade/potts/sim/Potts3DTest.java b/test/arcade/potts/sim/Potts3DTest.java index 1cda3803e..66b172123 100644 --- a/test/arcade/potts/sim/Potts3DTest.java +++ b/test/arcade/potts/sim/Potts3DTest.java @@ -208,7 +208,7 @@ private static void populate(int[][] array, int n, int k) { array[index++] = s.clone(); - for (; ; ) { + while (true) { int ii = k - 1; for (int i = k - 1; i >= 0 && s[i] == n - k + i; i--) { ii--;