Package gov.usgs.earthquake.nshmp.data
Class IntervalVolume.Builder
java.lang.Object
gov.usgs.earthquake.nshmp.data.IntervalVolume.Builder
- Enclosing class:
IntervalVolume
A builder of immutable
IntervalVolumes.
Rows, columns, and levels must be specified before any data can be
added. Note that any supplied max values may not correspond to the
final upper edge of the uppermost bins if max - min is not evenly
divisible by Δ.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double row, double column, double[] values) Add to the level array at the specified row and column.add(double row, double column, double level, double value) Add to the existing value at the specified row, column, and level.add(double row, double column, XySequence sequence) Add the y-values of the supplied sequence to the level array at the specified row and column.add(int row, int column, int level, double value) Add to the existing value at the specified row, column, and level indices.add(IntervalVolume volume) Add the values in the supplied interval volume to this builder.build()Return a newly-created, immutable 3-dimensional interval data container populated with the contents of thisBuilder.intcolumnIndex(double column) Return the index of the column that would contain the supplied value.columns(double min, double max, double delta) Define the data volume columns.static IntervalVolume.BuildercopyOf(IntervalVolume volume) Create a new builder with the structure and content identical to that of the supplied volume.static IntervalVolume.BuilderfromModel(IntervalVolume model) Create a new builder with a structure identical to that of the supplied model.intlevelIndex(double level) Return the index of the level that would contain the supplied value.levels(double min, double max, double delta) Define the data volume levels.multiply(double scale) Multiply (scale) all values in this builder.introwIndex(double row) Return the index of the row that would contain the supplied value.rows(double min, double max, double delta) Define the data volume rows.set(double row, double column, double level, double value) Set the value at the specified row, column, and level.set(int row, int column, int level, double value) Set the value at the specified row, column, and level indices.
-
Constructor Details
-
Builder
public Builder()Create a new interval volume builder.
-
-
Method Details
-
copyOf
Create a new builder with the structure and content identical to that of the supplied volume.- Parameters:
volume- to copy
-
fromModel
Create a new builder with a structure identical to that of the supplied model.- Parameters:
model- data volume
-
rows
Define the data volume rows.- Parameters:
min- lower edge of lowermost row binmax- upper edge of uppermost row bindelta- bin discretization
-
columns
Define the data volume columns.- Parameters:
min- lower edge of lowermost column binmax- upper edge of uppermost column bindelta- bin discretization
-
levels
Define the data volume levels.- Parameters:
min- lower edge of lowermost column binmax- upper edge of uppermost column bindelta- bin discretization
-
rowIndex
public int rowIndex(double row) Return the index of the row that would contain the supplied value.- Parameters:
row- value
-
columnIndex
public int columnIndex(double column) Return the index of the column that would contain the supplied value.- Parameters:
column- value
-
levelIndex
public int levelIndex(double level) Return the index of the level that would contain the supplied value.- Parameters:
level- value
-
set
Set the value at the specified row, column, and level. Be careful not to confuse this withset(int, int, int, double).- Parameters:
row- keycolumn- keylevel- keyvalue- to set
-
set
Set the value at the specified row, column, and level indices. Be careful not to confuse this withset(double, double, double, double).- Parameters:
row- indexcolumn- indexlevel- indexvalue- to set
-
add
Add to the existing value at the specified row, column, and level. Be careful not to confuse this withadd(int, int, int, double).- Parameters:
row- keycolumn- keylevel- keyvalue- to add
-
add
Add to the existing value at the specified row, column, and level indices. Be careful not to confuse this withadd(double, double, double, double).- Parameters:
row- indexcolumn- indexlevel- indexvalue-
-
add
Add to the level array at the specified row and column. Assumes that supplied value array is the same size or smaller than the levels of the internal builder data array.- Parameters:
row- keycolumn- keyvalues- to add- Throws:
IndexOutOfBoundsException- if values overrun level
-
add
Add the y-values of the supplied sequence to the level array at the specified row and column. Assumes that supplied sequence is the same size or smaller than the levels of the internal builder data array.- Parameters:
row- keycolumn- keysequence- to add- Throws:
IndexOutOfBoundsException- if values overrun level
-
add
Add the values in the supplied interval volume to this builder. This operation is very efficient if this builder and the supplied volume are sourced from the same model.- Parameters:
volume- to add- Throws:
IllegalArgumentException- if the rows, columns, and levels of the supplied volume do not match those of this volume- See Also:
-
multiply
Multiply (scale) all values in this builder.- Parameters:
scale- factor
-
build
Return a newly-created, immutable 3-dimensional interval data container populated with the contents of thisBuilder.
-