⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scribbletool.java

📁 JHotDraw学习过程中对数组的测试程序haha 学习过程中对数组的测试程序
💻 JAVA
字号:
/* * @(#)ScribbleTool.java 5.1 * */package CH.ifa.draw.figures;import java.awt.*;import java.awt.event.MouseEvent;import java.io.IOException;import CH.ifa.draw.framework.*;import CH.ifa.draw.standard.AbstractTool;/** * Tool to scribble a PolyLineFigure * @see PolyLineFigure */public class ScribbleTool extends AbstractTool {    private PolyLineFigure  fScribble;    private int             fLastX, fLastY;    public ScribbleTool(DrawingView view) {        super(view);    }    public void activate() {        super.activate();        fScribble = null;    }    public void deactivate() {        super.deactivate();        if (fScribble != null) {            if (fScribble.size().width < 4 || fScribble.size().height < 4)                drawing().remove(fScribble);        }    }    private void point(int x, int y) {        if (fScribble == null) {            fScribble = new PolyLineFigure(x, y);            view().add(fScribble);        } else if (fLastX != x || fLastY != y)            fScribble.addPoint(x, y);        fLastX = x;        fLastY = y;    }    public void mouseDown(MouseEvent e, int x, int y) {        if (e.getClickCount() >= 2) {            fScribble = null;            editor().toolDone();        }        else {            // use original event coordinates to avoid            // supress that the scribble is constrained to            // the grid            point(e.getX(), e.getY());        }    }    public void mouseDrag(MouseEvent e, int x, int y) {        if (fScribble != null)            point(e.getX(), e.getY());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -