public class AlgorithmStep
extends java.lang.Object
AlgorithmParagraph
.
AlgorithmParagraph
are executed consecutively.
_latex{
and the postfix }
, like "This is a fraction: _latex{\\frac{1}{2}}."
.
(
and )
behind _latex
, like
"This is a fraction: _latex(-2){\\frac{1}{2}}."
. The use of the parameters is contextual and must not have an effect.
new AlgorithmStep(p, "This is my\nstep text!", 1);
.
Keep in mind that you cannot use this sequence in latex formulas. There you have to use the latex specific line break sequence.
AlgorithmStep(AlgorithmParagraph, String, int, int)
. If the text of a step has
an indent not equal 0
the text is separated off the other steps and is indented by the specified factor. This makes it possible to stagger an algorithm text.This is the text of step 1 --> Indent=0 This is the text of step 2 --> Indent=2 This is the text of step 3 --> Indent=1 ...Breakpoint:
setBreakpoint(boolean)
to specify if the step should have a breakpoint. If a step has a
breakpoint then the runtime environment of the algorithm pauses and the user has to resume it.
AlgorithmExercise
that the user has to solve when the step is entered. Use setExercise(AlgorithmExercise)
to specify an exercise of the step.
Annotation
object using setAnnotation(Annotation)
. You can use annotations to explain an
algorithm step more exact.
getText()
to get the specified text and getFormula(int)
to get a latex formula
of the step.
AlgorithmStep.TextToken
s by using getTextTokenCount()
and getTextToken(int)
.AlgorithmText
,
AlgorithmParagraph
,
LaTeXFormula
Modifier and Type | Class and Description |
---|---|
class |
AlgorithmStep.TextToken
Represents a token of the text of an
AlgorithmStep . |
static class |
AlgorithmStep.TextTokenType
The type of a
AlgorithmStep.TextToken . |
Constructor and Description |
---|
AlgorithmStep(AlgorithmParagraph paragraph,
java.lang.String text,
int id)
Creates a new step.
|
AlgorithmStep(AlgorithmParagraph paragraph,
java.lang.String text,
int id,
int indent)
Creates a new step.
|
Modifier and Type | Method and Description |
---|---|
Annotation |
getAnnotation()
Gets the annotation of the step.
|
AlgorithmExercise<?> |
getExercise()
Gets the exercise that is associated with the step.
|
LaTeXFormula |
getFormula(int index)
Gets the formula at the given index.
|
int |
getFormulaCount()
Gets the number of formulas that the step text contain.
|
int |
getID()
Gets the identifier of the step.
|
int |
getIndent()
Gets the indent of the text of the step.
|
AlgorithmParagraph |
getParagraph()
Gets the associated paragraph.
|
java.lang.String |
getText()
Gets the text of the step, that means the original text with all latex formulas and so on.
|
AlgorithmStep.TextToken |
getTextToken(int index)
Gets a token of the text at a specific index.
|
int |
getTextTokenCount()
Gets the number of tokens of the text.
|
boolean |
hasBreakpoint()
Indicates if the step has currently a breakpoint.
|
void |
setAnnotation(Annotation annotation)
Sets the annotation of the step.
|
void |
setBreakpoint(boolean breakpoint)
Sets if the step has currently a breakpoint.
|
void |
setExercise(AlgorithmExercise<?> exercise)
Sets the exercise that is associated with the step.
|
java.lang.String |
toString() |
public AlgorithmStep(AlgorithmParagraph paragraph, java.lang.String text, int id) throws java.lang.IllegalArgumentException, InvalidIdentifierException, InvalidLaTeXFormulaException
paragraph
- the corresponding paragraphtext
- the text of the step (can contain latex formulas and line breaks)id
- the identifier of the stepjava.lang.IllegalArgumentException
- < 1
InvalidIdentifierException
- InvalidLaTeXFormulaException
- public AlgorithmStep(AlgorithmParagraph paragraph, java.lang.String text, int id, int indent) throws java.lang.IllegalArgumentException, InvalidIdentifierException, InvalidLaTeXFormulaException
paragraph
- the corresponding paragraphtext
- the text of the step (can contain latex formulas and line breaks)id
- the identifier of the stepindent
- the indent of the text of the step (the default value is 0
)java.lang.IllegalArgumentException
- < 1
< 0
InvalidIdentifierException
- InvalidLaTeXFormulaException
- public final AlgorithmParagraph getParagraph()
public final java.lang.String getText()
_latex{
and the postfix }
, like String formula = "This is a fraction: _latex{\\frac{1}{2}}."
.public final int getTextTokenCount()
public final AlgorithmStep.TextToken getTextToken(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getTextTokenCount()
)public int getFormulaCount()
public LaTeXFormula getFormula(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getFormulaCount()
)LaTeXFormula
public final int getID()
0
.public final int getIndent()
0
the text is separated off the other steps and is indented by the specified factor.
This makes it possible to stagger an algorithm text.This is the text of step 1 --> Indent=0 This is the text of step 2 --> Indent=2 This is the text of step 3 --> Indent=1 ...
public boolean hasBreakpoint()
true
if the step has a breakpoint otherwise false
public void setBreakpoint(boolean breakpoint)
breakpoint
- true
if the step has a breakpoint otherwise false
public AlgorithmExercise<?> getExercise()
null
if the step does not have an exerciseAlgorithmExercise
public void setExercise(AlgorithmExercise<?> exercise)
exercise
- the exercise or null
if the step should not have an exerciseAlgorithmExercise
,
AlgorithmText.setFinalExercise(AlgorithmExercise)
public Annotation getAnnotation()
null
if the step does not have an annotationAnnotation
public void setAnnotation(Annotation annotation)
annotation
- the annotation or null
if the step should not have an annotationAnnotation
public java.lang.String toString()
toString
in class java.lang.Object