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

📄 cursorlens.java

📁 JPowerGraph is a Java library for creating directed graphs for Swing. It supports graph movement, se
💻 JAVA
字号:
package net.sourceforge.jpowergraph.lens;

import java.awt.Cursor;
import java.awt.dnd.DragSource;
import java.awt.geom.Point2D;

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 = null;
    
    public CursorLens() {
        arrow = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        hand = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
        cross = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
        stop = DragSource.DefaultMoveNoDrop;
        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){
            theJGraphPane.setCursor(overRideCursor);
        }
        else if (moveGraph){
            theJGraphPane.setCursor(arrow);
        }
        else {
            theJGraphPane.setCursor(cross);
        }
    }

    public void undoLens(JGraphPane theJGraphPane, Point2D point) {
        if (overRideCursor != null){
            theJGraphPane.setCursor(overRideCursor);
        }
        else if (moveGraph){
            theJGraphPane.setCursor(arrow);
        }
        else {
            theJGraphPane.setCursor(cross);
        }
    }
}

⌨️ 快捷键说明

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