1 package com.hammurapi.jdraw;
2 
3 import java.awt.Color;
4 import java.awt.event.ActionEvent;
5 
6 import javax.swing.JApplet;
7 
8 import com.mxgraph.examples.swing.GraphEditor;
9 import com.mxgraph.examples.swing.editor.BasicGraphEditor;
10 import com.mxgraph.examples.swing.editor.EditorActions;
11 import com.mxgraph.examples.swing.editor.EditorMenuBar;
12 import com.mxgraph.swing.util.mxSwingConstants;
13 import com.mxgraph.util.mxConstants;
14 
15 public class JDrawApplet extends JApplet {
16 
17 //	private DefaultHttpClient httpClient;
18 
19 	@Override
init()20 	public void init() {
21 		super.init();
22 
23 //		HttpParams params = new BasicHttpParams();
24 //		SchemeRegistry schemeRegistry = new SchemeRegistry();
25 //		schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
26 //
27 //		ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
28 //		httpClient = new DefaultHttpClient(cm, params);
29 
30 		// Proxy configuration - requires java.net.NetPermission getProxySelector
31 //		ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
32 //		        httpClient.getConnectionManager().getSchemeRegistry(),
33 //		        ProxySelector.getDefault());
34 //		httpClient.setRoutePlanner(routePlanner);
35 
36 //		HttpHost proxy = new HttpHost("localhost", 8888);
37 //		httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
38 	}
39 
40 	@Override
start()41 	public void start() {
42 		mxSwingConstants.SHADOW_COLOR = Color.LIGHT_GRAY;
43 		mxConstants.W3C_SHADOWCOLOR = "#D3D3D3";
44 
45 		BasicGraphEditor.Config config = new BasicGraphEditor.Config(this); //, httpClient);
46 		GraphEditor editor = new GraphEditor(config);
47 		getContentPane().add(editor);
48 		setJMenuBar(new EditorMenuBar(editor));
49 
50 		ActionEvent event = new ActionEvent(editor.getGraphComponent(), -1, "open");
51 		new EditorActions.OpenAction().actionPerformed(event);
52 	}
53 
54 //	@Override
55 //	public void destroy() {
56 //		if (httpClient!=null) {
57 //			httpClient.getConnectionManager().shutdown();
58 //		}
59 //		super.destroy();
60 //	}
61 }
62