• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JMapFrame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.geotools.swing.JMapFrame的典型用法代码示例。如果您正苦于以下问题:Java JMapFrame类的具体用法?Java JMapFrame怎么用?Java JMapFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JMapFrame类属于org.geotools.swing包,在下文中一共展示了JMapFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * This method demonstrates using a memory-based cache to speed up the display (e.g. when
 * zooming in and out).
 * 
 * There is just one line extra compared to the main method, where we create an instance of
 * CachingFeatureStore.
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    CachingFeatureSource cache = new CachingFeatureSource(featureSource);

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Using cached features");
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(cache, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:QuickstartCache.java


示例2: main

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
 * contents on the screen in a map frame
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Quickstart");
    
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:26,代码来源:Quickstart.java


示例3: displayShapefile

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * Prompts the user for a shapefile (unless a filename is provided
 * on the command line; then creates a simple Style and displays
 * the shapefile on screen
 */
private void displayShapefile() throws Exception {
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    FeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("StyleLab");

    // Create a basic Style to render the features
    Style style = createStyle(file, featureSource);

    // Add the features and the associated Style object to
    // the MapContent as a new Layer
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:StyleLab.java


示例4: main

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * Prompts the user for a wms service, connects, and asks for a layer and then
 * and displays its contents on the screen in a map frame.
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    URL capabilitiesURL = WMSChooser.showChooseWMS();
    if( capabilitiesURL == null ){
        System.exit(0); // canceled
    }
    WebMapServer wms = new WebMapServer( capabilitiesURL );        
    
    List<Layer> wmsLayers = WMSLayerChooser.showSelectLayer( wms );
    if( wmsLayers == null ){
        JOptionPane.showMessageDialog(null, "Could not connect - check url");
        System.exit(0);
    }
    MapContent mapcontent = new MapContent();
    mapcontent.setTitle( wms.getCapabilities().getService().getTitle() );
    
    for( Layer wmsLayer : wmsLayers ){
        WMSLayer displayLayer = new WMSLayer(wms, wmsLayer );
        mapcontent.addLayer(displayLayer);
    }
    // Now display the map
    JMapFrame.showMap(mapcontent);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:28,代码来源:WMSLab.java


示例5: TwoAttributes

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
public TwoAttributes(String[] args) throws IOException {
	File file = new File(args[0]);
	FileDataStore store = FileDataStoreFinder.getDataStore(file);
	SimpleFeatureSource featureSource = store.getFeatureSource();
	SimpleFeatureType schema = featureSource.getSchema();
	System.out.println(schema);
	// Create a map content and add our shapefile to it
	MapContent mapContent = new MapContent();
	mapContent.setTitle("GeoTools Mapping");
	Style style = SLD.createSimpleStyle(featureSource.getSchema());
	Layer layer = new FeatureLayer(featureSource, style);
	mapContent.addLayer(layer);
	frame = new JMapFrame(mapContent);
	frame.enableStatusBar(true);
	frame.enableToolBar(true);
	JToolBar toolBar = frame.getToolBar();
	toolBar.addSeparator();
	SaveAction save = new SaveAction("Save");
	toolBar.add(save);
	frame.initComponents();
	frame.setSize(1000, 500);
	frame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:24,代码来源:TwoAttributes.java


示例6: SaveMapAsImage

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
public SaveMapAsImage(File file) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:SaveMapAsImage.java


示例7: withTestModels

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
private static void withTestModels(String folder) throws Exception {
    	URL schemaURL = new File("/Users/markus/Documents/Projects/EMFFrag/02_workspace/citygml.git/de.hub.citygml.models/schemas/"+folder+"/TestFeature.xsd").toURL();    	
    	URL modelURL = new File("/Users/markus/Documents/Projects/EMFFrag/02_workspace/citygml.git/de.hub.citygml.models/schemas/"+folder+"/TestFeature.xml").toURL();

        GML gml = new GML(Version.WFS1_1);
        gml.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
        NameImpl typeName = new NameImpl("http://www.geotools.org/test", "TestFeature");
//        
		SimpleFeatureType featureType = gml.decodeSimpleFeatureType(schemaURL, typeName);        
        System.out.println("#1: " + (featureType == null ? "NULL" : featureType.toString()));
    
        SimpleFeatureCollection featureCollection = gml.decodeFeatureCollection(modelURL.openStream());        
        System.out.println("#2: " + featureCollection.size());
        
		MapContent map = new MapContent();
		map.setTitle("Quickstart");

		Style style = SLD.createSimpleStyle(featureCollection.getSchema());
		Layer layer = new FeatureLayer(featureCollection, style);
		map.addLayer(layer);

		// Now display the map
		JMapFrame.showMap(map);
    }
 
开发者ID:markus1978,项目名称:citygml4emf,代码行数:25,代码来源:Quickstart.java


示例8: displayMaps

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
@Execute
public void displayMaps() throws Exception {
    sf = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
    ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    sb = new StyleBuilder(sf, ff);

    final MapContent map = new MapContent();
    map.setTitle("Maps Viewer");

    addImageMosaic(map);

    addCoverages(map);

    addFeatureCollections(map);

    map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);

    // Create a JMapFrame with a menu to choose the display style for the
    final JMapFrame frame = new JMapFrame(map);
    frame.setSize(1800, 1200);
    frame.enableStatusBar(true);
    frame.enableTool(JMapFrame.Tool.ZOOM, JMapFrame.Tool.PAN, JMapFrame.Tool.RESET);
    frame.enableToolBar(true);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
        public void windowClosing( WindowEvent e ) {
            frame.setVisible(false);
        }
    });

    while( frame.isVisible() ) {
        Thread.sleep(300);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:35,代码来源:OmsMapsViewer.java


示例9: main

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * GeoTools Quickstart demo application. Prompts the user for a shapefile
 * and displays its contents on the screen in a map frame
 */
public static void main(String[] args) throws Exception {
	File file = null;
	if (args.length >= 1) {
		file = new File(args[0]);
	}
	if (file == null) {
		// display a data store file chooser dialog for shapefiles
		file = JFileDataStoreChooser.showOpenFile("shp", null);
		if (file == null) {
			return;
		}
	}
	FileDataStore store = FileDataStoreFinder.getDataStore(file);
	SimpleFeatureSource featureSource = store.getFeatureSource();

	// Create a map content and add our shapefile to it
	MapContent map = new MapContent();
	map.setTitle("Quickstart");

	Style style = SLD.createSimpleStyle(featureSource.getSchema());
	Layer layer = new FeatureLayer(featureSource, style);
	map.addLayer(layer);

	// Now display the map
	JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:31,代码来源:Quickstart.java


示例10: displayShapefile

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * This method:
 * <ol type="1">
 * <li>Prompts the user for a shapefile to display
 * <li>Creates a JMapFrame with custom toolbar buttons
 * <li>Displays the shapefile
 * </ol>
 */
// docs start display
private void displayShapefile() throws Exception {
    sourceFile = JFileDataStoreChooser.showOpenFile("shp", null);
    if (sourceFile == null) {
        return;
    }
    FileDataStore store = FileDataStoreFinder.getDataStore(sourceFile);
    featureSource = store.getFeatureSource();

    // Create a map context and add our shapefile to it
    map = new MapContent();
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(featureSource, style);
    map.layers().add(layer);

    // Create a JMapFrame with custom toolbar buttons
    JMapFrame mapFrame = new JMapFrame(map);
    mapFrame.enableToolBar(true);
    mapFrame.enableStatusBar(true);

    JToolBar toolbar = mapFrame.getToolBar();
    toolbar.addSeparator();
    toolbar.add(new JButton(new ValidateGeometryAction()));
    toolbar.add(new JButton(new ExportShapefileAction()));

    // Display the map frame. When it is closed the application will exit
    mapFrame.setSize(800, 600);
    mapFrame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:38,代码来源:CRSLab.java


示例11: Tissot

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
public Tissot(File file) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		ReferencedEnvelope gridBounds = layer.getBounds();
		Layer gridLayer = createGridLayer(style, gridBounds);
		mapContent.addLayer(gridLayer);
		Style pstyle = SLD.createPointStyle("circle", Color.red, Color.red, 1.0f,
				5.0f);
		Layer tissotLayer = createTissotLayer(pstyle, gridBounds);
		mapContent.addLayer(tissotLayer);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:Tissot.java


示例12: MapWithGrid

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
public MapWithGrid(File file) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		style = SLD.createSimpleStyle(featureSource.getSchema());
		layer = new FeatureLayer(featureSource, style);

		ReferencedEnvelope gridBounds = layer.getBounds();
		gridLayer = createGridLayer(style, gridBounds);
		mapContent.addLayer(layer);
		mapContent.addLayer(gridLayer);
		mapContent.addMapBoundsListener(this);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);

		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:29,代码来源:MapWithGrid.java


示例13: SaveMapAsImage

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
public SaveMapAsImage(File file, File raster) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		AbstractGridFormat format = GridFormatFinder.findFormat(raster);
		AbstractGridCoverage2DReader reader = format.getReader(raster);
		GridCoverage2D cov;
		try {
			cov = reader.read(null);
		} catch (IOException giveUp) {
			throw new RuntimeException(giveUp);
		}
		Style rasterStyle = createRGBStyle(cov);
		Layer rasterLayer = new GridReaderLayer(reader, rasterStyle);
		mapContent.addLayer(rasterLayer);

		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		mapContent.getViewport().setCoordinateReferenceSystem(
				DefaultGeographicCRS.WGS84);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:37,代码来源:SaveMapAsImage.java


示例14: viewCoverage

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
@Execute
public void viewCoverage() throws Exception {
    StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
    // RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
    // Style rasterStyle = SLD.wrapSymbolizers(sym);

    StyleBuilder sB = new StyleBuilder(sf);
    RasterSymbolizer rasterSym = sf.createRasterSymbolizer();

    ColorMap colorMap = sf.createColorMap();

    RenderedImage renderedImage = raster.getRenderedImage();
    double max = Double.NEGATIVE_INFINITY;
    double min = Double.POSITIVE_INFINITY;
    RectIter iter = RectIterFactory.create(renderedImage, null);
    do {
        do {
            double value = iter.getSampleDouble();
            if (value > max) {
                max = value;
            }
            if (value < min) {
                min = value;
            }
        } while( !iter.nextPixelDone() );
        iter.startPixels();
    } while( !iter.nextLineDone() );

    // red to blue
    Color fromColor = Color.blue;
    Color toColor = Color.red;
    Expression fromColorExpr = sB.colorExpression(new java.awt.Color(fromColor.getRed(), fromColor.getGreen(), fromColor
            .getBlue(), 255));
    Expression toColorExpr = sB.colorExpression(new java.awt.Color(toColor.getRed(), toColor.getGreen(), toColor.getBlue(),
            255));
    Expression fromExpr = sB.literalExpression(min);
    Expression toExpr = sB.literalExpression(max);

    ColorMapEntry entry = sf.createColorMapEntry();
    entry.setQuantity(fromExpr);
    entry.setColor(fromColorExpr);
    colorMap.addColorMapEntry(entry);

    entry = sf.createColorMapEntry();
    entry.setQuantity(toExpr);
    entry.setColor(toColorExpr);
    colorMap.addColorMapEntry(entry);

    rasterSym.setColorMap(colorMap);

    Style rasterStyle = SLD.wrapSymbolizers(rasterSym);

    // Set up a MapContext with the two layers
    final MapContext map = new DefaultMapContext();
    map.setTitle("Coverage Viewer");
    map.addLayer(raster, rasterStyle);

    // Create a JMapFrame with a menu to choose the display style for the
    final JMapFrame frame = new JMapFrame(map);
    frame.setSize(800, 600);
    frame.enableStatusBar(true);
    frame.enableTool(JMapFrame.Tool.ZOOM, JMapFrame.Tool.PAN, JMapFrame.Tool.RESET);
    frame.enableToolBar(true);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
        public void windowClosing( WindowEvent e ) {
            frame.setVisible(false);
        }
    });

    while( frame.isVisible() ) {
        Thread.sleep(300);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:75,代码来源:OmsCoverageViewer.java


示例15: displayShapefile

import org.geotools.swing.JMapFrame; //导入依赖的package包/类
/**
 * This method connects to the shapefile; retrieves information about
 * its features; creates a map frame to display the shapefile and adds
 * a custom feature selection tool to the toolbar of the map frame.
 */
public void displayShapefile(File file) throws Exception {
    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    featureSource = store.getFeatureSource();
    setGeometry();

    /*
     * Create the JMapFrame and set it to display the shapefile's features
     * with a default line and colour style
     */
    MapContent map = new MapContent();
    map.setTitle("Feature selection tool example");
    Style style = createDefaultStyle();
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);
    mapFrame = new JMapFrame(map);
    mapFrame.enableToolBar(true);
    mapFrame.enableStatusBar(true);

    /*
     * Before making the map frame visible we add a new button to its
     * toolbar for our custom feature selection tool
     */
    JToolBar toolBar = mapFrame.getToolBar();
    JButton btn = new JButton("Select");
    toolBar.addSeparator();
    toolBar.add(btn);

    /*
     * When the user clicks the button we want to enable
     * our custom feature selection tool. Since the only
     * mouse action we are intersted in is 'clicked', and
     * we are not creating control icons or cursors here,
     * we can just create our tool as an anonymous sub-class
     * of CursorTool.
     */
    btn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            mapFrame.getMapPane().setCursorTool(
                    new CursorTool() {

                        @Override
                        public void onMouseClicked(MapMouseEvent ev) {
                            selectFeatures(ev);
                        }
                    });
        }
    });

    /**
     * Finally, we display the map frame. When it is closed
     * this application will exit.
     */
    mapFrame.setSize(600, 600);
    mapFrame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:62,代码来源:SelectionLab.java



注:本文中的org.geotools.swing.JMapFrame类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FTPTransferType类代码示例发布时间:2022-05-22
下一篇:
Java PageId类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap