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
|
import sum.kern.*;
public class KnopfAnwendung extends EreignisAnwendung
{
// Bezugsobjekte
private int count;
private double ge;
RechteckKnopf RK;
RechteckKnopf RK2;
RechteckKnopf RK3;
Auto auto;
Buntstift stift;
public KnopfAnwendung(int pH,int pV)
{
super(pH,pV);
RK = new RechteckKnopf(this.bildschirm().breite()/4,this.bildschirm().hoehe()-50,this,1,"Fahr los !");
RK2 = new RechteckKnopf(this.bildschirm().breite()/4*2,this.bildschirm().hoehe()-50,this,2,"Halt an !");
RK3 = new RechteckKnopf(this.bildschirm().breite()/4*3,this.bildschirm().hoehe()-50,this,3,"Bremse !");
auto = new Auto(this.bildschirm().breite()/5,this.bildschirm().hoehe()-100,0.00);
stift = new Buntstift();
}
public void bearbeiteMausDruck(double pH,double pV)
{
RK.bearbeiteMausDruck(pH,pV);
RK2.bearbeiteMausDruck(pH,pV);
RK3.bearbeiteMausDruck(pH,pV);
}
public void bearbeiteMausLos(double pH,double pV)
{
RK.bearbeiteMausLos(pH,pV);
RK2.bearbeiteMausLos(pH,pV);
RK3.bearbeiteMausLos(pH,pV);
}
public void bearbeiteMausDoppelKlick(double pH,double pV){};
public void bearbeiteMausBewegt(double pH,double pV)
{
RK.bearbeiteMausBewegt(pH,pV);
RK2.bearbeiteMausBewegt(pH,pV);
RK3.bearbeiteMausBewegt(pH,pV);
}
public void bearbeiteTaste(char pZeichen){};
public void idle()
{
auto.bewegeBis(stift.hPosition(),stift.vPosition());
if(auto.aktiv())
{
if(count == 1)
{
if(auto.ge() > 0)
{
auto.sge(auto.ge()-0.0001);
}
else
{
count = 0;
auto.saktiv(false);
}
}
else
{
if(auto.ge() < 0.1)
{
auto.sge(auto.ge()+0.0001);
}
}
if(stift.hPosition() >= this.bildschirm().breite())
{
stift.bewegeBis(0,stift.vPosition());
}
else
{
stift.bewegeBis(stift.hPosition()+auto.ge(),stift.vPosition());
}
}
}
public void action(int pN)
{
switch(pN)
{
case 1 : auto.saktiv(true);break;
case 2 : auto.saktiv(false);break;
case 3 : count = 1;break;
}
}
}
|