This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.~ava
251 lines (233 loc) · 7.83 KB
/
main.~ava
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
/**
*
* Beschreibung
*
* @version 1.0 vom 05.04.2013
* @author
*/
public class main extends Frame implements MouseListener{
// Anfang Attribute
public BufferedImage bild;
int MausX, MausY, MausNeuX, MausNeuY;
int hoehe, breite;
private int TAB_BREITE=200;
private int TAB_HOEHE=20;
private Jahr[] Jahre=new Jahr[1];
private int pointerj=0;
private int pointerm=0;
private boolean wait;
// Ende Attribute
public main(String title) {
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { dispose(); }
});
addMouseListener (this);
int frameWidth = 1000;
int frameHeight = 800;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
setResizable(false);
setLayout(null);
breite = getSize().width;
hoehe = getSize().height;
//leeres Pufferbild definieren
bild = new BufferedImage(d.width,d.height,BufferedImage.TYPE_INT_RGB);
MausX = 0;
MausY = 0;
Jahre[0]= new Jahr(false);
// Anfang Komponenten
// Ende Komponenten
setVisible(true);
} // end of public main
public void paint(Graphics g){
while (wait) {
} // end of while
//Puffergrafik laden
Graphics h = bild.getGraphics();
//Hintergrund leeren
h.setColor(Color.white);
h.fillRect(0,0,this.getWidth()-1,this.getHeight()-1);
try{
//externe Grafiken laden
Image img1 = ImageIO.read(new File("C:\\Users\\Benedikt\\Documents\\GitHub\\Term\\Term\\backx.jpg"));
Image img2 = ImageIO.read(new File("C:\\Users\\Benedikt\\Documents\\GitHub\\Term\\Term\\next.png"));
Image img3 = ImageIO.read(new File("C:\\Users\\Benedikt\\Documents\\GitHub\\Term\\Term\\plus.png"));
Image img4 = ImageIO.read(new File("C:\\Users\\Benedikt\\Documents\\GitHub\\Term\\Term\\previous.png"));
//System.out.println(img1.toString());
//System.out.println(img2.toString());
//System.out.println(img3.toString());
//System.out.println(img4.toString());
//Grafik zeichnen
h.setColor(Color.BLACK);
h.drawImage(img1,0,10,this.getWidth()-1,this.getHeight()-1,this);
h.drawImage(img2,250,750,20,20,this);
h.drawRect(248,748,24,24);
h.drawImage(img3,200,750,20,20,this);
h.drawRect(198,748,24,24);
h.drawImage(img4,150,750,20,20,this);
h.drawRect(148,748,24,24);
h.setFont(new Font("Calibri",10,50));
h.drawString((pointerj+2015)+"",450,65);
h.setFont(new Font("Calibri",10,20));
if (pointerm>11) {
h.drawString(Jahre[pointerj+1].Monate[pointerm%12].getName(),185,80);
}else{
h.drawString(Jahre[pointerj].Monate[pointerm].getName(),185,80);
} // end of if
if (pointerm+1>11) {
h.drawString(Jahre[pointerj+1].Monate[(pointerm+1)%12].getName(),385,80);
}else{
h.drawString(Jahre[pointerj].Monate[pointerm+1].getName(),385,80);
}// end of if
if (pointerm+2>11) {
h.drawString(Jahre[pointerj+1].Monate[(pointerm+2)%12].getName(),585,80);
}else{
h.drawString(Jahre[pointerj].Monate[pointerm+2].getName(),585,80);
} // end of if
if (pointerm+3>11) {
// System.out.println(Jahre[pointerj+1].toString());
h.drawString(Jahre[pointerj+1].Monate[(pointerm+3)%12].getName(),785,80);
}else{
h.drawString(Jahre[pointerj].Monate[pointerm+3].getName(),785,80);
} // end of if
}catch (IOException ex){
//Ladefehler abfangen
System.out.println(ex);
}
//Tabelle zeichnen
drawTable(100,100,31,4,h);
//Puffergrafik auf Fenster übertragen
g.drawImage(bild,0,0,null);
pause (30);
//neu laden
repaint();
}
public void update (Graphics g){
paint(g);
}
public void pause (int ms){
try {
Thread.sleep(ms);
} catch(InterruptedException e) {}
}
public void drawTable(int x,int y,int countx,int county,Graphics f){
//Für alle Zeilen
for (int i=0;i<county;i++) {
//Für alle Spalten
for (int j=0;j<countx;j++) {
//weißes Kästchen mit schwarzem Rahmen
f.setColor(Color.WHITE);
f.fillRect(x+(i*TAB_BREITE),y+(j*TAB_HOEHE),TAB_BREITE,TAB_HOEHE);
f.setColor(Color.BLACK);
f.drawRect(x+(i*TAB_BREITE),y+(j*TAB_HOEHE),TAB_BREITE,TAB_HOEHE);
} // end of for
} // end of for
}
// Anfang Methoden
public void mouseClicked(MouseEvent me){
int posx = me.getX();
int posy = me.getY();
//Maus geklickt
//System.out.println(posx+" x, "+posy+" y.");
if (posx>248&&posx<272&&posy>748&&posy<772) {
//auf den next Button geklickt
//System.out.println("next");
//paint warten lassen
wait=true;
try{
//übetreten der Jahresgrenze überprüfen
//System.out.println(""+pointerm);
if ((((pointerm+3)-((pointerm+3)%12))/12)+1+pointerj>Jahre.length-1) {
//System.out.println("1");
//Jahre um ein weiteres Jahr verlängern
Jahr[] pivot;
pivot=Jahre;
Jahre=new Jahr[Jahre.length+1];
for (int i=0;i<pivot.length;i++) {
Jahre[i]=pivot[i];
} // end of for
//überprüfen ob neues Jahr ein Schaltjahr ist
if (Jahre.length+2014%400==0){
Jahre[Jahre.length+2014]=new Jahr(true);
}else if (Jahre.length+2014%100==0){
Jahre[Jahre.length-1]=new Jahr(false);
}else if (Jahre.length+2014%4==0){
Jahre[Jahre.length-1]=new Jahr(true);
}else{
Jahre[Jahre.length-1]=new Jahr(false);
}// end of if
//nächten Monat anzeigen
pointerm++;
}else{
//nächsten Monat anzeigen
pointerm++;
} // end of if
}catch (ArithmeticException aex){
//falls pointerm = 0 also division durch null
pointerm++;
}
if (pointerm>11) {
pointerj++;
pointerm=0;
} // end of if
//Grafik freigeben
wait=false;
}else if(posx>198&&posx<222&&posy>748&&posy<772){
//auf den plus Button geklickt
System.out.println("plus");
}else if(posx>148&&posx<172&&posy>748&&posy<772){
//auf den previous Button geklickt
//System.out.println("previous");
//überprüfen ob array vorne verlassen wird
if (pointerm==0&&pointerj==0) {
//Fehler-Fenster anzeigen
JOptionPane.showMessageDialog(null,"Du kannst vergangene Termine nicht mehr ansehen","Fehler",JOptionPane.INFORMATION_MESSAGE);
}else{
if (pointerm==0) {
pointerj--;
pointerm=11;
}else
//um einen Monat nach vorne springen
pointerm--;
} // end of if
}else if(me.getClickCount()>1){
//Doppelklick
} // end of if
}
public void mouseEntered(MouseEvent me)
{ }
public void mouseExited(MouseEvent me)
{ }
public void mousePressed(MouseEvent me){
}
public void mouseReleased(MouseEvent me)
{
}
public void getData(){
fenster Fenster=new fenster(this,"Termin eintragen",true);
int Time=fenster.getTime();
Boolean Private=fenster.getPrivate();
String Title=fenster.getTitle();
String Description=fenster.getDesc();
String Place=fenster.getPlace();
Termin term=new Termin(Time,Private,Title,Description,Place);
Jahre[fenster.getYear()-2015].addTermin(term,fenster.getMonth(),fenster.getDay());
}
// Ende Methoden
public static void main(String[] args) {
new main("main");
} // end of main
// end of class ballbuffer
}