JSBean Appliction Online Demo

Map Window Only Mode - In this mode, users can right-click the mouse button to
get assistant popup menu. Click the upper-right icon on Map Window to switch to All Window Mode.

All Windows Mode - Click the upper-right icon on Map Window to switch to Map Window Only Mode.
The parameters used in the online demo:
#project parameters
project=The Populations of Japan Cities
unzoomratio=2
cmdfile=japan.cmd
piofile=japan.pio
external=japan
mbcolor=blue
MapWindowOnly=on
status=5
count=2
#layer1 parameters
layer1=japancity.shp
info1=japancity.txt
title1=Cities
fcolor1=green
lcolor1=green
size1=8
thematic1=japancity.tmt
tmenable1=off
pio1=1
#layer2 parameters
layer2=japan.shp
title2=Japan
fcolor2=red
bcolor2=lightGray
The application source code generated by Sun's BeanBox:
import java.util.Hashtable;
import java.io.Serializable;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.applet.Applet;
import java.lang.reflect.Method;
import java.beans.Beans;
import sunw.beanbox.AppletSupport;
import sunw.beanbox.PropertyHookup;
public class MyApplet extends Applet implements Serializable {
// Public 0-argument constructor
public void start() {
// public MyApplet() {
this.setLayout(null);
try {
initContents();
} catch (Exception ex) {
System.err.println(ex);
throw new Error("trouble initializing contents: "+ex);
}
}
// Preferred size
public Dimension getPreferredSize() {
return getMinimumSize();
}
// Preferred size
public Dimension getMinimumSize() {
return new Dimension(380, 477);
}
// Initialize nested beans
private void initContents()
throws java.lang.ClassNotFoundException,
java.io.IOException
{
myLoader = this.getClass().getClassLoader();
propInstances = new Hashtable();
// Create nested beans
JSBean1 = (JSBean) Beans.instantiate(myLoader,"JSBean");
JSBean1.SetApplet(this);
JSBean1.setProjectFile("japan.ini");
buttonBean1 = (ButtonBean) Beans.instantiate(myLoader,"ButtonBean");
buttonBean1.setLabel("UnZoom");
buttonBean2 = (ButtonBean) Beans.instantiate(myLoader,"ButtonBean");
buttonBean2.setLabel("ZoomIn");
buttonBean3 = (ButtonBean) Beans.instantiate(myLoader,"ButtonBean");
buttonBean3.setLabel("ZoomOut");
// position all nested beans - we don't have it initially
acquire(JSBean1, new Rectangle(12, 38, 359, 340));
acquire(buttonBean1, new Rectangle(23, 412, 90, 38));
acquire(buttonBean2, new Rectangle(148, 412, 90, 38));
acquire(buttonBean3, new Rectangle(270, 412, 90, 38));
// Add their connections
addConnections();
}
private void addConnections() {
try {
//
hookup0 = new tmp.sunw.beanbox.___Hookup_158322691c();
hookup0.setTarget(JSBean1);
buttonBean1.addActionListener(hookup0);
//
hookup1 = new tmp.sunw.beanbox.___Hookup_1583226ee2();
hookup1.setTarget(JSBean1);
buttonBean2.addActionListener(hookup1);
//
hookup2 = new tmp.sunw.beanbox.___Hookup_158322760a();
hookup2.setTarget(JSBean1);
buttonBean3.addActionListener(hookup2);
//
// No property adaptors. A typical example is:
// hookup0 = addPropertyTarget(
// ourButton1,
// "foreground",
// "background",
// "setBackground", new String[] {"java.awt.Font"});
} catch (Exception ex) {
System.err.println("Problems adding a target: "+ex);
ex.printStackTrace();
}
}
private void addReconnections() {
try {
//
//
//
//
// No property adaptors. A typical example is:
// hookup0 = addPropertyTarget(
// ourButton1,
// "foreground",
// "background",
// "setBackground", new String[] {"java.awt.Font"});
// No method adaptors. A typical example is:
// hookup0 = new MyActionAdaptor();
// ourButton1.addActionListener(hookup0);
} catch (Exception ex) {
System.err.println("Problems adding a target: "+ex);
ex.printStackTrace();
}
}
// Serialization code - readObject
private void readObject(java.io.ObjectInputStream ois)
throws java.lang.ClassNotFoundException,
java.io.IOException
{
// Initialize object from stream
Object[] data = (Object[]) ois.readObject();
myLoader = this.getClass().getClassLoader();
propInstances = new Hashtable();
String id = (String) data[0];
if (! id.equals("MyApplet")) {
throw new Error("Wrong data!");
}
// Get references to nested beans
JSBean1 = (JSBean) data[1];
buttonBean1 = (ButtonBean) data[2];
buttonBean2 = (ButtonBean) data[3];
buttonBean3 = (ButtonBean) data[4];
// Don't position nested beans
acquire(JSBean1, null);
acquire(buttonBean1, null);
acquire(buttonBean2, null);
acquire(buttonBean3, null);
// Reconnect their connections
addReconnections();
}
// Serialization code - writeObject
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException
{
Object data[] = new Object[5];
data[0] = "MyApplet";
data[1] = JSBean1;
data[2] = buttonBean1;
data[3] = buttonBean2;
data[4] = buttonBean3;
// Write the object out
oos.writeObject(data);
}
// The fields used to hold the beans
private JSBean JSBean1;
private ButtonBean buttonBean1;
private ButtonBean buttonBean2;
private ButtonBean buttonBean3;
// The hookups
private tmp.sunw.beanbox.___Hookup_158322691c hookup0;
private tmp.sunw.beanbox.___Hookup_1583226ee2 hookup1;
private tmp.sunw.beanbox.___Hookup_158322760a hookup2;
// No property adaptors. A typical example is:
// private PropertyHookup hookup1;
// the loader so we can locate the resource file
private ClassLoader myLoader;
// ===========================================
// Support code
// ===========================================
// It really belongs in support.jar but it is here for your reading pleasure
// Acquire a bean
private void acquire(Object bean, Rectangle boundsData) {
if (!(bean instanceof Component)) {
return;
}
if (bean instanceof Applet) {
AppletSupport.assignStub((Applet) bean,
myLoader,
bean.getClass());
}
add((Component) bean);
if (boundsData != null) {
((Component) bean).setBounds(boundsData);
}
((Component)bean).invalidate(); // not needed?
if (bean instanceof Applet) {
// Start the Applet
((Applet)bean).start();
}
}
// Add a property bound via an adaptor
Hashtable propInstances = new Hashtable();
private PropertyHookup addPropertyTarget(Object source,
String propertyName,
Object targetObject,
String setterName, String[] setterTypeNames) throws Exception
{
Object args[] = new Object[1]; // arguments
Class types[] = new Class[1]; // types
Class pClass = java.beans.PropertyChangeListener.class;
PropertyHookup hook = (PropertyHookup) propInstances.get(source);
if (hook == null) {
// This is the first property hookup on this source object
// Push a PropertyHookup adaptor onto the source
hook = new PropertyHookup(source);
propInstances.put(source, hook);
// find the adder
types[0] = pClass;
Method adder = source.getClass().getMethod("addPropertyChangeListener", types);
// invoke the adder
args[0] = hook;
adder.invoke(source, args);
}
// get setter
Method setter = targetObject.getClass().getMethod(setterName,
getClassFromTypes(setterTypeNames));
hook.attach(propertyName, targetObject, setter);
return hook;
}
private Class[] getClassFromTypes(String types[]) throws Exception {
Class[] back = new Class[types.length];
for (int i=0; i<back.length; i++) {
Class c = unwrapPrimitiveStringToClass(types[i]);
if (c == null)
back[i] = myLoader.loadClass(types[i]);
else
back[i] = c;
}
return back;
}
private Class unwrapPrimitiveStringToClass(String s) {
if (s.equals(Byte.TYPE.getName())) return byte.class;
if (s.equals(Short.TYPE.getName())) return short.class;
if (s.equals(Integer.TYPE.getName())) return int.class;
if (s.equals(Long.TYPE.getName())) return long.class;
if (s.equals(Double.TYPE.getName())) return double.class;
if (s.equals(Float.TYPE.getName())) return float.class;
if (s.equals(Character.TYPE.getName())) return char.class;
if (s.equals(Boolean.TYPE.getName())) return boolean.class;
if (s.equals(Void.TYPE.getName())) return void.class;
return null;
}
// ===========================================
// End of Support code
// ===========================================
}
');
document.write('');
// document.write('');
document.write('');
document.write('');
if (document.cookie.indexOf('fcseenpop') == -1) {
pop_domain = document.domain.substring(document.domain.indexOf('.'));
expiry_date = new Date(new Date().getTime() + 86400000).toGMTString(); // 24 hours
document.write('');
document.cookie = 'fcseenpop=1; path=/; domain=' + pop_domain + '; expires=' + expiry_date;
}
}
}
// -->