?? mapperclientapplet.java
字號(hào):
// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: MapperClientApplet.java
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
public class MapperClientApplet extends Applet
{
class MCanvas extends Canvas
{
void setImage(Image i)
{
m_bufferedImage = i;
}
public void paint(Graphics g)
{
if(m_bufferedImage != null && g != null)
g.drawImage(m_bufferedImage, 0, 0, this);
}
public boolean imageUpdate(Image img, int infoflag, int x, int y, int width, int height)
{
boolean result = true;
if((infoflag & 0xc0) != 0)
{
result = false;
}
else
{
if((infoflag & 0x20) != 0)
result = false;
repaint();
}
return result;
}
public void update(Graphics g)
{
paint(g);
}
Image m_bufferedImage;
MCanvas()
{
m_bufferedImage = null;
}
}
public MapperClientApplet()
{
m_tool = "0";
m_isStandalone = false;
m_zoomIn = new Button();
m_zoomOut = new Button();
m_pan = new Button();
m_map = new MCanvas();
}
public String getParameter(String key, String def)
{
return m_isStandalone ? System.getProperty(key, def) : getParameter(key) == null ? def : getParameter(key);
}
public void init()
{
String strParm = getParameter("servleturl");
if(strParm != null && strParm.length() > 1)
m_servletName = strParm;
setBackground(Color.white);
m_zoomIn.setBounds(new Rectangle(50, 8, 80, 35));
m_zoomIn.setLabel("ZoomIn");
m_zoomIn.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
{
m_tool = "1";
}
});
m_zoomOut.setBounds(new Rectangle(200, 8, 80, 35));
m_zoomOut.setLabel("ZoomOut");
m_zoomOut.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
{
m_tool = "2";
}
});
m_pan.setBounds(new Rectangle(350, 8, 80, 35));
m_pan.setLabel("Pan");
m_map.setBounds(new Rectangle(0, 50, 500, 500));
m_map.setBackground(Color.white);
m_map.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
{
String url = m_sessionURL;
url = url + "?ptx=" + new Integer(e.getX());
url = url + "&pty=" + new Integer(e.getY());
url = url + "&tool=" + m_tool;
adjustMap(url);
}
});
m_pan.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e)
{
m_tool = "3";
}
});
setLayout(null);
add(m_zoomIn, null);
add(m_zoomOut, null);
add(m_pan, null);
add(m_map, null);
try
{
initMap();
adjustMap(m_sessionURL);
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public String getAppletInfo()
{
return "Applet Information";
}
void adjustMap(String url)
{
try
{
byte img[] = new byte[m_map.getPreferredSize().width * m_map.getPreferredSize().height * 2];
URL mapServer = new URL(url);
System.out.println("url: " + mapServer);
URLConnection s = mapServer.openConnection();
DataInputStream in = new DataInputStream(s.getInputStream());
try
{
in.readFully(img);
}
catch(EOFException eofexception) { }
in.close();
m_map.setImage(getToolkit().createImage(img));
m_map.repaint();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
void initMap()
{
try
{
String url = m_servletName + "?init=true";
URL mapServer = new URL(url);
URLConnection s = mapServer.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String inputLine;
if((inputLine = in.readLine()) != null)
{
m_sessionURL = inputLine;
System.out.println("Received: " + inputLine);
}
in.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private static String m_servletName = "http://localhost:8080/samples45/servlet/mapper";
private String m_sessionURL;
private String m_tool;
private final String NO_TOOL = "0";
private final String ZOOM_IN_TOOL = "1";
private final String ZOOM_OUT_TOOL = "2";
private final String PAN_TOOL = "3";
private boolean m_isStandalone;
private Button m_zoomIn;
private Button m_zoomOut;
private Button m_pan;
private MCanvas m_map;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -