summaryrefslogtreecommitdiff
path: root/src/aufgaben/b20160604/Aufgabe1.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:36:30 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:36:30 +0200
commit84e220b332bfffb0f2dcc39b9697a6fd6691d265 (patch)
tree0b861a9a099017ffd9bf00bae12e33ed6a309bbe /src/aufgaben/b20160604/Aufgabe1.java
Initial commitHEADmaster
Diffstat (limited to 'src/aufgaben/b20160604/Aufgabe1.java')
-rwxr-xr-xsrc/aufgaben/b20160604/Aufgabe1.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/aufgaben/b20160604/Aufgabe1.java b/src/aufgaben/b20160604/Aufgabe1.java
new file mode 100755
index 0000000..9574334
--- /dev/null
+++ b/src/aufgaben/b20160604/Aufgabe1.java
@@ -0,0 +1,109 @@
+package aufgaben.b20160604;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import function.Display;
+import function.Grade1;
+import function.Grade2;
+import function.Sin;
+import function.SquareRoot;
+import misc.Utils;
+import aufgaben.Aufgabe;
+import aufgaben.blatt2.Objekt;
+
+public class Aufgabe1 extends Aufgabe implements Runnable {
+
+ private final int width = 500, height = 500;
+ private volatile boolean done;
+ private String name;
+ private Display wasser, boot, segel;
+ private Display[] regenbogen;
+
+ public Aufgabe1() {
+ name = "BV 2 - Aufgabe 1";
+ done = false;
+ this.setSize(width, height);
+ this.setTitle(name);
+ this.addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ System.out.println("close");
+ done = true;
+ }
+ }
+ );
+ }
+
+ @Override
+ public boolean done() {
+ return done;
+ }
+
+ public void paint(Graphics g) {
+ wasser.draw(g);
+ boot.draw(g);
+ g.drawLine(250, 385, 350, 385);
+ g.drawLine(350, 385, 350, 415);
+ g.drawLine(300, 385, 300, 300);
+ segel.draw(g);
+ g.drawLine(300, 385, 330, 370);
+ g.drawOval(450, 0, 100, 100);
+ g.drawLine(400, 50, 450, 50);
+ g.drawLine(400, 60, 450, 60);
+ //ziel1 bei 475, 75
+ g.drawLine(419, 100, 457, 75);
+ g.drawLine(426, 110, 464, 85);
+ for(int i = 0; i<regenbogen.length/5; i++) {
+ g.setColor(new Color(255, i*10, 0));
+ regenbogen[i].draw(g);
+ }
+ for(int i = 0; i<regenbogen.length/5; i++) {
+ g.setColor(new Color(255-(i*10), 255, 0));
+ regenbogen[(regenbogen.length/5)+i].draw(g);
+ }
+ for(int i = 0; i<regenbogen.length/5; i++) {
+ g.setColor(new Color(0, 255, i*10));
+ regenbogen[((regenbogen.length/5)*2)+i].draw(g);
+ }
+ for(int i = 0; i<regenbogen.length/5; i++) {
+ g.setColor(new Color(0, 255-(i*10), 255));
+ regenbogen[((regenbogen.length/5)*3)+i].draw(g);
+ }
+ for(int i = 0; i<regenbogen.length/5; i++) {
+ g.setColor(new Color(i*10, 0, 255));
+ regenbogen[((regenbogen.length/5)*4)+i].draw(g);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void init() {
+ wasser = new Display(0, 400, 500, 10, 0, 7, -1, 1);
+ wasser.addFunction(new Sin(1, 10, 0, 0));
+ boot = new Display(250, 375, 100, 100, 0, 10, 0, 10);
+ boot.addFunction(new SquareRoot(1, 1, 0));
+ segel = new Display(300, 300, 100, 70, 0, 10, 0, 10);
+ segel.addFunction(new Grade2(1, 0, 0));
+ regenbogen = new Display[125];
+ for(int i = 0; i<regenbogen.length; i++) {
+ regenbogen[i] = new Display(0, 100+i, 500, 100, 0, 10, 0, 10);
+ regenbogen[i].addFunction(new Grade2(0.4, -4.0, 10.0));
+ }
+ new Thread(this).start();
+ }
+
+ @Override
+ public void run() {
+ while(!done);
+ done = false;
+ this.setVisible(false);
+ }
+
+}