Package gov.usgs.earthquake.nshmp.data
Class IntervalVolume.Builder
- java.lang.Object
-
- gov.usgs.earthquake.nshmp.data.IntervalVolume.Builder
-
- Enclosing class:
- IntervalVolume
public static final class IntervalVolume.Builder extends Object
A builder of immutableIntervalVolume
s.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 ifmax - min
is not evenly divisible byΔ
.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Create a new interval volume builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IntervalVolume.Builder
add(double row, double column, double[] values)
Add to the level array at the specified row and column.IntervalVolume.Builder
add(double row, double column, double level, double value)
Add to the existing value at the specified row, column, and level.IntervalVolume.Builder
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.IntervalVolume.Builder
add(int row, int column, int level, double value)
Add to the existing value at the specified row, column, and level indices.IntervalVolume.Builder
add(IntervalVolume volume)
Add the values in the supplied interval volume to this builder.IntervalVolume
build()
Return a newly-created, immutable 3-dimensional interval data container populated with the contents of thisBuilder
.int
columnIndex(double column)
Return the index of the column that would contain the supplied value.IntervalVolume.Builder
columns(double min, double max, double delta)
Define the data volume columns.static IntervalVolume.Builder
copyOf(IntervalVolume volume)
Create a new builder with the structure and content identical to that of the supplied volume.static IntervalVolume.Builder
fromModel(IntervalVolume model)
Create a new builder with a structure identical to that of the supplied model.int
levelIndex(double level)
Return the index of the level that would contain the supplied value.IntervalVolume.Builder
levels(double min, double max, double delta)
Define the data volume levels.IntervalVolume.Builder
multiply(double scale)
Multiply (scale
) all values in this builder.int
rowIndex(double row)
Return the index of the row that would contain the supplied value.IntervalVolume.Builder
rows(double min, double max, double delta)
Define the data volume rows.IntervalVolume.Builder
set(double row, double column, double level, double value)
Set the value at the specified row, column, and level.IntervalVolume.Builder
set(int row, int column, int level, double value)
Set the value at the specified row, column, and level indices.
-
-
-
Method Detail
-
copyOf
public static IntervalVolume.Builder copyOf(IntervalVolume volume)
Create a new builder with the structure and content identical to that of the supplied volume.- Parameters:
volume
- to copy
-
fromModel
public static IntervalVolume.Builder fromModel(IntervalVolume model)
Create a new builder with a structure identical to that of the supplied model.- Parameters:
model
- data volume
-
rows
public IntervalVolume.Builder rows(double min, double max, double delta)
Define the data volume rows.- Parameters:
min
- lower edge of lowermost row binmax
- upper edge of uppermost row bindelta
- bin discretization
-
columns
public IntervalVolume.Builder columns(double min, double max, double delta)
Define the data volume columns.- Parameters:
min
- lower edge of lowermost column binmax
- upper edge of uppermost column bindelta
- bin discretization
-
levels
public IntervalVolume.Builder levels(double min, double max, double delta)
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
public IntervalVolume.Builder set(double row, double column, double level, double value)
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
public IntervalVolume.Builder set(int row, int column, int level, double value)
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
public IntervalVolume.Builder add(double row, double column, double level, double value)
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
public IntervalVolume.Builder add(int row, int column, int level, double value)
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
public IntervalVolume.Builder add(double row, double column, double[] values)
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
public IntervalVolume.Builder 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. 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
public IntervalVolume.Builder add(IntervalVolume volume)
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:
fromModel(IntervalVolume)
-
multiply
public IntervalVolume.Builder multiply(double scale)
Multiply (scale
) all values in this builder.- Parameters:
scale
- factor
-
build
public IntervalVolume build()
Return a newly-created, immutable 3-dimensional interval data container populated with the contents of thisBuilder
.
-
-