actual version of our generator
This commit is contained in:
parent
604d5ab06a
commit
20b2323bc4
BIN
ss2012/AlgoAnim/Teil 4/Animal-MultiGenerator-included.jar
Normal file
BIN
ss2012/AlgoAnim/Teil 4/Animal-MultiGenerator-included.jar
Normal file
Binary file not shown.
BIN
ss2012/AlgoAnim/Teil 4/DummyGenerator.class
Normal file
BIN
ss2012/AlgoAnim/Teil 4/DummyGenerator.class
Normal file
Binary file not shown.
25
ss2012/AlgoAnim/Teil 4/DummyGenerator.java
Normal file
25
ss2012/AlgoAnim/Teil 4/DummyGenerator.java
Normal file
@ -0,0 +1,25 @@
|
||||
package generators.maths;
|
||||
|
||||
import generators.framework.Generator;
|
||||
import generators.framework.GeneratorBundle;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import algoanim.animalscript.AnimalScript;
|
||||
|
||||
public class DummyGenerator implements GeneratorBundle {
|
||||
|
||||
@Override
|
||||
public Vector<Generator> getGenerators() {
|
||||
Vector<Generator> generators = new Vector<Generator>(35, 15);
|
||||
generators.add(new AnnotatedSiebdesEratosthenes());
|
||||
generators.add(new FastBitcount());
|
||||
generators.add(new ErweiterterEuklid2());
|
||||
generators.add(new KreuzProd());
|
||||
generators.add(new MatrixMult());
|
||||
generators.add(new ModPow());
|
||||
generators.add(new PascalTriangle());
|
||||
generators.add(new MultiGenerator(new AnimalScript("", "", 0, 0)));
|
||||
return generators;
|
||||
}
|
||||
}
|
||||
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator$1.class
Normal file
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator$1.class
Normal file
Binary file not shown.
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator$2.class
Normal file
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator$2.class
Normal file
Binary file not shown.
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator.class
Normal file
BIN
ss2012/AlgoAnim/Teil 4/MultiGenerator.class
Normal file
Binary file not shown.
@ -10,6 +10,7 @@ import algoanim.primitives.SourceCode;
|
||||
import algoanim.primitives.StringMatrix;
|
||||
import algoanim.primitives.generators.Language;
|
||||
import algoanim.properties.AnimationPropertiesKeys;
|
||||
import algoanim.properties.MatrixProperties;
|
||||
import algoanim.properties.RectProperties;
|
||||
import algoanim.properties.SourceCodeProperties;
|
||||
import algoanim.properties.TextProperties;
|
||||
@ -23,6 +24,16 @@ import de.ahrgr.animal.kohnert.asugen.Font;
|
||||
import generators.framework.properties.AnimationPropertiesContainer;
|
||||
import algoanim.animalscript.AnimalScript;
|
||||
|
||||
/*
|
||||
* Hier ist euch ein anschaulicher Generator gelungen,
|
||||
* den man auch bereits auf beliebige Zahlen loslassen kann.
|
||||
* Blo§ beim Auflšsen der Rekursion werden auch die Schritte,
|
||||
* in denen nicht multipliziert wird, mit animiert.
|
||||
* Das wirkt ein wenig verwirrend, wenn man nur auf das Ergebnis rechts unten schaut und
|
||||
* sich wundert, wieso es sich nicht verŠndert. Im Grunde ist das ganz korrekt,
|
||||
* aber fŸr den unbedarften Zuschauer kšnnte man vielleicht noch daneben anmerken "nichts zu tun".
|
||||
*/
|
||||
|
||||
public class MultiGenerator implements Generator {
|
||||
|
||||
/**
|
||||
@ -30,6 +41,7 @@ public class MultiGenerator implements Generator {
|
||||
*/
|
||||
static int A = 27;
|
||||
static int B = 82;
|
||||
static SourceCodeProperties HIGHLIGHTCOLOR_PROPERTY = null;
|
||||
static int HIGHLIGHTING_TIME = 100; //in ticks
|
||||
static int UNHIGHLIGHTING_TIME = 0; //in ticks
|
||||
|
||||
@ -40,7 +52,11 @@ public class MultiGenerator implements Generator {
|
||||
*/
|
||||
private Language lang;
|
||||
|
||||
|
||||
/**
|
||||
* The "nicht addieren!" text
|
||||
*/
|
||||
private SourceCode nichtAddieren = null;
|
||||
|
||||
/**
|
||||
* The info text as a SourceCode object (first slide)
|
||||
*/
|
||||
@ -111,8 +127,21 @@ public class MultiGenerator implements Generator {
|
||||
|
||||
//=========================================================================================================
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param l
|
||||
* the concrete language object used for creating output
|
||||
*/
|
||||
public MultiGenerator(Language language) {
|
||||
lang = new AnimalScript("Russische Bauenmultiplikation [DE]", "Ulf Gebhardt, Michael Scholz", 800, 600);
|
||||
// This initializes the step mode. Each pair of subsequent steps has to
|
||||
// be divdided by a call of lang.nextStep();
|
||||
lang.setStepMode(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the information text for the first page in the animation
|
||||
*/
|
||||
public void generateInfoText(){
|
||||
@ -161,13 +190,9 @@ public class MultiGenerator implements Generator {
|
||||
* Builds the SourceCode
|
||||
*/
|
||||
public void generateSourceCode(){
|
||||
|
||||
//set the visual properties for the source code
|
||||
SourceCodeProperties scProps = new SourceCodeProperties();
|
||||
scProps.set(AnimationPropertiesKeys.HIGHLIGHTCOLOR_PROPERTY, Color.RED);
|
||||
|
||||
//initialize source code object and add code lines
|
||||
this.sc = lang.newSourceCode(new Coordinates(10, 147), "sourceCode", null, scProps);
|
||||
this.sc = lang.newSourceCode(new Coordinates(10, 147), "sourceCode", null, this.HIGHLIGHTCOLOR_PROPERTY);
|
||||
this.sc.addCodeLine("public int russe(int a, int b){", null, 0, null); // 0
|
||||
this.sc.addCodeLine("if(a == 1){", null, 1, null); // 1
|
||||
this.sc.addCodeLine("return b;", null, 2, null); // 2
|
||||
@ -232,7 +257,7 @@ public class MultiGenerator implements Generator {
|
||||
|
||||
//create table tb1
|
||||
this.tb1 = lang.newStringMatrix(new Coordinates(270, 100), tb1Data, "tb1", null);
|
||||
this.tb1.changeColor(AnimationPropertiesKeys.FILL_PROPERTY, Color.WHITE, null, null);
|
||||
//this.tb1.changeColor(AnimationPropertiesKeys.FILL_PROPERTY, Color.WHITE, null, null);
|
||||
|
||||
}
|
||||
|
||||
@ -264,6 +289,16 @@ public class MultiGenerator implements Generator {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* write "nicht addieren"
|
||||
*/
|
||||
public void writeNichtAddieren(){
|
||||
SourceCodeProperties scProps = new SourceCodeProperties();
|
||||
this.nichtAddieren = lang.newSourceCode(new Offset(2, 8, this.tb2, AnimalScript.DIRECTION_SW), "sourceCode", null, scProps);
|
||||
nichtAddieren.addCodeLine("Das Zwischenergebnis bleibt unverŠndert!", null, 0, null);
|
||||
this.nichtAddieren.hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the table tb2
|
||||
* @param bArrayLength
|
||||
@ -303,6 +338,9 @@ public class MultiGenerator implements Generator {
|
||||
|
||||
//draw tb2
|
||||
drawTb2(this.bArray.length);
|
||||
|
||||
//write "nicht addieren"
|
||||
writeNichtAddieren();
|
||||
|
||||
//STEP
|
||||
lang.nextStep();
|
||||
@ -320,12 +358,15 @@ public class MultiGenerator implements Generator {
|
||||
if(oldLineNumber == 5){
|
||||
this.tb2.unhighlightCell(1, 0, this.unhighTime, this.unhighTime);
|
||||
}
|
||||
this.nichtAddieren.hide();
|
||||
this.sc.unhighlight(oldLineNumber);
|
||||
//STEP
|
||||
lang.nextStep();
|
||||
this.sc.highlight(newLineNumber);
|
||||
if(newLineNumber == 5){
|
||||
this.tb2.highlightCell(1, 0, this.highTime, this.highTime);
|
||||
}else{
|
||||
this.nichtAddieren.show();
|
||||
}
|
||||
//update tb2
|
||||
this.bArray[i-1] = this.bArray[i-1] + this.bArray[i];
|
||||
@ -480,17 +521,17 @@ public class MultiGenerator implements Generator {
|
||||
|
||||
|
||||
public void init(){
|
||||
lang = new AnimalScript("Russische Bauenmultiplikation [DE]", "Ulf Gebhardt, Michael Scholz", 800, 600);
|
||||
//lang = new AnimalScript(getAlgorithmName(), getAnimationAuthor(), 640, 480);
|
||||
|
||||
}
|
||||
|
||||
public String generate(AnimationPropertiesContainer props,Hashtable<String, Object> primitives) {
|
||||
B = (Integer)primitives.get("b");
|
||||
A = (Integer)primitives.get("a");
|
||||
B = (Integer)primitives.get("b");
|
||||
HIGHLIGHTCOLOR_PROPERTY = (SourceCodeProperties)props.getPropertiesByName("Quelltext");
|
||||
|
||||
init(); //initialize the language
|
||||
|
||||
lang.setStepMode(true);
|
||||
this.multiply(A, B);
|
||||
multiply(A, B);
|
||||
|
||||
return lang.toString();
|
||||
}
|
||||
@ -510,15 +551,15 @@ public class MultiGenerator implements Generator {
|
||||
public String getDescription(){
|
||||
return "Das hier vorgestellte Verfahren eignete sich fŸr die Multiplikation zweier ganzer Zahlen. Es ist auch unter den"
|
||||
+"\n"
|
||||
+"Namen Ägyptischen Multiplizieren, Abessinische Bauernregel oder Verdopplungs-Halbierungs-Methode"
|
||||
+"Namen Ägyptischen Multiplizieren, Abessinische Bauernregel oder Verdopplungs-Halbierungs-Methode"
|
||||
+"\n"
|
||||
+"bekannt. Die Geschichte des vorgestellten Rechenverfahrens führt bis auf die Ägypter zurŸck. Sie"
|
||||
+"bekannt. Die Geschichte des vorgestellten Rechenverfahrens führt bis auf die Ägypter zurŸck. Sie"
|
||||
+"\n"
|
||||
+"nutzten diese Methode nachweislich zur Multiplikation zweier ganzer Zahlen. Das Verfahren baut auf dem Teile und Herrsche Prinzip"
|
||||
+"\n"
|
||||
+"(Divide et impera ) auf und lŠsst sich somit leicht mittels Rekursion implementieren.\n"
|
||||
+"\n"
|
||||
+"Die Funktionsweise lässt sich in die folgenden fünf Schritte gliedern:\n"
|
||||
+"Die Funktionsweise lässt sich in die folgenden fünf Schritte gliedern:\n"
|
||||
+"\n"
|
||||
+"1. Schreibe die beiden zu multiplizierenden Zahlen nebeneinander.\n"
|
||||
+"\n"
|
||||
@ -530,7 +571,7 @@ public class MultiGenerator implements Generator {
|
||||
+"\n"
|
||||
+"4. Nun streicht man alle Zeilen, in denen die linke Zahl gerade ist.\n"
|
||||
+"\n"
|
||||
+"5. Schlussendlich werden alle übrigen Zahlen der rechten Spalte addiert."
|
||||
+"5. Schlussendlich werden alle übrigen Zahlen der rechten Spalte addiert."
|
||||
+"\n"
|
||||
+" ";
|
||||
}
|
||||
@ -567,7 +608,7 @@ public class MultiGenerator implements Generator {
|
||||
}
|
||||
|
||||
public GeneratorType getGeneratorType() {
|
||||
return new GeneratorType(GeneratorType.GENERATOR_TYPE_MORE);
|
||||
return new GeneratorType(GeneratorType.GENERATOR_TYPE_MATHS);
|
||||
}
|
||||
|
||||
public String getOutputLanguage() {
|
||||
|
||||
@ -9,5 +9,79 @@
|
||||
<name>b</name>
|
||||
<value><int>82</int></value>
|
||||
</Primitive>
|
||||
<AnimationProperties type="SourceCodeProperties">
|
||||
<AnimationPropertyItem type="BooleanPropertyItem">
|
||||
<name>bold</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><boolean value="false" /></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="ColorPropertyItem">
|
||||
<name>color</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><Color>(0, 0, 0)</Color></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="ColorPropertyItem">
|
||||
<name>highlightColor</name>
|
||||
<isEditable value="true" />
|
||||
<label>Markierungsfarbe Quelltext</label>
|
||||
<value><Color>(255, 0, 0)</Color></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="BooleanPropertyItem">
|
||||
<name>hidden</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><boolean value="false" /></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="FontPropertyItem">
|
||||
<name>font</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><Font>SansSerif</Font></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="StringPropertyItem">
|
||||
<name>name</name>
|
||||
<isEditable value="true" />
|
||||
<label></label>
|
||||
<value><String>Quelltext</String></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="ColorPropertyItem">
|
||||
<name>contextColor</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><Color>(0, 0, 0)</Color></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="BooleanPropertyItem">
|
||||
<name>italic</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><boolean value="false" /></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="IntegerPropertyItem">
|
||||
<name>depth</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><int>1</int></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="IntegerPropertyItem">
|
||||
<name>row</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><int>1</int></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="IntegerPropertyItem">
|
||||
<name>size</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><int>10</int></value>
|
||||
</AnimationPropertyItem>
|
||||
<AnimationPropertyItem type="IntegerPropertyItem">
|
||||
<name>indentation</name>
|
||||
<isEditable value="false" />
|
||||
<label></label>
|
||||
<value><int>1</int></value>
|
||||
</AnimationPropertyItem>
|
||||
</AnimationProperties>
|
||||
</Folder>
|
||||
</PropertiesTreeModel>
|
||||
Loading…
x
Reference in New Issue
Block a user