importjavax.swing.*;importjava.util.Collection.*;importorg.apache.log4j.Logger;importorg.apache.log4j.Level;importorg.apache.log4j.BasicConfigurator;importGraph.*;publicclassMapViewerextendsjavax.swing.JFrame{/** * The logger for this module. */privatestaticfinalLoggerLOGGER=Logger.getLogger("org.geotools.j2se-demos");privateFeatureCollectionfeatures;privateStylestyle;privateJLabelstatus;privateMapmap;privateMapPanemaster;privateAreaOfInterestModelaoi;/** Creates a new instance of MapViewer */publicvoidMapViewer(){initComponents();}/** This method is called from within the constructor to * initialize the form. */privatevoidinitComponents(){JMenuBarmenuBar=newjavax.swing.JMenuBar();JMenufileMenu=newjavax.swing.JMenu();JMenuItemloadGML=newjavax.swing.JMenuItem();JMenuItemloadSHP=newjavax.swing.JMenuItem();JSeparatorjSeparator1=newjavax.swing.JSeparator();JMenuItemloadSLD=newjavax.swing.JMenuItem();setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);setTitle("Map Viewer");addWindowListener(newjava.awt.event.WindowAdapter(){publicvoidwindowClosing(java.awt.event.WindowEventevt){exitForm(evt);}});fileMenu.setMnemonic("F");fileMenu.setText("File");fileMenu.setToolTipText("null");loadGML.setText("Open GML");loadGML.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){loadGMLActionPerformed(evt);}});loadSLD.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){loadSLDActionPerformed(evt);}});fileMenu.add(loadGML);loadSHP.setText("Item");loadSHP.setEnabled(false);fileMenu.add(loadSHP);fileMenu.add(jSeparator1);loadSLD.setText("Open SLD");fileMenu.add(loadSLD);menuBar.add(fileMenu);setJMenuBar(menuBar);status=newJLabel("[Geometry : False] [Style : False]");this.getContentPane().add(status,"South");map=newDefaultMap();aoi=newDefaultAreaOfInterestModel(null,null);finalMapPanemaster=newMapPane(map,aoi);this.getContentPane().add(master.createScrollPane(),"Center");pack();java.awt.DimensionscreenSize=java.awt.Toolkit.getDefaultToolkit().getScreenSize();setSize(newjava.awt.Dimension(461,318));setLocation((screenSize.width-461)/2,(screenSize.height-318)/2);}privatevoidsetupMap(){updateStatus();if(style==null||features==null){LOGGER.fine("abort map setup, style or features is null");return;}map.addFeatureTable(features,style);}privatevoidloadSLDActionPerformed(java.awt.event.ActionEventevt){try{JFileChooserfc=newJFileChooser();intstatus=fc.showOpenDialog(this);if(status!=JFileChooser.APPROVE_OPTION){return;}Filef=fc.getSelectedFile();style=newBasicPolygonStyle();setupMap();}catch(Exceptionioe){LOGGER.warning("Unable to load SLD file "+ioe);}}privatevoidloadGMLActionPerformed(java.awt.event.ActionEventevt){try{JFileChooserfc=newJFileChooser();intstatus=fc.showOpenDialog(this);if(status!=JFileChooser.APPROVE_OPTION){return;}Filef=fc.getSelectedFile();ShapefileDataSourcedatasource=newShapefileDataSource(f.toURL());features=newFeatureCollectionDefault(datasource);Envelopeenv=datasource.getBbox(false);EnvelopeExtentr=newEnvelopeExtent(env);features.getFeatures(r);features.setExtent(r);aoi.setAreaOfInterest(env,null);LOGGER.fine("gml data loaded "+features.getFeatures().length+" features loaded");setupMap();}catch(IOExceptionioe){LOGGER.warning("Unable to load GML file"+ioe);}catch(DataSourceExceptiondse){LOGGER.warning("Unable to load GML file"+dse);}}privatevoidexitForm(java.awt.event.WindowEventevt){System.exit(0);}privatevoidupdateStatus(){status.setText("[Geometry : "+(features!=null)+"] "+"[Style : "+(style!=null)+"]");}/** * @param args the command line arguments */publicstaticvoidmain(Stringargs[]){newMapViewer().show();}}
pcalcado
Olá,
Quando vc for postar codigo, tenha do dos nossos pobres olhinhos e coloque-o entre as tags [ code] e [ /code], assim ele nao vira uma macarronada pos-modernista