📄 scribbletool.java
字号:
/*
* ScribbleTool.java - part of MutliTalk
*
* Created on 29 aprile 2006, 18.29
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Thanks to Arash Partow that is so generous to make his code so simple in his Scribble Application:
* http://www.partow.net/projects/jpaintbrush/index.html
*/
package _main.windowElement.drawTools;
import _main.ClientTCP;
import _main.windowElement.DrawPanel;
import java.awt.event.MouseEvent;
/**
*
* @author paolomind
*/
public abstract class ScribbleTool extends AbstractTool {
private int mousex;
private int mousey;
private int prevx;
private int prevy;
private int Orx;
private int Ory;
protected int drawY;
protected int drawX;
protected int OrHeight;
protected int OrWidth;
/** Creates a new instance of ScribbleTool */
protected ScribbleTool(DrawPanel p) {
super(p);
}
protected ScribbleTool(ClientTCP c, DrawPanel p) {
super(c,p);
}
protected void setGraphicalDefaults(MouseEvent e) {
mousex = e.getX();
mousey = e.getY();
prevx = e.getX();
prevy = e.getY();
Orx = e.getX();
Ory = e.getY();
drawX = e.getX();
drawY = e.getY();
OrWidth = 0;
OrHeight = 0;
}
protected void updateXY(MouseEvent e) {
mousex = e.getX();
mousey = e.getY();
}
protected void setActualBoundry() {
/*
If the any of the current mouse coordinates
are smaller than the origin coordinates, meaning
if drag occured in a negative manner, where either
the x-shift occured from right and/or y-shift occured
from bottom to top.
*/
if (mousex < Orx || mousey < Ory) {
/*
if the current mouse x coordinate is smaller
than the origin x coordinate,
equate the drawX to be the difference between
the current width and the origin x coordinate.
*/
if (mousex < Orx) {
OrWidth = Orx - mousex;
drawX = Orx - OrWidth;
}
else {
drawX = Orx;
OrWidth = mousex - Orx;
}
/*
if the current mouse y coordinate is smaller
than the origin y coordinate,
equate the drawY to be the difference between
the current height and the origin y coordinate.
*/
if (mousey < Ory) {
OrHeight = Ory - mousey;
drawY = Ory - OrHeight;
}
else {
drawY = Ory;
OrHeight = mousey - Ory;
}
}
/*
Else if drag was done in a positive manner meaning
x-shift occured from left to right and or y-shift occured
from top to bottom
*/
else {
drawX = Orx;
drawY = Ory;
OrWidth = mousex - Orx;
OrHeight = mousey - Ory;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -