insertArtifactForSpace method

void insertArtifactForSpace(
  1. int indexOfArtifact,
  2. double x1,
  3. double x2
)

Inserts a space artifact at a specified position in the artifacts list.

This method creates a new Artifact representing a space and inserts it into the artifacts list at the specified index.

Parameters:

  • indexOfArtifact: The index at which to insert the space artifact.
  • x1: The left x-coordinate of the space artifact.
  • x2: The right x-coordinate of the space artifact.

The created space artifact has the following properties:

  • Character matched is a space ' '.
  • Band ID is set to the current band's ID.
  • Rectangle is set based on the provided x-coordinates and the band's top and bottom.
  • A matrix is created based on the dimensions of the rectangle.

Implementation

void insertArtifactForSpace(
  final int indexOfArtifact,
  final double x1,
  final double x2,
) {
  final Artifact artifactSpace = Artifact();
  artifactSpace.characterMatched = ' ';

  artifactSpace.matrix.rectangle = Rect.fromLTRB(
    x1,
    rectangle.top,
    x2,
    rectangle.bottom,
  );
  artifactSpace.matrix.rectangle = artifactSpace.matrix.rectangle;

  artifactSpace.matrix.setGrid(
    Matrix(
      artifactSpace.matrix.rectangle.width.toInt(),
      artifactSpace.matrix.rectangle.height.toInt(),
    ).data,
  );
  this.artifacts.insert(indexOfArtifact, artifactSpace);
}