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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.Graphics;
public class neu extends Applet {
Pause p=new Pause();
int xmax=500;
int ymax=500;
int V=1;
int T=273;
int x0, y0, x1, x2, y1, y2, r, fakx, faky, xPUNKT, yPUNKT;
int Ex=25; // linter oberer Eckpunkt Zylinder
int Ey=330; // linker oberer Eckpunkt Zylinder
int Bx=15; // Breite Kolben
int By=30; // Breite Zylinder
int xm=Ex+Bx+100;
int ym=(Ey+(By/2)-1);
Scrollbar sbarVOLUMEN, sbarTEMPERATUR;
Label labVOLUMEN, labTEMPERATUR, labPUNKT;
public void init() {
resize(xmax, ymax);
setLayout(null);
setBackground(Color.lightGray);
r=5;
x0=25; y0=ymax-200-15;
fakx=20;
faky=30;
labVOLUMEN = new Label("Volumen = "+String.valueOf(V)+"ltr");
labVOLUMEN.setBounds(50,398,90,25);
labVOLUMEN.setBackground(Color.gray);
add(labVOLUMEN);
sbarVOLUMEN = new Scrollbar(Scrollbar.HORIZONTAL,V,1,1,100);
sbarVOLUMEN.setBounds(150,400,300,20);
sbarVOLUMEN.setBackground(Color.white);
add(sbarVOLUMEN);
sbarVOLUMEN.addAdjustmentListener(new HorcherVOLUMEN());
labTEMPERATUR = new Label("Temperatur = "+String.valueOf(T)+"K");
labTEMPERATUR.setBounds(330,40,115,25);
labTEMPERATUR.setBackground(Color.lightGray);
add(labTEMPERATUR);
sbarTEMPERATUR = new Scrollbar(Scrollbar.VERTICAL,T,0,1,501);
sbarTEMPERATUR.setBounds(450,10,20,200);
sbarTEMPERATUR.setBackground(Color.white);
add(sbarTEMPERATUR);
sbarTEMPERATUR.addAdjustmentListener(new HorcherTEMPERATUR());
labPUNKT = new Label("P("+String.valueOf(V)+") = ");
labPUNKT.setBounds(330,340,115,25);
labPUNKT.setBackground(Color.red);
add(labPUNKT);
}
public void paint(Graphics g)
{
// Zylinder
g.drawLine(Ex,Ey,Ex,Ey+By); //senkrehte
g.drawLine(Ex-1,Ey,Ex-1,Ey+By); // doppelte Line
g.drawLine(Ex-1,Ey-1,Ex+165,Ey-1); // waagrechte
g.drawLine(Ex-1,Ey-2,Ex+165,Ey-2); // doppelte Linie oben
g.drawLine(Ex-1,Ey+By,Ex+165,Ey+By); // waagrechte
g.drawLine(Ex-1,Ey+By+1,Ex+165,Ey+By+1); // doppelte Linie unten
// Kolben
g.setColor(Color.blue);
g.fillRect(Ex+V,Ey,Bx,By);
g.fillRect(Ex+Bx+V-1,ym,100,3);
// Zeichenfläche
g.setColor(Color.white);
g.fillRect(r,r,xmax-2*r,ymax-200);
g.setColor(Color.black);
g.drawRect(r,r,xmax-2*r,ymax-200);
g.clipRect(r,r,xmax-2*r,ymax-200);
// Koordinatenachsen
g.drawLine(x0,y0,xmax-20,y0);
g.drawLine(x0,y0,x0,2*r+35);
// Beschriftung
int i;
for (i=0; i<=12; i=i+1)
{
g.drawLine(x0+i*fakx,y0,x0+i*fakx,y0+3);
}
for (i=-1; i>=-7; i=i-1)
{
g.drawLine(x0,y0+i*faky,x0-3,y0+i*faky);
}
for (i=0; i<=12; i=i+1)
{
g.drawString(Integer.toString(i),x0+1*i*fakx,y0+15);
}
for (i=1; i<=7; i=i+1)
{
g.drawString(Integer.toString(i),x0-2*r,y0-i*faky);
}
g.drawString("V",xmax-30,y0-1);
g.drawString("[ltr]",xmax-34,y0+11);
g.drawString("P",x0-10,r+r+20);
g.drawString("[bar]",x0-19,r+r+32);
// Funktion zeichnen
double x11 = 0.1;
while (x11<=12)
{
x1 = (int) (x11*fakx + x0);
y1 = (int) (fvonX(x11)*faky+y0);
x2 = (int) ((x11+0.1)*fakx +x0);
y2 = (int) (fvonX(x11+0.1)*faky+ y0);
g.drawLine(x1,y1,x2,y2);
x11 = x11+0.1;
}
// Punkt zeichnen
double xwert=V;
double ywert=-0.044079*8.31*T/(V*0.001)/100000;
xPUNKT= (int) (x0+xwert*fakx);
yPUNKT= (int) (y0+ywert*faky);
g.setColor(Color.red);
g.fillOval(xPUNKT,yPUNKT,5,5);
}
public double fvonX(double V)
{
double ywert;
ywert =-0.044079*8.31*T/(V*0.001)/100000;
return ywert;
}
class HorcherVOLUMEN implements AdjustmentListener
{
public void adjustmentValueChanged(AdjustmentEvent e1)
{
V=e1.getValue();
labVOLUMEN.setText("Volumen = "+String.valueOf(V)+"ltr");
labPUNKT.setText("P("+String.valueOf(V)+") = ");
repaint();
zeichneneu();
}
}
class HorcherTEMPERATUR implements AdjustmentListener
{
public void adjustmentValueChanged(AdjustmentEvent e1)
{
T=e1.getValue();
labTEMPERATUR.setText("Temperatur = "+String.valueOf(T)+"K");
labPUNKT.setText("P("+String.valueOf(V)+") = ");
repaint();
}
}
public void zeichneneu()
{
Graphics g=getGraphics();
g.setColor(Color.blue);
g.fillRect(Ex,Ey,Bx,By);
//p.warten(14);
g.clearRect(Ex,Ey,Bx,By);
g.clearRect(Ex+Bx,ym-3,100,6);
g.setColor(Color.lightGray);
g.setColor(Color.blue);
//p.warten(10);
g.fillRect(Ex+V,Ey,Bx,By);
g.setColor(Color.red);
g.fillRect(Ex,Ey,V,By);
g.setColor(Color.blue);
g.fillRect(Ex+Bx,ym,100,3);
g.dispose();
}
}
|