Skip to content

Insert cells off center - #237

Open
allison-li-1016 wants to merge 4 commits into
mainfrom
allli/insert-clusters
Open

allison-li-1016 wants to merge 4 commits into
mainfrom
allli/insert-clusters

Conversation

@allison-li-1016

@allison-li-1016 allison-li-1016 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Estimated time to review: M

Context: In an effort to insert multiple clusters for a population, I added new functionality that allows inserts to be off the center of the simulation FOV. Currently I describe the center with a direction and offset parameter.

For hex grids, the directions are N, S, NE, NW, SW, SE to describe the 6 neighbors of a hex location. For rect grids the directions are N, W, E, S to describe the 4 neighbors of each rect location.

Offset is the number of location units from the center (same unit as radius)

Summary of changes:
PatchActionInsert:

  • Added parameter input read for offset
  • Added parameter input read for direction
  • Updated call to getCoordinates to describe the center
  • Added parameter checking for direction (is it a valid direction)

Parameters

  • Added default parameters for offset and direction

Enums

  • Added enums for valid directions for hex and rect grid

PatchLocationFactory

  • updated getCoordinates abstract method to now allow for offset and direction to describe centroid
  • added clampOffset method to clamp insertion area if it is beyond the simulation FOV

PatchLocationFactoryHex

  • added makeCenter method to calculate new center based on direction and offset
  • updated getCoordinates method to now account for new center if it is not the default simulation center

PatchLocationFactoryRect

  • added makeCenter method to calculate new center based on direction and offset
  • updated getCoordinates method to now account for new center if it is not the default simulation center

Tests

  • Added unit tests (specific to the new changes) for insert, PatchLocationFactory, PatchLocationFactoryHex, PatchLocationFactoryRect

Example usage:

<actions>
          <action id="INSERT_HIGH_DENSITY_TUMOR" class="insert">
             <action.parameter id="TIME_DELAY" value="5" />
             <action.parameter id="INSERT_NUMBER" value="1500" />
             <action.parameter id="INSERT_RADIUS" value="5" />
             <action.parameter id="INSERT_DIRECTION" value="SW" />
             <action.parameter id="INSERT_OFFSET" value="10" />
             <action.register id="cancer" />
         </action>

         <action id="INSERT_HIGH_DENSITY_TUMOR_2" class="insert">
             <action.parameter id="TIME_DELAY" value="10" />
             <action.parameter id="INSERT_NUMBER" value="1500" />
             <action.parameter id="INSERT_RADIUS" value="5" />
             <action.parameter id="INSERT_DIRECTION" value="NE" />
             <action.parameter id="INSERT_OFFSET" value="10" />
             <action.register id="cancer" />
         </action>
  </actions>

@allison-li-1016 allison-li-1016 self-assigned this Sep 22, 2026
@allison-li-1016
allison-li-1016 marked this pull request as draft September 22, 2026 22:55
@allison-li-1016
allison-li-1016 marked this pull request as ready for review October 5, 2026 16:34
@allison-li-1016
allison-li-1016 requested review from a team, Jannetty, afu5, cainja, daniellevahdat, jacob-evarts, jessicasyu and kristaphommatha and removed request for a team October 5, 2026 16:36

@kristaphommatha kristaphommatha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great! I just had some documentation comments :)

/**
* Implementation of {@link Action} for inserting cell agents.
*
* <p>The action is stepped once after {@code TIME_DELAY}. The action will insert a mixture of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should update this javadoc to reflect all the changes! I think it should be specified somewhere too, whether in this javadoc or a later one, that the default for if the direction and/or offset is not specified by the user is CENTER and 0, respectively

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this file is named PatchLocationFactoryHexOffsetTest.java and not just PatchLocationFactoryHexTest.java file? I'm just wondering because the rest of the test java files seem to be named exactly after the file that it's testing?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants