📄 cursorlens.java
字号:
package net.sourceforge.jpowergraph.lens;
import java.awt.geom.Point2D;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Display;
import net.sourceforge.jpowergraph.pane.JGraphPane;
public class CursorLens extends AbstractLens {
protected boolean moveGraph;
private static Cursor arrow;
public static Cursor hand;
private static Cursor cross;
public static Cursor stop;
private Cursor overRideCursor;
private boolean disposed = false;
public CursorLens(Display theDisplay) {
arrow = new Cursor(theDisplay, SWT.CURSOR_ARROW);
hand = new Cursor(theDisplay, SWT.CURSOR_HAND);
cross = theDisplay.getSystemCursor(SWT.CURSOR_CROSS);
stop = theDisplay.getSystemCursor(SWT.CURSOR_NO);
setMoveGraph(true);
}
public boolean isMoveGraph() {
return moveGraph;
}
public boolean isCreateEdge() {
return !moveGraph;
}
public void setMoveGraph(boolean theMoveGraph) {
moveGraph = theMoveGraph;
fireLensUpdated();
}
public void setCreateEdge(boolean theCreateEdge) {
moveGraph = !theCreateEdge;
fireLensUpdated();
}
public void setCursor(Cursor theCursor){
overRideCursor = theCursor;
fireLensUpdated();
}
public void applyLens(JGraphPane theJGraphPane, Point2D point) {
if (overRideCursor != null && !overRideCursor.isDisposed()){
theJGraphPane.setCursor(overRideCursor);
}
else if (moveGraph){
if (!arrow.isDisposed()){
theJGraphPane.setCursor(arrow);
}
}
else {
if (!cross.isDisposed()){
theJGraphPane.setCursor(cross);
}
}
}
public void undoLens(JGraphPane theJGraphPane, Point2D point) {
if (overRideCursor != null && !overRideCursor.isDisposed()){
theJGraphPane.setCursor(overRideCursor);
}
else if (moveGraph){
if (!arrow.isDisposed()){
theJGraphPane.setCursor(arrow);
}
}
else {
if (!cross.isDisposed()){
theJGraphPane.setCursor(cross);
}
}
}
public void dispose(){
if (!arrow.isDisposed()){
arrow.dispose();
}
if (!hand.isDisposed()){
hand.dispose();
}
if (!cross.isDisposed()){
cross.dispose();
}
if (!stop.isDisposed()){
stop.dispose();
}
if (overRideCursor != null && !overRideCursor.isDisposed()){
overRideCursor.dispose();
}
disposed = true;
}
public boolean isDisposed(){
return disposed ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -