connectedtexttool.java
来自「开源(Open Source)项目JHotDraw的文档和源程序」· Java 代码 · 共 52 行
JAVA
52 行
/*
* @(#)ConnectedTextTool.java 5.2
*
*/
package CH.ifa.draw.figures;
import java.awt.*;
import java.awt.event.MouseEvent;
import CH.ifa.draw.framework.*;
import CH.ifa.draw.standard.*;
/**
* Tool to create new or edit existing text figures.
* A new text figure is connected with the clicked figure.
*
* @see CH.ifa.draw.standard.TextHolder
*/
public class ConnectedTextTool extends TextTool {
boolean fConnected = false;
public ConnectedTextTool(DrawingView view, Figure prototype) {
super(view, prototype);
}
/**
* If the pressed figure is a TextHolder it can be edited otherwise
* a new text figure is created.
*/
public void mouseDown(MouseEvent e, int x, int y) {
super.mouseDown(e, x, y);
Figure pressedFigure = drawing().findFigureInside(x, y);
TextHolder textHolder = getTypingTarget();
if (!fConnected && pressedFigure != null &&
textHolder != null && pressedFigure != textHolder) {
textHolder.connect(pressedFigure);
fConnected = true;
}
}
/**
* If the pressed figure is a TextHolder it can be edited otherwise
* a new text figure is created.
*/
public void activate() {
fConnected = false;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?