📄 tinylineapplet.java
字号:
/****************************************************************** * Copyright (C) 2002-2006 Andrew Girow. All rights reserved. * * ---------------------------------------------------------------* * This software is published under the terms of the TinyLine * * License, a copy of which has been included with this * * distribution in the TINYLINE_LICENSE.TXT file. * * * * For more information on the TinyLine, * * please see <http://www.tinyline.com/>. * *****************************************************************/package com.tinyline.app;import java.applet.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.net.*;import java.util.zip.*;import java.awt.image.*;import com.tinyline.tiny2d.*;import com.tinyline.svg.*;/** * The <tt>TinyLineApplet</tt> is the J2ME Personal Profile * implementation of the SVGT Viewer. * <p> * @author (C) Andrew Girow * @version 1.9 * <p> */public class TinyLineApplet extends Applet implements StatusBar{ String appletInfo = new String("TinyLine4Web 1.10 Copyright (C) 2002-2006 Andrew Girow. All rights reserved."); // The viewer size Dimension dim; // Bounds Rectangle canvasBounds; // The mouse event handler AppletMouseHandler currentMouseHandler; // SVG canvas! PPSVGCanvas canvas; Runtime r; // The svg file t be drawn String svgfile; /** Constructs the viewer */ public TinyLineApplet() { setBackground(Color.white); } /** Returns information about this applet */ public String getAppletInfo() { return appletInfo; } /* Returns the applet params */ public String[][] getParameterInfo() { String as[][] = { { "svgfile", "url", "the SVG Tiny file" } }; return as; } /** * Called by the browser or applet viewer to inform * this applet that it should start its execution. It is called after * the <code>init</code> method and each time the applet is revisited * in a Web page. */ public void start() { canvas.start(); try { URL url = new URL(getDocumentBase(),svgfile); canvas.goURL(url.toExternalForm()); r.gc(); } catch(Exception e) { } } /** * Called by the browser or applet viewer to inform * this applet that it should stop its execution. It is called when * the Web page that contains this applet has been replaced by * another page, and also just before the applet is to be destroyed. */ public void stop() { if(canvas!= null) canvas.stop(); } /** * Called by the browser or applet viewer to inform * this applet that it is being reclaimed and that it should destroy * any resources that it has allocated. */ public void destroy() { if(canvas!= null) canvas.stop(); } /** * Called by the browser or applet viewer to inform * this applet that it has been loaded into the system. It is always * called before the first time that the <code>start</code> method is * called. * <p> * Builds the viewer layout and inits the viewer * <p> */ public void init() { r = Runtime.getRuntime(); setLayout(null); dim = getSize(); setBackground(new Color(184,200,216)); // Calculates bounds canvasBounds = new Rectangle(0,0,dim.width,dim.height); // Creates the SVG canvas canvas = new PPSVGCanvas(canvasBounds.width,canvasBounds.height); canvas.setBounds(canvasBounds.x,canvasBounds.y,canvasBounds.width,canvasBounds.height); add(canvas); canvas.setStatusBar(this); // Sets the applet mouse handler currentMouseHandler = new AppletMouseHandler(canvas,this); currentMouseHandler.type = AppletMouseHandler.LINK_MOUSE; canvas.addMouseListener(currentMouseHandler); canvas.addMouseMotionListener(currentMouseHandler); // Gets graphics repaint(); ///???? // Adds the default events listener PlayerListener defaultListener = new PlayerListener(canvas); canvas.addEventListener("default", defaultListener, false); // Loads the default font!!! SVGDocument doc = canvas.loadSVG(getClass().getResourceAsStream("/com/tinyline/app/images/helvetica_svg")); SVGFontElem font = SVGDocument.getFont(doc,SVG.VAL_DEFAULT_FONTFAMILY); SVGDocument.defaultFont = font; // Gets the 'svgfile' parameter svgfile = this.getParameter("svgfile"); } /** Updates this viewer */ public void update(Graphics g) { paint(g); } /** Shows an error message */ public void alertError(String s) { System.out.println(s); showStatus(s); } /** Shows a wait message */ public void alertWait(String s) { showStatus(s); } /** Shows an init message */ public void alertInit(String s) { showStatus(s); } /** Shows an exteranal resource */ public void showDocument(String s) { try { URL url = new URL(s); getAppletContext().showDocument(url); } catch(Exception e) { } } /** * Returns the PPSVGCanvas. * @return an PPSVGCanvas object. */ public PPSVGCanvas getSVGCanvas() { return canvas; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -