Package uk.ac.qmul.eecs.depic.daw
Class Selection
- java.lang.Object
-
- uk.ac.qmul.eecs.depic.patterns.Range<java.lang.Integer>
-
- uk.ac.qmul.eecs.depic.daw.Selection
-
public final class Selection extends Range<java.lang.Integer>
A selection on integer values
-
-
Field Summary
Fields Modifier and Type Field and Description static Selection
ZERO_SELECTION
-
Fields inherited from class uk.ac.qmul.eecs.depic.patterns.Range
end, NORMALIZED_RANGE_D, NORMALIZED_RANGE_F, start
-
-
Constructor Summary
Constructors Constructor and Description Selection(int start, int scaleFactor)
Selection(int start, int end, int scaleFactor)
Constructs a new instance ofLoopPoints
from the bound values passed as argument.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
contains(int p)
Returnstrue
ifp
is contained in the selection ( p is greater thangetStart()
and smaller thangetEnd()
).static int
convertFactor(int position, int fromFactor, int toFactor)
static Selection
convertFactor(Selection s, int newFactor)
Convert a selection to another selection with a new scale factor.java.lang.Integer
getEnd()
Returns the end value of the loopint
getScaleFactor()
Returns the scale factor of this selectionboolean
isOpen()
Checks whether the selection defines an open or closed interval.java.lang.String
toString()
-
-
-
Field Detail
-
ZERO_SELECTION
public static Selection ZERO_SELECTION
-
-
Constructor Detail
-
Selection
public Selection(int start, int scaleFactor)
-
Selection
public Selection(int start, int end, int scaleFactor)
Constructs a new instance ofLoopPoints
from the bound values passed as argument. The lower value is assigned to the start of the loop, whereas the higher value is assigned to the end of the loop. If the two values are equals the loop is assumed to have no end but only a starting point.- Parameters:
start
- the start of the range, it must be greater or equal than 0end
- the end of the range, it must be either greater or equal than 0 or equal toNO_POSITION
scaleFactor
-- Throws:
java.lang.IndexOutOfBoundsException
- whetherstart
is a negative value orend
is a negative value different fromNO_POSITION
java.lang.IllegalArgumentException
- ifend
is greater thanstart
-
-
Method Detail
-
getEnd
public final java.lang.Integer getEnd()
Returns the end value of the loop
-
getScaleFactor
public int getScaleFactor()
Returns the scale factor of this selection- Returns:
- the scale factor of this selection
-
isOpen
public boolean isOpen()
Checks whether the selection defines an open or closed interval. The selection is open is the end is equal toNO_POSITION
.- Returns:
true
is the selection is open,false
otherwise
-
contains
public boolean contains(int p)
Returnstrue
ifp
is contained in the selection ( p is greater thangetStart()
and smaller thangetEnd()
). If the selection is open,false
is returned.- Parameters:
p
- the integer vale to check for- Returns:
-
convertFactor
public static Selection convertFactor(Selection s, int newFactor)
Convert a selection to another selection with a new scale factor. Thestart
andend
of the selection are changed accordingly.- Parameters:
s
- the selection to convertnewFactor
- the factor of the converted selection- Returns:
s
ifnewFactor
is already the scale factor ofs
, a new selection
-
convertFactor
public static int convertFactor(int position, int fromFactor, int toFactor)
-
-