Package ca.spatial.patchworks
Class Block
java.lang.Object
java.util.Observable
ca.spatial.patchworks.Block
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionboolean
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.boolean
clearTreatment(int year1, int year2, boolean wantManaged)
Clear all treatments that occur between the specified age range.int
float
getArea()
Return the sum of the managed and unmanaged block componentsint
getIndex()
Return the internal block index numbergetLabel()
Return the block labelReturn the managed comonent object, or null if there is no managed comonpnentReturn the unmanaged comonent object, or null if there is no unmanaged comonpnentboolean
Return true if this block has a managed component, or false otherwiseboolean
Check if the managed component of the block has treatmentsboolean
Return true if this block has a nunmanaged component, or false otherwiseboolean
isAvailable(int period)
Check if the managaged portion of this block is available for scheduling in the specified period.boolean
setAvailable(boolean[] values)
boolean
setAvailable(boolean value, int period)
boolean
shiftTreatment(int year1, int year2, boolean wantManaged)
Shift all treatments by the given amount of years.toString()
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
-
Method Details
-
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
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
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
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 applyyear
- the planning year when the treatment should be appliedwantManaged
- 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
- Specified by:
compareTo
in interfaceComparable<Block>
-
toString
-