import ilog.views.IlvGrapher; import ilog.views.IlvManagerView; import ilog.views.IlvPoint; import ilog.views.maps.*; import ilog.views.maps.beans.*; import ilog.views.maps.projection.IlvCoordinatePanelFactory; import ilog.views.maps.datasource.*; import ilog.views.maps.symbology.swing.IlvSymbologyTreeView; import ilog.views.maps.graphic.style.IlvPolylineStyle; import ilog.views.maps.srs.coordsys.*; import ilog.views.sdm.IlvSDMEngine; import ilog.views.sdm.IlvSDMModel; import ilog.views.sdm.renderer.*; import ilog.views.swing.IlvJManagerViewControlBar; import ilog.views.swing.IlvJScrollManagerView; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.net.URL; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JTabbedPane; import simulation.SimulationController;
App6aDemo
,
which defines the basic building blocks of the Map Builder: public class App6aDemo extends JFrame { IlvManagerView view;// Map view. IlvJScrollManagerView viewScroll;// Scroll around the Map View. IlvSymbologyTreeView symbPanel;// Symbology control panel. IlvJManagerViewControlBar viewToolbar; // Zoom & selection toolbar. IlvJCoordinateSystemEditorPanel csPanel;// Coordinate system choice. IlvJMouseCoordinateViewer locator;// Coordinate information.
public App6aDemo() { super(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
view=new IlvManagerView(); view.setManager(new IlvGrapher()); viewScroll=new IlvJScrollManagerView(view); viewToolbar = new IlvJManagerViewControlBar(); csPanel=new IlvJCoordinateSystemEditorPanel(); viewToolbar.setView(view); locator=new IlvJMouseCoordinateViewer(); locator.setView(view); viewToolbar.add(locator); view.setKeepingAspectRatio(true); view.setBackground(new Color(80, 180, 240)); view.setAntialiasing(false); view.setSize(new Dimension(900, 450)); viewScroll.setPreferredSize(view.getSize());
final IlvSDMEngine symbology = new IlvSDMEngine(); URL symbolCss = App6aDemo.class.getResource("data/app6.css"); symbology.setReferenceView(view); symbology.setGrapher((IlvGrapher) view.getManager()); try { symbology.setStyleSheets(new String[] { symbolCss.toString()}); } catch (IlvSDMException e) {e.printStackTrace(); } /* show this symbology on the GUI */ symbPanel = new IlvSymbologyTreeView(symbology); IlvApp6aSymbologyTreeViewActions app6Actions = new IlvApp6aSymbologyTreeViewActions(); app6Actions.setLatLonPicker(new IlvCoordinatePanelFactory. CoordPointInputPanel(view,IlvDisplayPreferencesProperty. GetDisplayPreferences(view.getManager()).getCoordinateFormatter())); symbPanel.setSymbologyTreeViewActions(app6Actions);
view.getManager().setNamedProperty(new IlvCoordinateSystemProperty(IlvGeographicCoordinateSystem.WGS84));
csPanel.setCoordinateSystem(IlvCoordinateSystemProperty. GetCoordinateSystem(view.getManager())); csPanel.addCoordinateSystemChangeListener(new PropertyChangeListener(){ public void propertyChange(PropertyChangeEvent evt) { IlvCoordinateSystem system = (IlvCoordinateSystem) evt.getNewValue(); view.getManager().setNamedProperty(new IlvCoordinateSystemProperty(system)); symbology.loadData(); } });
symbPanel.setSymbology(symbology);
loadInitialData();
getContentPane().add(viewToolbar,BorderLayout.NORTH); getContentPane().add(symbPanel,BorderLayout.LINE_END); getContentPane().add(viewScroll,BorderLayout.CENTER); JTabbedPane tabPane=new JTabbedPane(); tabPane.addTab("Coordinate System",csPanel); getContentPane().add(tabPane,BorderLayout.LINE_START); getContentPane().add(locator,BorderLayout.SOUTH); }
private void loadInitialData() { URL shpFile = App6aDemo.class.getResource("data/World_Countries.shp"); try { // Create a data source for the shape file. IlvShapeDataSource reader = new IlvShapeDataSource(shpFile.getFile(), true); reader.setCoordinateSystem(IlvGeographicCoordinateSystem.WGS84); // Insert it in the data source tree of the manager. This optional step is necessary to retrieve the data when, for example, a coordinate system change occurs. IlvMapDataSourceModel dsm = IlvMapDataSourceProperty.GetMapDataSourceModel(view.getManager()); dsm.insert(reader); // Get the Map Layer used to display the data source and insert it in the Map Layer tree of the manager. IlvMapLayer layer = reader.getInsertionLayer(); layer.setName("World data"); IlvMapLayerTreeModel ltm = IlvMapLayerTreeProperty.GetMapLayerTreeModel(view.getManager()); ltm.addChild(null, layer); // Start reading. reader.start(); // Set up the layer style. layer.getStyle().setAttribute(IlvPolylineStyle.FOREGROUND,Color.black); layer.getStyle().setAttribute(IlvPolylineStyle.BACKGROUND,new Color(1,1,0.8f)); } catch (Exception e1) {e1.printStackTrace(); }
view.fitTransformerToContent(); }
static public void main(String args[]) { javax.swing.SwingUtilities.invokeLater( new Runnable() { public void run() { final JFrame frame = new App6aDemo(); frame.pack(); frame.setVisible(true); } ); }