summaryrefslogtreecommitdiff
path: root/src/aufgaben/b20160604/Aufgabe1.java
blob: 95743346f6443c9de19f1a0554abbff879e787e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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);
	}

}