📄 boxtool.java
字号:
/*
* BoxTool.java - part of __PROJECT__
*
* Created on 29 aprile 2006, 13.51
*
* 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.
*/
package _main.windowElement.drawTools;
import _main.ClientTCP;
import _main.instancePacket.onlyClient.RectanglePacket;
import _main.windowElement.DrawPanel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.swing.Icon;
import streamlib.PacketObject;
import utilitylib.CanvasJPanel;
/**
*
* @author paolomind
*/
public class BoxTool extends ScribbleTool {
protected final BoxPacket packet = new BoxPacket();
//public final Icon icon = new javax.swing.ImageIcon(getClass().getResource("/_main/icons/pencil.gif"));
class BoxPacket extends RectanglePacket {
public void readMe(InputStream in) throws IOException {
synchronized(this) {
super.readMe(in);
synchronized(panel) {
Graphics Bpaint = panel.getBufferedGraphics();
Bpaint.setColor(new Color(RGB));
Bpaint.fillRect(x,y,x2,y2);
panel.repaint();
}
}
}
public void writeMe(OutputStream out) throws IOException {
super.writeMe(out);
}
public void setCoordinates(int x1,int y1,int w,int h) {
from=core.getUsername();
RGB=parent.getColor().getRGB();
strokeWidth=0;
x=x1;
y=y1;
this.x2=w;
this.y2=h;
}
}
/** Creates a new instance of BoxTool */
public BoxTool(DrawPanel p) {
super(p);
}
public BoxTool(ClientTCP m, DrawPanel p) {
super(m,p);
}
public PacketObject getToolPacket() {
return packet;
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
setGraphicalDefaults(e);
}
public void mouseReleased(MouseEvent e) {
updateXY(e);
setActualBoundry();
synchronized(panel) {
Graphics Bpaint = panel.getBufferedGraphics();
Bpaint.setColor(parent.getColor());
Bpaint.fillRect(drawX,drawY,OrWidth-1,OrHeight-1);
panel.repaint();
}
if (core.isChannelActive()) {
try {
synchronized (packet) {
packet.setCoordinates(drawX,drawY,OrWidth-1,OrHeight-1);
core.sendPacket(packet);
}
} catch (IOException ex) {}
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseDragged(MouseEvent e) {
synchronized(panel) {
Graphics g = panel.getGraphics();
g.setColor(parent.getColor());
g.setXORMode(new Color(~parent.getColor().getRGB(),false));
g.drawRect(drawX,drawY,OrWidth-1,OrHeight-1);
updateXY(e);
setActualBoundry();
g.drawRect(drawX,drawY,OrWidth-1,OrHeight-1);
}
}
public void mouseMoved(MouseEvent e) {
}
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.BLACK);
g.drawRect(5,5,12,12);
g.setColor(Color.WHITE);
g.fillRect(6,6,11,11);
}
public void myAction() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -