|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A mechanism to record where an object prefers to be broken. An implementation of this interface is passed to report element views for them to record the break weight at certain indices.
At each index, the object sets its preferred break weight. If multiple weights are recorded at the same index, then the minimum weight prevails. The weights have the following meanings:
Weight | Meaning |
UNDEFINED_BREAK_WEIGHT | The weight has yet to be set for the index. |
BAD_BREAK_WEIGHT | The object cannot be broken at the index. |
FORCED_BREAK_WEIGHT | The object requests to be broken at the index. |
GOOD_BREAK_WEIGHT | The index is a good break position. |
EXCELLENT_BREAK_WEIGHT | The index is an excellent break position. |
Clients can change the range of indices for which to record break weights via the methods
setRange
and createView
.
The former establishes a clip range such that any
index outside of the range is ignored. The latter establishes a clip range
but additionally resets the beginning of this range to index 0.
After the weights have been set, use getBreakIndex
to determine the best
break position.
View.gatherBreakWeights(int, sos.reports.BreakWeightRecorder)
,
ArrayBreakWeightRecorder
Field Summary | |
static int |
BAD_BREAK_WEIGHT
A constant signaling a bad break (1). |
static int |
EXCELLENT_BREAK_WEIGHT
A constant signaling an excellent break (4). |
static int |
FORCED_BREAK_WEIGHT
A constant signaling that a break is required (2). |
static int |
GOOD_BREAK_WEIGHT
A constant signaling a good break (3). |
static int |
UNDEFINED_BREAK_WEIGHT
A constant signaling that the break weight has not been specified (0). |
Method Summary | |
BreakWeightRecorder |
createView(int index,
int length)
Returns a view of this recorder. |
void |
fill(int weight)
Fills the entire clip range with the specified weight. |
void |
fill(int index,
int length,
int weight)
Fills the specified range with the specified weight. |
void |
fillEnd(int index,
int weight)
Fills the end portion with the specified weight. |
int |
getBestWeight()
Returns the best, or highest, break weight in the clip range. |
int |
getBreakIndex()
Returns the best place to break within the clip range, or -1 if such a place does not exist. |
int |
getFirstIndexOfWeight(int weight)
Returns the index of the first bit in the clip range with the specified weight. |
int |
getFirstIndexOfWeightAtLeast(int weight)
Returns the index of the first bit in the clip range with a weight greater than or equal to the specified weight. |
int |
getLastIndexOfWeight(int weight)
Returns the index of the last bit in the clip range with the specified weight. |
int |
getLastIndexOfWeightAtLeast(int weight)
Returns the index of the last bit in the clip range with a weight greater than or equal to the specified weight. |
int |
getRangeLength()
Returns the length of the clip range. |
int |
getRangeStart()
Returns the starting index of the clip range. |
int |
getWeight(int index)
Returns the weight at the specified index. |
void |
setRange(int index,
int length)
Sets this recorder's clip range. |
void |
setWeight(int index,
int weight)
Sets the weight at the specified index. |
Field Detail |
public static final int UNDEFINED_BREAK_WEIGHT
public static final int BAD_BREAK_WEIGHT
public static final int FORCED_BREAK_WEIGHT
public static final int GOOD_BREAK_WEIGHT
public static final int EXCELLENT_BREAK_WEIGHT
Method Detail |
public BreakWeightRecorder createView(int index, int length)
length - 1
. Index 0 in the view corresponds to
index
in this recorder,
and index length - 1
corresponds to index + length - 1
.
Operations on the view within its range propagate to this recorder.The specified index and length are bound by this recorder's current range. That is, they are adjusted so that the view cannot operate outside this recorder's range.
index
- index of this recorder to get mapped to index 0 of the returned viewlength
- number of indices to be in the view
length
indices and
translated by index
java.lang.IllegalArgumentException
- if length < 0
java.lang.IndexOutOfBoundsException
- if index < 0
public void fill(int weight)
weight
- maximum weight that each bit in the clip range should havepublic void fill(int index, int length, int weight)
The range is bound by this recorder's current clip range. That is, bits outside the clip range are ignored.
index
- start index at which to set the weightlength
- number of bits for which to set the wieghtweight
- maximum weight that each bit in the specified range should have
java.lang.IllegalArgumentException
- if length < 0
java.lang.IndexOutOfBoundsException
- if index < 0
fill(int)
,
fillEnd(int, int)
public void fillEnd(int index, int weight)
The range is bound by this recorder's current clip range. That is, bits outside the clip range are ignored.
index
- start index at which to set the weightweight
- maximum weight that each bit in the specified range should have
java.lang.IndexOutOfBoundsException
- if index < 0
public int getBestWeight()
public int getBreakIndex()
BAD_BREAK_WEIGHT
.
public int getFirstIndexOfWeight(int weight)
weight
- weight to seek
public int getFirstIndexOfWeightAtLeast(int weight)
weight
- minimum weight to seek
public int getLastIndexOfWeight(int weight)
weight
- weight to seek
public int getLastIndexOfWeightAtLeast(int weight)
weight
- minimum weight to seek
public int getRangeStart()
getRangeLength()
,
setRange(int, int)
public int getRangeLength()
getRangeStart()
,
setRange(int, int)
public int getWeight(int index)
index
- index at which to fetch the weight
index
java.lang.IndexOutOfBoundsException
- if index < 0
or index
is outside the clip rangepublic void setRange(int index, int length)
The range is bound by this recorder's current clip range. That is, bits outside the clip range are ignored.
index
- start index of range to cliplength
- length of range to clip
java.lang.IllegalArgumentException
- if length < 0
java.lang.IndexOutOfBoundsException
- if index < 0
public void setWeight(int index, int weight)
index
is the minimum of the current weight and the
specified weight.
index
- index at which to set the weightweight
- weight of a potential break at index
java.lang.IndexOutOfBoundsException
- if index < 0
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |