Update of /cvsroot/osmose-dev/osmose/src/osmose/application/draw
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8792/src/osmose/application/draw
Modified Files:
OSMDrawingPanel.java
Log Message:
Drawing tools size synchronized with user choice.
Index: OSMDrawingPanel.java
===================================================================
RCS file: /cvsroot/osmose-dev/osmose/src/osmose/application/draw/OSMDrawingPanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** OSMDrawingPanel.java 30 Jan 2006 22:35:33 -0000 1.2
--- OSMDrawingPanel.java 31 Jan 2006 19:30:34 -0000 1.3
***************
*** 92,95 ****
--- 92,99 ----
if(m_Tools != null) {
g.setColor(m_Colors.getCurrentColor());
+ if (g instanceof Graphics2D) {
+ Graphics2D g2 = (Graphics2D)g;
+ g2.setStroke(new BasicStroke(new Integer(m_Tools.getPenSize()).floatValue()));
+ }
if(m_Tools.getCurrentTool() == OSMDrawingToolsPanel.OSMDRAW_RECT)
drawARect(g, m_X, m_Y, m_W, m_H);
***************
*** 122,125 ****
--- 126,133 ----
g.setColor(m_Colors.getCurrentColor());
m_ImgGraphic.setColor(m_Colors.getCurrentColor());
+ if (m_ImgGraphic instanceof Graphics2D) {
+ Graphics2D g2 = (Graphics2D)m_ImgGraphic;
+ g2.setStroke(new BasicStroke(new Integer(m_Tools.getPenSize()).floatValue()));
+ }
drawALine(g, m_X0, m_Y0, e.getX(), e.getY());
drawALine(m_ImgGraphic, m_X0, m_Y0, e.getX(), e.getY());
***************
*** 130,133 ****
--- 138,145 ----
if(m_Tools.getCurrentTool() == OSMDrawingToolsPanel.OSMDRAW_ERASE) {
m_ImgGraphic.setColor(Color.WHITE);
+ if (m_ImgGraphic instanceof Graphics2D) {
+ Graphics2D g2 = (Graphics2D)m_ImgGraphic;
+ g2.setStroke(new BasicStroke(new Integer(m_Tools.getPenSize()).floatValue()));
+ }
g.setColor(Color.WHITE);
int eraserSize = m_Tools.getPenSize();
***************
*** 149,152 ****
--- 161,168 ----
if(m_ImgGraphic != null) {
m_ImgGraphic.setColor(m_Colors.getCurrentColor());
+ if (m_ImgGraphic instanceof Graphics2D) {
+ Graphics2D g2 = (Graphics2D)m_ImgGraphic;
+ g2.setStroke(new BasicStroke(new Integer(m_Tools.getPenSize()).floatValue()));
+ }
if(m_Tools.getCurrentTool() == OSMDrawingToolsPanel.OSMDRAW_RECT)
drawARect(m_ImgGraphic, m_X, m_Y, m_W, m_H);
***************
*** 359,386 ****
{
g.drawOval(x, y, w, h);
- if(m_Tools.getPenSize() > 1)
- {
- g.drawOval(x + 1, y, w - 2, h);
- g.drawOval(x, y + 1, w, h - 2);
- if (m_Tools.getPenSize() > 2)
- {
- g.drawOval(x - 1, y, w + 2, h);
- g.drawOval(x, y - 1, w, h + 2);
- }
- }
-
- /* g.drawOval(x, y, w, h);
- if(m_Tools.getPenSize() > 1)
- {
- g.drawOval(x, y + 1, w, h - 2);
- g.drawOval(x + 1, y, w - 2, h);
- g.drawOval(x + 1, y+1, w - 2, h-2);
- if(m_Tools.getPenSize() > 2)
- {
- g.drawOval(x, y - 1, w, h + 2);
- g.drawOval(x - 1, y, w + 2, h);
- g.drawOval(x - 1, y-1, w + 2, h+2);
- }
- }*/
}
--- 375,378 ----
***************
*** 396,418 ****
private void drawALine(Graphics g, int x1, int y1, int x2, int y2) {
g.drawLine(x1, y1, x2, y2);
- float pente = 0;
- if(x1 != x2)
- pente = (float)Math.abs(y2 - y1) / Math.abs(x2 - x1);
- else
- pente = 1000;
- if(pente < 1) {
- if(m_Tools.getPenSize() > 1) {
- g.drawLine(x1, y1 - 1, x2, y2 - 1);
- if(m_Tools.getPenSize() > 2)
- g.drawLine(x1, y1 + 1, x2, y2 + 1);
- }
- }
- else {
- if(m_Tools.getPenSize() > 1) {
- g.drawLine(x1 - 1, y1, x2 - 1, y2);
- if(m_Tools.getPenSize() > 2)
- g.drawLine(x1 + 1, y1, x2 + 1, y2);
- }
- }
}
--- 388,391 ----
***************
*** 483,491 ****
private void drawARect(Graphics g, int x, int y, int w, int h) {
g.drawRect(x, y, w, h);
- if(m_Tools.getPenSize() > 1) {
- g.drawRect(x + 1, y + 1, w - 2, h - 2);
- if(m_Tools.getPenSize() > 2)
- g.drawRect(x - 1, y - 1, w + 2, h + 2);
- }
}
--- 456,459 ----
|