741 |
10 Oct 06 |
olle |
1 |
/* |
1652 |
22 May 07 |
gregory |
$Id$ |
741 |
10 Oct 06 |
olle |
3 |
|
1916 |
31 Aug 07 |
jari |
Copyright (C) 2006 Olle Mansson |
1916 |
31 Aug 07 |
jari |
Copyright (C) 2007 Gregory Vincic |
741 |
10 Oct 06 |
olle |
6 |
|
1652 |
22 May 07 |
gregory |
This file is part of Proteios. |
1652 |
22 May 07 |
gregory |
Available at http://www.proteios.org/ |
741 |
10 Oct 06 |
olle |
9 |
|
1652 |
22 May 07 |
gregory |
Proteios is free software; you can redistribute it and/or modify it |
1652 |
22 May 07 |
gregory |
under the terms of the GNU General Public License as published by |
1652 |
22 May 07 |
gregory |
the Free Software Foundation; either version 2 of the License, or |
1652 |
22 May 07 |
gregory |
(at your option) any later version. |
741 |
10 Oct 06 |
olle |
14 |
|
1652 |
22 May 07 |
gregory |
Proteios is distributed in the hope that it will be useful, but |
1652 |
22 May 07 |
gregory |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1652 |
22 May 07 |
gregory |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1652 |
22 May 07 |
gregory |
General Public License for more details. |
741 |
10 Oct 06 |
olle |
19 |
|
1652 |
22 May 07 |
gregory |
You should have received a copy of the GNU General Public License |
1652 |
22 May 07 |
gregory |
along with this program; if not, write to the Free Software |
1652 |
22 May 07 |
gregory |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
1652 |
22 May 07 |
gregory |
02111-1307, USA. |
1652 |
22 May 07 |
gregory |
24 |
*/ |
741 |
10 Oct 06 |
olle |
25 |
|
741 |
10 Oct 06 |
olle |
// Xerver Free Web Server |
741 |
10 Oct 06 |
olle |
// Copyright (C) 2002-2005 Omid Rouhani |
741 |
10 Oct 06 |
olle |
28 |
// |
741 |
10 Oct 06 |
olle |
29 |
// |
741 |
10 Oct 06 |
olle |
// This program is free software; you can redistribute it and/or |
741 |
10 Oct 06 |
olle |
// modify it under the terms of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// as published by the Free Software Foundation; either version 2 |
741 |
10 Oct 06 |
olle |
// of the License, or (at your option) any later version. |
741 |
10 Oct 06 |
olle |
34 |
// |
741 |
10 Oct 06 |
olle |
// This program is distributed in the hope that it will be useful, |
741 |
10 Oct 06 |
olle |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
741 |
10 Oct 06 |
olle |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
741 |
10 Oct 06 |
olle |
// GNU General Public License for more details. |
741 |
10 Oct 06 |
olle |
39 |
// |
741 |
10 Oct 06 |
olle |
// You should have received a copy of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// along with this program; if not, write to the Free Software |
741 |
10 Oct 06 |
olle |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
741 |
10 Oct 06 |
olle |
43 |
// |
741 |
10 Oct 06 |
olle |
44 |
// |
741 |
10 Oct 06 |
olle |
45 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
// ## YOU CAN CONTACT THE AUTHOR (OMID ROUHANI) AT: ## |
741 |
10 Oct 06 |
olle |
// ## HTTP://WWW.JAVASCRIPT.NU/XERVER/ ## |
741 |
10 Oct 06 |
olle |
48 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## IF YOUR SOFTWARE IS NOT RELEASED UNDER THE ## |
741 |
10 Oct 06 |
olle |
// ## GNU GENERAL PUBLIC LICENSE (GPL), ## |
741 |
10 Oct 06 |
olle |
// ## PLEASE DO NOT COPY ANYTHING FROM THIS SOURCE CODE!!! ## |
741 |
10 Oct 06 |
olle |
52 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## FOR FULL LICENSE, PLEASE READ "XERVER LICENSE". ## |
741 |
10 Oct 06 |
olle |
54 |
// ############################################################# |
1652 |
22 May 07 |
gregory |
55 |
package se.lu.thep.coreftpd.common; |
741 |
10 Oct 06 |
olle |
56 |
|
741 |
10 Oct 06 |
olle |
57 |
import java.awt.Color; |
741 |
10 Oct 06 |
olle |
58 |
import java.awt.Font; |
741 |
10 Oct 06 |
olle |
59 |
import java.awt.FontMetrics; |
741 |
10 Oct 06 |
olle |
60 |
import java.awt.Frame; |
741 |
10 Oct 06 |
olle |
61 |
import java.awt.Graphics; |
741 |
10 Oct 06 |
olle |
62 |
import java.awt.Image; |
741 |
10 Oct 06 |
olle |
63 |
import java.awt.Insets; |
741 |
10 Oct 06 |
olle |
64 |
import java.awt.Point; |
741 |
10 Oct 06 |
olle |
65 |
import java.awt.Polygon; |
741 |
10 Oct 06 |
olle |
66 |
import java.awt.event.MouseAdapter; |
741 |
10 Oct 06 |
olle |
67 |
import java.awt.event.MouseEvent; |
741 |
10 Oct 06 |
olle |
68 |
import java.awt.event.MouseListener; |
741 |
10 Oct 06 |
olle |
69 |
import java.awt.event.MouseMotionAdapter; |
741 |
10 Oct 06 |
olle |
70 |
import java.awt.event.MouseMotionListener; |
741 |
10 Oct 06 |
olle |
71 |
import java.awt.event.WindowAdapter; |
741 |
10 Oct 06 |
olle |
72 |
import java.awt.event.WindowEvent; |
741 |
10 Oct 06 |
olle |
73 |
|
741 |
10 Oct 06 |
olle |
74 |
/** |
1652 |
22 May 07 |
gregory |
75 |
* |
1652 |
22 May 07 |
gregory |
* <B>About this class:</B> <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>MyString</CODE> is a very useful class. <BR> |
741 |
10 Oct 06 |
olle |
* It's used to open a simple window allowing you to paint on it as you prefer. |
741 |
10 Oct 06 |
olle |
* <BR> |
741 |
10 Oct 06 |
olle |
* Several help members are included. |
1652 |
22 May 07 |
gregory |
81 |
* |
741 |
10 Oct 06 |
olle |
* @author <a href="http://www.JavaScript.nu/xerver/" TARGET="_top">Omid Rouhani</a> |
741 |
10 Oct 06 |
olle |
* @version 1.0 |
741 |
10 Oct 06 |
olle |
84 |
*/ |
741 |
10 Oct 06 |
olle |
85 |
|
1652 |
22 May 07 |
gregory |
86 |
@SuppressWarnings("serial") |
1652 |
22 May 07 |
gregory |
87 |
final public class MyWindow extends Frame { |
1652 |
22 May 07 |
gregory |
88 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ############################### VARIABLER |
1652 |
22 May 07 |
gregory |
90 |
// ################################# |
1652 |
22 May 07 |
gregory |
91 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
92 |
public boolean mouseButtonDown; // Is the mouse button down? |
741 |
10 Oct 06 |
olle |
93 |
|
1652 |
22 May 07 |
gregory |
94 |
public boolean killProgramAtShutdown = true; // Close window ==> Kill |
1652 |
22 May 07 |
gregory |
// whole program |
1652 |
22 May 07 |
gregory |
96 |
|
1652 |
22 May 07 |
gregory |
97 |
public boolean windowHasBeenShutDown = false; // Has the user closed this |
1652 |
22 May 07 |
gregory |
// window? |
1652 |
22 May 07 |
gregory |
99 |
|
1652 |
22 May 07 |
gregory |
100 |
public boolean automaticRepaint = true; // Call "repaint()" automatically |
1652 |
22 May 07 |
gregory |
// after each painting? |
1652 |
22 May 07 |
gregory |
102 |
|
741 |
10 Oct 06 |
olle |
103 |
public long timeWhenWindowWasCreated; |
1652 |
22 May 07 |
gregory |
104 |
|
1652 |
22 May 07 |
gregory |
105 |
public Point mousePosition = new Point(); // The mouse position (x,y) |
1652 |
22 May 07 |
gregory |
106 |
|
741 |
10 Oct 06 |
olle |
107 |
private Image paintArea; |
1652 |
22 May 07 |
gregory |
108 |
|
741 |
10 Oct 06 |
olle |
109 |
private int winWidth, winHeight; |
1652 |
22 May 07 |
gregory |
110 |
|
741 |
10 Oct 06 |
olle |
111 |
private FontMetrics myFontMetrics; |
1652 |
22 May 07 |
gregory |
112 |
|
1652 |
22 May 07 |
gregory |
113 |
private Color myColor = Color.red; |
1652 |
22 May 07 |
gregory |
114 |
|
1652 |
22 May 07 |
gregory |
115 |
private Font myFont = new Font("Times", Font.BOLD, 12); |
1652 |
22 May 07 |
gregory |
116 |
|
741 |
10 Oct 06 |
olle |
117 |
private Insets theInsets; |
1652 |
22 May 07 |
gregory |
118 |
|
741 |
10 Oct 06 |
olle |
119 |
private Graphics graphicsArea; |
741 |
10 Oct 06 |
olle |
120 |
|
1652 |
22 May 07 |
gregory |
121 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ################################## MAIN |
1652 |
22 May 07 |
gregory |
123 |
// ################################### |
1652 |
22 May 07 |
gregory |
124 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
125 |
public static void main(String[] s) { |
1652 |
22 May 07 |
gregory |
126 |
MyWindow MW = new MyWindow(400, 300, "Untitled Window"); |
741 |
10 Oct 06 |
olle |
127 |
} |
741 |
10 Oct 06 |
olle |
128 |
|
1652 |
22 May 07 |
gregory |
129 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ############################## KONSTRUERARE |
1652 |
22 May 07 |
gregory |
131 |
// ############################### |
1652 |
22 May 07 |
gregory |
132 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
133 |
public MyWindow() { |
1652 |
22 May 07 |
gregory |
134 |
new MyWindow(400, 300, "Untitled Window"); |
741 |
10 Oct 06 |
olle |
135 |
} |
741 |
10 Oct 06 |
olle |
136 |
|
1652 |
22 May 07 |
gregory |
137 |
public MyWindow(int width, int height, String rubrik) { |
1652 |
22 May 07 |
gregory |
138 |
timeWhenWindowWasCreated = System.currentTimeMillis(); |
741 |
10 Oct 06 |
olle |
139 |
setVisible(true); |
741 |
10 Oct 06 |
olle |
140 |
|
1652 |
22 May 07 |
gregory |
// super.setFont(myFont); |
741 |
10 Oct 06 |
olle |
142 |
paintArea = createImage(width, height); |
1652 |
22 May 07 |
gregory |
143 |
graphicsArea = paintArea.getGraphics(); // run "setVisible(true);" |
1652 |
22 May 07 |
gregory |
// before this line |
741 |
10 Oct 06 |
olle |
145 |
graphicsArea.setFont(myFont); |
741 |
10 Oct 06 |
olle |
146 |
graphicsArea.setColor(myColor); |
741 |
10 Oct 06 |
olle |
147 |
winWidth = width; |
741 |
10 Oct 06 |
olle |
148 |
winHeight = height; |
741 |
10 Oct 06 |
olle |
149 |
myFontMetrics = graphicsArea.getFontMetrics(); |
741 |
10 Oct 06 |
olle |
150 |
addMouseListener(MyMouseListener); |
741 |
10 Oct 06 |
olle |
151 |
addMouseMotionListener(MyMouseMotionListener); |
741 |
10 Oct 06 |
olle |
152 |
addWindowListener(MyWindowListener); |
741 |
10 Oct 06 |
olle |
153 |
setTitle(rubrik); |
741 |
10 Oct 06 |
olle |
154 |
theInsets = getInsets(); |
1652 |
22 May 07 |
gregory |
155 |
super.setSize(width + theInsets.left + theInsets.right, height |
1652 |
22 May 07 |
gregory |
156 |
+ theInsets.top + theInsets.bottom); |
741 |
10 Oct 06 |
olle |
157 |
setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
158 |
repaint(); |
741 |
10 Oct 06 |
olle |
159 |
} |
741 |
10 Oct 06 |
olle |
160 |
|
1652 |
22 May 07 |
gregory |
161 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ###################### PUBLICA DIVERSE FUNKTIONER |
1652 |
22 May 07 |
gregory |
163 |
// ######################### |
1652 |
22 May 07 |
gregory |
164 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
165 |
public void pauseWindow(int milliSek) // Pause this window in "milliSek" |
1652 |
22 May 07 |
gregory |
// milliseconds |
741 |
10 Oct 06 |
olle |
167 |
{ |
1652 |
22 May 07 |
gregory |
168 |
long tidVidStart = System.currentTimeMillis(); |
1652 |
22 May 07 |
gregory |
169 |
while (tidVidStart + milliSek > System.currentTimeMillis()) |
1652 |
22 May 07 |
gregory |
170 |
; |
741 |
10 Oct 06 |
olle |
171 |
} |
741 |
10 Oct 06 |
olle |
172 |
|
1652 |
22 May 07 |
gregory |
173 |
public static long getWindowLifeTime(MyWindow theWindow) // Number of |
1652 |
22 May 07 |
gregory |
// millis since |
1652 |
22 May 07 |
gregory |
// window was |
1652 |
22 May 07 |
gregory |
// created |
741 |
10 Oct 06 |
olle |
177 |
{ |
1652 |
22 May 07 |
gregory |
178 |
return (System.currentTimeMillis() - theWindow.timeWhenWindowWasCreated); |
741 |
10 Oct 06 |
olle |
179 |
} |
741 |
10 Oct 06 |
olle |
180 |
|
1652 |
22 May 07 |
gregory |
181 |
public void setColor(Color newColor) { |
741 |
10 Oct 06 |
olle |
182 |
if (graphicsArea != null) |
741 |
10 Oct 06 |
olle |
183 |
graphicsArea.setColor(newColor); |
741 |
10 Oct 06 |
olle |
184 |
myColor = newColor; |
741 |
10 Oct 06 |
olle |
185 |
} |
741 |
10 Oct 06 |
olle |
186 |
|
2386 |
14 Nov 07 |
gregory |
187 |
@Override |
1652 |
22 May 07 |
gregory |
188 |
public void setFont(Font newFont) { |
741 |
10 Oct 06 |
olle |
189 |
if (graphicsArea != null) |
741 |
10 Oct 06 |
olle |
190 |
graphicsArea.setFont(newFont); |
741 |
10 Oct 06 |
olle |
191 |
} |
741 |
10 Oct 06 |
olle |
192 |
|
2386 |
14 Nov 07 |
gregory |
193 |
@Override |
1652 |
22 May 07 |
gregory |
194 |
public void setBackground(Color newBackgroundColor) { |
741 |
10 Oct 06 |
olle |
195 |
super.setBackground(newBackgroundColor); |
1652 |
22 May 07 |
gregory |
196 |
if (graphicsArea != null) { |
741 |
10 Oct 06 |
olle |
197 |
graphicsArea.setColor(newBackgroundColor); |
1652 |
22 May 07 |
gregory |
198 |
graphicsArea.fillRect(0, 0, winWidth, winHeight); |
741 |
10 Oct 06 |
olle |
199 |
graphicsArea.setColor(myColor); |
741 |
10 Oct 06 |
olle |
200 |
} |
1652 |
22 May 07 |
gregory |
201 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
202 |
repaint(); |
741 |
10 Oct 06 |
olle |
203 |
} |
741 |
10 Oct 06 |
olle |
204 |
|
1652 |
22 May 07 |
gregory |
205 |
public boolean buttonDown() { |
741 |
10 Oct 06 |
olle |
206 |
return mouseButtonDown; |
741 |
10 Oct 06 |
olle |
207 |
} |
741 |
10 Oct 06 |
olle |
208 |
|
1652 |
22 May 07 |
gregory |
209 |
public Point getMouse() { |
741 |
10 Oct 06 |
olle |
210 |
return mousePosition; |
741 |
10 Oct 06 |
olle |
211 |
} |
741 |
10 Oct 06 |
olle |
212 |
|
2386 |
14 Nov 07 |
gregory |
213 |
@Override |
1652 |
22 May 07 |
gregory |
214 |
public String toString() { |
741 |
10 Oct 06 |
olle |
215 |
return getTitle(); |
741 |
10 Oct 06 |
olle |
216 |
} |
741 |
10 Oct 06 |
olle |
217 |
|
1652 |
22 May 07 |
gregory |
218 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ########################## PUBLIC DRAW MEMTHODS |
1652 |
22 May 07 |
gregory |
220 |
// ########################### |
1652 |
22 May 07 |
gregory |
221 |
// ########################################################################### |
741 |
10 Oct 06 |
olle |
222 |
|
1652 |
22 May 07 |
gregory |
223 |
public void clearRect(int x, int y, int width, int height) { |
1652 |
22 May 07 |
gregory |
224 |
graphicsArea.clearRect(x, y, width, height); |
1652 |
22 May 07 |
gregory |
225 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
226 |
repaint(); |
741 |
10 Oct 06 |
olle |
227 |
} |
1652 |
22 May 07 |
gregory |
228 |
|
1652 |
22 May 07 |
gregory |
229 |
public void draw3DRect(int x, int y, int width, int height, boolean raised) { |
1652 |
22 May 07 |
gregory |
230 |
graphicsArea.draw3DRect(x, y, width, height, raised); |
1652 |
22 May 07 |
gregory |
231 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
232 |
repaint(); |
741 |
10 Oct 06 |
olle |
233 |
} |
1652 |
22 May 07 |
gregory |
234 |
|
1652 |
22 May 07 |
gregory |
235 |
public void drawArc(int x, int y, int width, int height, int startAngle, |
1652 |
22 May 07 |
gregory |
236 |
int arcAngle) { |
1652 |
22 May 07 |
gregory |
237 |
graphicsArea.drawArc(x, y, width, height, startAngle, arcAngle); |
1652 |
22 May 07 |
gregory |
238 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
239 |
repaint(); |
741 |
10 Oct 06 |
olle |
240 |
} |
1652 |
22 May 07 |
gregory |
241 |
|
1652 |
22 May 07 |
gregory |
242 |
public void drawLine(int x0, int y0, int x1, int y1) { |
1652 |
22 May 07 |
gregory |
243 |
graphicsArea.drawLine(x0, y0, x1, y1); |
1652 |
22 May 07 |
gregory |
244 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
245 |
repaint(); |
741 |
10 Oct 06 |
olle |
246 |
} |
1652 |
22 May 07 |
gregory |
247 |
|
1652 |
22 May 07 |
gregory |
248 |
public void drawOval(int x, int y, int width, int height) { |
1652 |
22 May 07 |
gregory |
249 |
graphicsArea.drawOval(x, y, width, height); |
1652 |
22 May 07 |
gregory |
250 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
251 |
repaint(); |
741 |
10 Oct 06 |
olle |
252 |
} |
1652 |
22 May 07 |
gregory |
253 |
|
1652 |
22 May 07 |
gregory |
254 |
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { |
1652 |
22 May 07 |
gregory |
255 |
graphicsArea.drawPolygon(xPoints, yPoints, nPoints); |
1652 |
22 May 07 |
gregory |
256 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
257 |
repaint(); |
741 |
10 Oct 06 |
olle |
258 |
} |
1652 |
22 May 07 |
gregory |
259 |
|
1652 |
22 May 07 |
gregory |
260 |
public void drawPolygon(Polygon p) { |
741 |
10 Oct 06 |
olle |
261 |
graphicsArea.drawPolygon(p); |
1652 |
22 May 07 |
gregory |
262 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
263 |
repaint(); |
741 |
10 Oct 06 |
olle |
264 |
} |
1652 |
22 May 07 |
gregory |
265 |
|
1652 |
22 May 07 |
gregory |
266 |
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { |
1652 |
22 May 07 |
gregory |
267 |
graphicsArea.drawPolyline(xPoints, yPoints, nPoints); |
1652 |
22 May 07 |
gregory |
268 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
269 |
repaint(); |
741 |
10 Oct 06 |
olle |
270 |
} |
1652 |
22 May 07 |
gregory |
271 |
|
1652 |
22 May 07 |
gregory |
272 |
public void drawRect(int x, int y, int width, int height) { |
741 |
10 Oct 06 |
olle |
273 |
graphicsArea.drawRect(x, y, width, height); |
1652 |
22 May 07 |
gregory |
274 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
275 |
repaint(); |
741 |
10 Oct 06 |
olle |
276 |
} |
1652 |
22 May 07 |
gregory |
277 |
|
1652 |
22 May 07 |
gregory |
278 |
public void drawRoundRect(int x, int y, int width, int height, |
1652 |
22 May 07 |
gregory |
279 |
int arcWidth, int arcHeight) { |
741 |
10 Oct 06 |
olle |
280 |
graphicsArea.drawRoundRect(x, y, width, height, arcWidth, arcHeight); |
1652 |
22 May 07 |
gregory |
281 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
282 |
repaint(); |
741 |
10 Oct 06 |
olle |
283 |
} |
1652 |
22 May 07 |
gregory |
284 |
|
1652 |
22 May 07 |
gregory |
285 |
public void drawString(String str, int x, int y) { |
741 |
10 Oct 06 |
olle |
286 |
graphicsArea.drawString(str, x, y); |
1652 |
22 May 07 |
gregory |
287 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
288 |
repaint(); |
741 |
10 Oct 06 |
olle |
289 |
} |
1652 |
22 May 07 |
gregory |
290 |
|
1652 |
22 May 07 |
gregory |
291 |
public void fill3DRect(int x, int y, int width, int height, boolean raised) { |
1652 |
22 May 07 |
gregory |
292 |
graphicsArea.fill3DRect(x, y, width, height, raised); |
1652 |
22 May 07 |
gregory |
293 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
294 |
repaint(); |
741 |
10 Oct 06 |
olle |
295 |
} |
1652 |
22 May 07 |
gregory |
296 |
|
1652 |
22 May 07 |
gregory |
297 |
public void fillArc(int x, int y, int width, int height, int startAngle, |
1652 |
22 May 07 |
gregory |
298 |
int arcAngle) { |
1652 |
22 May 07 |
gregory |
299 |
graphicsArea.fillArc(x, y, width, height, startAngle, arcAngle); |
1652 |
22 May 07 |
gregory |
300 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
301 |
repaint(); |
741 |
10 Oct 06 |
olle |
302 |
} |
1652 |
22 May 07 |
gregory |
303 |
|
1652 |
22 May 07 |
gregory |
304 |
public void fillOval(int x, int y, int width, int height) { |
741 |
10 Oct 06 |
olle |
305 |
graphicsArea.fillOval(x, y, width, height); |
1652 |
22 May 07 |
gregory |
306 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
307 |
repaint(); |
741 |
10 Oct 06 |
olle |
308 |
} |
1652 |
22 May 07 |
gregory |
309 |
|
1652 |
22 May 07 |
gregory |
310 |
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { |
741 |
10 Oct 06 |
olle |
311 |
graphicsArea.fillPolygon(xPoints, yPoints, nPoints); |
1652 |
22 May 07 |
gregory |
312 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
313 |
repaint(); |
741 |
10 Oct 06 |
olle |
314 |
} |
1652 |
22 May 07 |
gregory |
315 |
|
1652 |
22 May 07 |
gregory |
316 |
public void fillPolygon(Polygon p) { |
741 |
10 Oct 06 |
olle |
317 |
graphicsArea.fillPolygon(p); |
1652 |
22 May 07 |
gregory |
318 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
319 |
repaint(); |
741 |
10 Oct 06 |
olle |
320 |
} |
1652 |
22 May 07 |
gregory |
321 |
|
1652 |
22 May 07 |
gregory |
322 |
public void fillRect(int x, int y, int width, int height) { |
741 |
10 Oct 06 |
olle |
323 |
graphicsArea.fillRect(x, y, width, height); |
1652 |
22 May 07 |
gregory |
324 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
325 |
repaint(); |
741 |
10 Oct 06 |
olle |
326 |
} |
1652 |
22 May 07 |
gregory |
327 |
|
1652 |
22 May 07 |
gregory |
328 |
public void fillRoundRect(int x, int y, int width, int height, |
1652 |
22 May 07 |
gregory |
329 |
int arcWidth, int arcHeight) { |
741 |
10 Oct 06 |
olle |
330 |
graphicsArea.fillRoundRect(x, y, width, height, arcWidth, arcHeight); |
1652 |
22 May 07 |
gregory |
331 |
if (automaticRepaint) |
1652 |
22 May 07 |
gregory |
332 |
repaint(); |
741 |
10 Oct 06 |
olle |
333 |
} |
741 |
10 Oct 06 |
olle |
334 |
|
1652 |
22 May 07 |
gregory |
335 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ########################## "SYSTEM FUNCTIONS" |
1652 |
22 May 07 |
gregory |
337 |
// ############################# |
1652 |
22 May 07 |
gregory |
338 |
// ########################################################################### |
2386 |
14 Nov 07 |
gregory |
339 |
@Override |
1652 |
22 May 07 |
gregory |
340 |
public void paint(Graphics g) { |
1652 |
22 May 07 |
gregory |
341 |
if (paintArea != null) // Without these error might occur |
1652 |
22 May 07 |
gregory |
342 |
if (theInsets != null) |
1652 |
22 May 07 |
gregory |
343 |
g.drawImage(paintArea, theInsets.left, theInsets.top, this); |
741 |
10 Oct 06 |
olle |
344 |
} |
741 |
10 Oct 06 |
olle |
345 |
|
1652 |
22 May 07 |
gregory |
346 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
// ################################ EVENTS |
1652 |
22 May 07 |
gregory |
348 |
// //################################# |
1652 |
22 May 07 |
gregory |
349 |
// ########################################################################### |
1652 |
22 May 07 |
gregory |
350 |
private WindowAdapter MyWindowListener = new WindowAdapter() { |
2386 |
14 Nov 07 |
gregory |
351 |
@Override |
1652 |
22 May 07 |
gregory |
352 |
public void windowClosing(WindowEvent e) // Window is closed |
741 |
10 Oct 06 |
olle |
353 |
{ |
1652 |
22 May 07 |
gregory |
354 |
windowHasBeenShutDown = true; |
741 |
10 Oct 06 |
olle |
355 |
dispose(); |
741 |
10 Oct 06 |
olle |
356 |
if (killProgramAtShutdown) |
741 |
10 Oct 06 |
olle |
357 |
System.exit(0); |
741 |
10 Oct 06 |
olle |
358 |
} |
741 |
10 Oct 06 |
olle |
359 |
}; |
741 |
10 Oct 06 |
olle |
360 |
|
1652 |
22 May 07 |
gregory |
361 |
private MouseListener MyMouseListener = new MouseAdapter() { |
2386 |
14 Nov 07 |
gregory |
362 |
@Override |
1652 |
22 May 07 |
gregory |
363 |
public void mousePressed(MouseEvent e) // Mouse is pressed down |
741 |
10 Oct 06 |
olle |
364 |
{ |
741 |
10 Oct 06 |
olle |
365 |
mouseButtonDown = true; |
1652 |
22 May 07 |
gregory |
366 |
mousePosition = e.getPoint(); |
1652 |
22 May 07 |
gregory |
367 |
mousePosition.y -= theInsets.top; // Removes the size of the blue |
1652 |
22 May 07 |
gregory |
// list in windows (test with |
1652 |
22 May 07 |
gregory |
// winXP gave: 21) |
1652 |
22 May 07 |
gregory |
370 |
mousePosition.x -= theInsets.left; // Removes the size of the |
1652 |
22 May 07 |
gregory |
// window border (test with |
1652 |
22 May 07 |
gregory |
// winXP gave: 4) |
741 |
10 Oct 06 |
olle |
373 |
} |
1652 |
22 May 07 |
gregory |
374 |
|
2386 |
14 Nov 07 |
gregory |
375 |
@Override |
1652 |
22 May 07 |
gregory |
376 |
public void mouseReleased(MouseEvent e) // Mouse button is going up |
741 |
10 Oct 06 |
olle |
377 |
{ |
741 |
10 Oct 06 |
olle |
378 |
mouseButtonDown = false; |
741 |
10 Oct 06 |
olle |
379 |
} |
741 |
10 Oct 06 |
olle |
380 |
}; |
741 |
10 Oct 06 |
olle |
381 |
|
1652 |
22 May 07 |
gregory |
382 |
private MouseMotionListener MyMouseMotionListener = new MouseMotionAdapter() { |
2386 |
14 Nov 07 |
gregory |
383 |
@Override |
1652 |
22 May 07 |
gregory |
384 |
public void mouseDragged(MouseEvent e) // Mouse is keept down and is |
1652 |
22 May 07 |
gregory |
// draged |
741 |
10 Oct 06 |
olle |
386 |
{ |
1652 |
22 May 07 |
gregory |
387 |
mousePosition = e.getPoint(); |
1652 |
22 May 07 |
gregory |
388 |
mousePosition.y -= theInsets.top; // Removes the size of the blue |
1652 |
22 May 07 |
gregory |
// list in windows (test with |
1652 |
22 May 07 |
gregory |
// winXP gave: 21) |
1652 |
22 May 07 |
gregory |
391 |
mousePosition.x -= theInsets.left; // Removes the size of the |
1652 |
22 May 07 |
gregory |
// window border (test with |
1652 |
22 May 07 |
gregory |
// winXP gave: 4) |
741 |
10 Oct 06 |
olle |
394 |
} |
741 |
10 Oct 06 |
olle |
395 |
}; |
741 |
10 Oct 06 |
olle |
396 |
} |