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

📄 javadrawviewer.java

📁 开源(Open Source)项目JHotDraw的文档和源程序
💻 JAVA
字号:
/*
 * @(#)JavaDrawViewer.java 5.2
 *
 */

package CH.ifa.draw.samples.javadraw;

import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.*;
import java.io.*;
import java.net.*;

import CH.ifa.draw.framework.*;
import CH.ifa.draw.standard.*;
import CH.ifa.draw.util.*;


public  class JavaDrawViewer extends JApplet implements DrawingEditor {

    private Drawing         fDrawing;
    private Tool            fTool;
    private StandardDrawingView fView;
    private Iconkit         fIconkit;

    public void init() {
		getContentPane().setLayout(new BorderLayout());
	    fView = new StandardDrawingView(this, 400, 370);
        getContentPane().add("Center", fView);
        fTool = new FollowURLTool(view(), this);

        fIconkit = new Iconkit(this);

        String filename = getParameter("Drawing");
        if (filename != null) {
		    loadDrawing(filename);
            fView.setDrawing(fDrawing);
		} else
		    showStatus("Unable to load drawing");
    }

    private void loadDrawing(String filename) {
        try {
            URL url = new URL(getCodeBase(), filename);
            InputStream stream = url.openStream();
            StorableInput reader = new StorableInput(stream);
            fDrawing = (Drawing)reader.readStorable();
        } catch (IOException e) {
            fDrawing = new StandardDrawing();
            System.out.println("Error when Loading: " + e);
            showStatus("Error when Loading: " + e);
        }
    }

    /**
     * Gets the editor's drawing view.
     */
    public DrawingView view() {
        return fView;
    }

    /**
     * Gets the editor's drawing.
     */
    public Drawing drawing() {
        return fDrawing;
    }

    /**
     * Gets the current the tool (there is only one):
     */
    public Tool tool() {
        return fTool;
    }

    /**
     * Sets the editor's default tool. Do nothing since we only have one tool.
     */
    public void toolDone() {}

    /**
     * Ignore selection changes, we don't show any selection
     */
    public void selectionChanged(DrawingView view) {}
}

⌨️ 快捷键说明

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