public class AlgorithmText
extends java.lang.Object
AlgorithmRTE
to execute a specific algorithm step.
getExecutingStepID()
. Use getStepByID(int)
or getParagraphByID(int)
to get a step or paragraph with the aid of an identifier.
setFinalExercise(AlgorithmExercise)
to set an exercise that has to be solved when the algorithm is terminated. If you want to add
exercises to steps then use AlgorithmStep.setExercise(AlgorithmExercise)
.AlgorithmParagraph
,
AlgorithmStep
Modifier and Type | Field and Description |
---|---|
static float |
FONTSIZE
the default font size of the text and the latex formulas which is 12.0f
|
Constructor and Description |
---|
AlgorithmText()
Creates a new empty algorithm text.
|
AlgorithmText(float fontSize)
Creates a new empty algorithm text.
|
Modifier and Type | Method and Description |
---|---|
void |
addTextListener(AlgorithmTextListener listener)
Adds a listener to listen to changes inside the text that means if new steps or
paragraphs were added or if the current step changed.
|
AlgorithmText |
getBaseCopy()
Returns a deep base copy of the algorithm text meaning that the returned text contains the
same structure as this text but some properties (like breakpoints, exercises, etc.) are not included.
|
int |
getExecutingStepID()
Gets the identifier of the step that is currently executed in the runtime environment of
the algorithm.
|
AlgorithmExercise<?> |
getFinalExercise()
Gets the final exercise of the algorithm.
|
int |
getFirstStepID()
Gets the id of the first step in the first paragraph of the algorithm text.
|
float |
getFontSize()
Gets the font size of the text
|
AlgorithmParagraph |
getParagraph(int index)
Gets the paragraph at the given index.
|
AlgorithmParagraph |
getParagraphByID(int id)
Gets the paragraph that has the given id.
|
int |
getParagraphCount()
Gets the number of paragraphs.
|
AlgorithmStep |
getStep(int index)
Gets the step at the given index.
|
AlgorithmStep |
getStepByID(int id)
Gets the step that has the given id.
|
int |
getStepCount()
Gets the number of steps that are available in the text.
|
void |
removeTextListener(AlgorithmTextListener listener)
Removes an existing listener.
|
void |
setExecutingStepID(int id)
Sets the identifier of the step that is currently executed in the runtime environment of
the algorithm.
|
void |
setFinalExercise(AlgorithmExercise<?> exercise)
Sets the final exercise of the algorithm.
|
void |
setFontSize(float size)
Sets the font size of the text.
|
public static final float FONTSIZE
public AlgorithmText()
public AlgorithmText(float fontSize) throws java.lang.IllegalArgumentException
fontSize
- the font size of the textjava.lang.IllegalArgumentException
- <= 0.0f
public void addTextListener(AlgorithmTextListener listener)
listener
- the listenerpublic void removeTextListener(AlgorithmTextListener listener)
listener
- the listenerpublic int getParagraphCount()
public AlgorithmParagraph getParagraph(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getParagraphCount()
)public AlgorithmParagraph getParagraphByID(int id)
id
- the identifier of the paragraphnull
, if there is no paragraph with the specified idpublic int getStepCount()
public AlgorithmStep getStep(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getStepCount()
)public AlgorithmStep getStepByID(int id)
id
- the identifier of the stepnull
, if there is no step with the specified idpublic int getExecutingStepID()
-1
if there is no step in executionAlgorithmRTE
public void setExecutingStepID(int id)
id
- the id of the currently executed step or -1
if there is no step in executionAlgorithmRTE
public int getFirstStepID()
-1
if the text does not have stepspublic float getFontSize()
public void setFontSize(float size) throws java.lang.IllegalArgumentException
size
- the font size in which the text and the formulas are displayedjava.lang.IllegalArgumentException
- <= 0.0f
public AlgorithmExercise<?> getFinalExercise()
null
if the algorithm has no final exercisepublic void setFinalExercise(AlgorithmExercise<?> exercise)
exercise
- the final exercise or null
if the algorithm should not have a final exercisepublic AlgorithmText getBaseCopy()