public class CodomainChain extends Object
A lookup table is built by composing all maps (in the same order as their
contexts were enqueued) in a single tranformation and then by applying this
map to each value in the codomain interval
[intervalStart, intervalEnd]
note that, in order to
compose the maps, this interval has to be both the domain and codomain of
each transformation. The LUT is re-built everytime the definition of the
codomain interval or the state of the queue changes.
Contexts are privately owned (add
and
update
make copies) because we want to
exclude the possibility that a context's state can be modified after the
lookup table is built.
Constructor and Description |
---|
CodomainChain(int start,
int end)
Creates a new chain.
|
CodomainChain(int start,
int end,
List mapContexts)
Creates a new chain.
|
Modifier and Type | Method and Description |
---|---|
void |
add(CodomainMapContext mapCtx)
Adds a map context to the chain.
|
int |
getIntervalEnd()
Returns the upper bound of the codomain interval.
|
int |
getIntervalStart()
Returns the lower bound of the codomain interval.
|
void |
remove()
Removes all
CodomainMapContext s except the identity and resets
the interval. |
void |
remove(CodomainMapContext mapCtx)
Removes a map context from the chain.
|
void |
setInterval(int start,
int end)
Sets the codomain interval.
|
String |
toString()
Overrides the toString method.
|
int |
transform(int x)
Applies the transformation.
|
void |
update(CodomainMapContext mapCtx)
Updates a map context in the chain.
|
public CodomainChain(int start, int end)
transform
method
returns the input value. The interval defined by start
and
end
must be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.public CodomainChain(int start, int end, List mapContexts)
mapContexts
is null
or empty, the chain
will contain only the identity context. The interval defined by
start
and end
has to be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.mapContexts
- The sequence of CodomainMapContext
objects that define
the chain. No two objects of the same class are allowed. The
objects in this list are copied.IllegalArgumentException
- If one of the contexts is already defined.public void setInterval(int start, int end)
start
and end
must be a sub-interval of
[QuantumStrategy.MIN
, QuantumStrategy.MAX
]
.start
- The lower bound of the codomain interval.end
- The upper bound of the codomain interval.public int getIntervalEnd()
public int getIntervalStart()
public void remove()
CodomainMapContext
s except the identity and resets
the interval.public void add(CodomainMapContext mapCtx)
mapCtx
. This is
because we don't want to compose the same transformation twice. This
method adds a copy of mapCtx
to the chain. This is because
we want to exclude the possibility that the context's state can be
modified after the lookup table is built. This method triggers a re-build
of the lookup table.mapCtx
- The context to add. Mustn't be null
.IllegalArgumentException
- If the context is already defined.public void update(CodomainMapContext mapCtx)
mapCtx
.
This method replaces the old context with a copy of mapCtx
.
This is because we want to exclude the possibility that the context's
state can be modified after the lookup table is built. This method
triggers a re-build of the lookup table.mapCtx
- The context to add. Mustn't be null
and already
contained in the chain.IllegalArgumentException
- If the specifed context doesn't exist.public void remove(CodomainMapContext mapCtx)
mapCtx
. This means that the transformation associated to
the passed context won't be applied. This method triggers a re-build of
the lookup table.mapCtx
- The context to remove.public int transform(int x)
x
- The input value. Must be in the current codomain interval.public String toString()
toString
in class Object
Object.toString()
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.