public abstract class MTree_<M extends MTree_<M>> extends Object implements MetrumIndication
MTree
and MTreeSpec
.
It realizes common methods for retrieval, inquiry, visualisation, etc.
MTree
.
A user constructs an MTreeSpec
, for representing a specifications, and then calls
MTree.install(MTreeSpec,MTree.Parameters)
to expand these.Modifier and Type | Field and Description |
---|---|
(package private) M |
alternative
An alternative to this node.
|
(package private) @Opt Rational |
duration
The duration of the time interval (of a measure) represented by this node.
|
(package private) @Opt Rational |
end
The end time of the time interval (of a measure) represented by this node,
relative to the start of the topmost node, which is fixed as "0/1".
|
(package private) boolean |
equidist
Whether all child nodes of this node have equal durations.
|
(package private) boolean |
explicitDuration
Whether the duration of this node has been given explicitly with its specification.
|
(package private) boolean |
implicit
Whether this node has been created automatically, by implict division into halfs.
|
(package private) boolean |
initialized
Whether all initialization has already been performed, by a call to
MTreeSpec.initialize(Modifiers.Reaction) . |
(package private) M |
parent
The parent node of this tree node.
|
(package private) int |
position
Position ot "this" in the parent's list, starting from zero(0).
|
(package private) @Opt Rational |
start
The start time of the time interval (of a measure) represented by this node,
relative to the start of the topmost node, which is fixed as "0/1".
|
(package private) List<M> |
subs
List of child nodes.
|
Constructor and Description |
---|
MTree_() |
Modifier and Type | Method and Description |
---|---|
void |
addAlternative(M alt)
Adds a node at the END of this's alternative chain.
Used by MTreeSpec and MTree. |
protected void |
calcStartEnd(Rational start)
|
List<Integer> |
compoundName() |
Rational |
constantRationalMeasureDuration()
Returns the length of a measure.
|
protected void |
copyTimeValues(MTree_<?> newthis)
Copies only time values and boolean flags, from this instance into the
argument.
|
void |
dump()
Prints an indented visualization to System.err.
|
void |
dump(PrintStream p)
Prints an indented visualization.
|
void |
dump(PrintWriter p)
Prints an indented visualization.
|
List<Integer> |
durationName() |
M |
get_alternative()
Return the (first) alternative node.
|
Rational |
get_duration()
Get the duration value.
|
Rational |
get_end()
Get the end time point value.
|
boolean |
get_explicitDuration()
Return whether the duration has been set explicitly, when speficfying this node.
|
boolean |
get_implicit()
Whether this has been created explicitly, or by implicit division by two
|
boolean |
get_initialized()
Retrun whether this node is initialized.
|
M |
get_parent()
Return the parent node.
|
int |
get_position()
Position in the parents' list, starting from zero(0).
|
int |
get_size_binary()
Returns the number of children of this node.
|
int |
get_size() |
Rational |
get_start()
Get the start time point value.
|
List<M> |
get_subs() |
M |
getFollowing()
Returns the highest node which starts at the timepoint when this ends.
|
M |
getFollowingSibling()
Returns the node which is child of the same parent, and one position further,
iff it exists, otherwise null.
|
M |
getPrecedingSibling()
Returns the node which is child of the same parent, and one position earlier,
iff it exists, otherwise null.
|
M |
getTopNode()
Get the top most node to which this node is linked as a descendant.
|
boolean |
is_equi_binary()
Returns whether the cild level is divided equidistantly by two.
|
boolean |
isFollowingSiblingOf(MTree_<?> predec)
Returns whether this node is child of the same parent as the argument,
and one position further.
|
protected void |
propagateDown_alt(Rational altdur,
Modifiers.Reaction redundantDuration)
The duration of some alternative of the node is fixed
(explicitly when constructing, or by upward propagation;
in altdur != null).
|
protected void |
propagateDown(Modifiers.Reaction redundantDuration)
The duration of the node is fixed (by construction or by downward propagation or
by some alternative.) Either all children do not have a duration, then the
duration is distributed equally among them, or only one child does not have a
duration and gets the rest.
|
protected void |
propagateUp(Modifiers.Reaction redundantDuration)
Visit depth-first and sum-up the durations of children, as long as possible and
necessary.
|
protected abstract M |
self()
Necessary to avoid "unchecked cast" warning when returning "this" instance
as a result of a methode declared of type "M".
|
String |
toString()
gives one-line rendering.
|
int position
@Opt M extends MTree_<M> parent
@Opt M extends MTree_<M> alternative
@Opt @Opt Rational duration
==null
in a specification and will be calculated by the constraints imposed
by parents and siblings, etc. Must be !=null
after installing and in
every instance of MTree
.@Opt @Opt Rational start
eu.bandm.sig.music.entities.MTreeSpec#initialize(Reaction)
and MTree.install(MTreeSpec,MTree.Parameters)
have been called.
Can be ==null
in a specification and will be calculated by the constraints imposed
by parents and siblings, etc. Must be !=null
after installing and in
every instance of MTree
.@Opt @Opt Rational end
eu.bandm.sig.music.entities.MTreeSpec#initialize(Reaction)
and MTree.install(MTreeSpec,MTree.Parameters)
have been called.
Is always ==null
in a specification and will be filled by the constraints imposed
by parents and siblings, etc. Must be !=null
after installing and in
every instance of MTree
.boolean explicitDuration
boolean initialized
MTreeSpec.initialize(Modifiers.Reaction)
.boolean implicit
boolean equidist
protected void copyTimeValues(MTree_<?> newthis)
public void addAlternative(M alt)
alt
- the node to append to the list of alternatives of this node.
Its start, end, duration, position and parent must be the same as with this,
if specified.IllegalArgumentException
- if durations of this and "alt" differ.public Rational constantRationalMeasureDuration()
constantRationalMeasureDuration
in interface MetrumIndication
public int get_position()
public int get_size()
public boolean get_implicit()
public boolean get_initialized()
public Rational get_start()
initialized
should be ==true and thus the result!=null.public Rational get_end()
initialized
should be ==true and thus the result!=null.public Rational get_duration()
initialized
should be ==true and thus the result!=null.public boolean get_explicitDuration()
public boolean isFollowingSiblingOf(MTree_<?> predec)
@Opt public M getFollowingSibling()
alternative
, which have a different structure, but
the same duration.@Opt public M getPrecedingSibling()
alternative
, which have a different structure, but
the same duration.@Opt public M getFollowing()
alternative
, which have a different structure, but
the same duration. protected abstract M self()
public M getTopNode()
public int get_size_binary()
public boolean is_equi_binary()
protected void calcStartEnd(Rational start)
start
, end
and
equidist
.
Assume that all duration
fields of all visited nodes are set.start
- the start time point of this node, relative to the start of the
top-most node, which represents a complete measure.protected void propagateUp(Modifiers.Reaction redundantDuration)
propagateDown(Modifiers.Reaction)
for the sub-tree.protected void propagateDown_alt(Rational altdur, Modifiers.Reaction redundantDuration)
propagateDown(Modifiers.Reaction)
.protected void propagateDown(Modifiers.Reaction redundantDuration)
public List<Integer> durationName()
public List<Integer> compoundName()
public String toString()
dump(PrintStream)
, which gives a
multi-line indented view.public void dump()
public void dump(PrintStream p)
public void dump(PrintWriter p)