import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
+import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
* possible de fermer la fenĂȘtre via le gestionnaire de fenĂȘtres.
*
* @author Arnaud Giersch <arnaud.giersch@univ-fcomte.fr>
- * @version 20141021
+ * @version 20141104
*/
public class DrawingWindow {
* @see #setColor
*/
public void drawPoint(int x, int y) {
+ if (x < 0 || y < 0 || x >= width || y >= height)
+ return;
synchronized (image) {
image.setRGB(x, y, graphics.getColor().getRGB());
}
synchronized (image) {
graphics.drawPolygon(poly);
}
- panel.repaint(poly.getBounds());
+ Rectangle bounds = poly.getBounds();
+ bounds.setSize(bounds.width + 1, bounds.height + 1);
+ panel.repaint(bounds);
}
/**
graphics.drawPolygon(poly);
graphics.fillPolygon(poly);
}
+ Rectangle bounds = poly.getBounds();
+ bounds.setSize(bounds.width + 1, bounds.height + 1);
panel.repaint(poly.getBounds());
}
* @see #setBgColor(int)
*/
public int getPointColor(int x, int y) {
- return image.getRGB(x, y);
+ return (x < 0 || y < 0 || x >= width || y >= height) ?
+ 0 : image.getRGB(x, y) & 0x00ffffff;
}
/**
m.put("lightgray", new Color(0x00d3d3d3));
m.put("lightgreen", new Color(0x0090ee90));
m.put("lightgrey", new Color(0x00d3d3d3));
- m.put("", new Color(0000000000));
m.put("lightpink", new Color(0x00ffb6c1));
m.put("lightsalmon", new Color(0x00ffa07a));
m.put("lightseagreen", new Color(0x0020b2aa));