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

📄 translatelens.java

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

import java.awt.geom.Point2D;

import net.sourceforge.jpowergraph.pane.JGraphPane;

/**
 * An implementation of the lens that allows transaltion.
 */
public class TranslateLens extends AbstractLens {
    /** The translation along X axis. */
    protected double m_translateX;
    /** The translation along Y axis. */
    protected double m_translateY;
    private boolean disposed = false;

    /**
     * Creates a lens for zooming.
     */
    public TranslateLens() {
        setTranslate(0,0);
    }
    /**
     * Returns the translation along X axis.
     *
     * @return                  the translation along X axis
     */
    public double getTranslateX() {
        return m_translateX;
    }
    /**
     * Returns the translation along Y axis.
     *
     * @return                  the translation along Y axis
     */
    public double getTranslateY() {
        return m_translateY;
    }
    /**
     * Sets the new translation factory.
     *
     * @param translateX        translation along X axis
     * @param translateY        translation along Y axis
     */
    public void setTranslate(double translateX,double translateY) {
        m_translateX=translateX;
        m_translateY=translateY;
        fireLensUpdated();
    }
    /**
     * Applies the lens to the point and modifies it according to the lens equations.
     *
     * @param point             the point that will be modified
     */
    public void applyLens(JGraphPane theJGraphPane, Point2D point) {
        point.setLocation(point.getX()+m_translateX,point.getY()+m_translateY);
    }
    /**
     * Undoes the lens effect on the point.
     *
     * @param point             the point that will be modified
     */
    public void undoLens(JGraphPane theJGraphPane, Point2D point) {
        point.setLocation(point.getX()-m_translateX,point.getY()-m_translateY);
    }
    
    public void dispose(){
        disposed = true;
    }
    
    public boolean isDisposed(){
        return disposed ;
    }
}

⌨️ 快捷键说明

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