Class Block

java.lang.Object
java.util.Observable
ca.spatial.patchworks.Block
All Implemented Interfaces:
Comparable<Block>

public class Block extends Observable implements Comparable<Block>
This class contains information that describes a block, consisting of a one or both of a managed and unmanaged component.

Very little information is held in this block object. The managed and unmanaged component objects hold all of the stratification, area, attribute and scheduling information. Most of the methods in this class will delegate to the component parts.

  • Method Details

    • getLabel

      public String getLabel()
      Return the block label
    • getIndex

      public int getIndex()
      Return the internal block index number
    • getArea

      public float getArea()
      Return the sum of the managed and unmanaged block components
    • getManaged

      public BlockPart getManaged()
      Return the managed comonent object, or null if there is no managed comonpnent
    • hasManagedArea

      public boolean hasManagedArea()
      Return true if this block has a managed component, or false otherwise
    • getUnmanaged

      public BlockPart getUnmanaged()
      Return the unmanaged comonent object, or null if there is no unmanaged comonpnent
    • hasUnmanagedArea

      public boolean hasUnmanagedArea()
      Return true if this block has a nunmanaged component, or false otherwise
    • isAvailable

      public boolean isAvailable(int period)
      Check if the managaged portion of this block is available for scheduling in the specified period.
      Parameters:
      period - the period to check for scheduling availability
    • hasManagedTreatments

      public boolean hasManagedTreatments()
      Check if the managed component of the block has treatments
    • setAvailable

      public boolean setAvailable(boolean value, int period)
    • setAvailable

      public boolean setAvailable(boolean[] values)
    • applyTreatment

      public boolean applyTreatment(String label, int year, boolean wantManaged)
      Attempt to apply a treatment in a given year, and return true or false depending if the treatment was applied successfully or not. If the treatment is applied then the account structures are updated. If the treatment could not be applied then the account structures are unchanged.

      Parameters:
      label - the name of the treatment to apply
      year - the planning year when the treatment should be applied
      wantManaged - if true then try to apply the treatment to the managed component, if false try to apply the treatment to the unmanaged component.
      Returns:
      true if treatment was successfully applied to the block component, or false if the treatment could not be applied.
    • clearTreatment

      public boolean clearTreatment(int year1, int year2, boolean wantManaged)
      Clear all treatments that occur between the specified age range.
      Returns:
      True if treatments cleared, false it not.
    • shiftTreatment

      public boolean shiftTreatment(int year1, int year2, boolean wantManaged)
      Shift all treatments by the given amount of years.
    • compareTo

      public int compareTo(Block object)
      Specified by:
      compareTo in interface Comparable<Block>
    • toString

      public String toString()
      Overrides:
      toString in class Object