当前位置: 首页>>代码示例>>Java>>正文


Java GTRenderer类代码示例

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


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

示例1: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
private static GTRenderer getRenderer(File shapeFilesFolder) {
    File[] shpFiles = shapeFilesFolder.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".shp");
        }
    });

    MapContent mapContent = new MapContent();
    for (File shpFile : shpFiles) {
        try {
            SimpleFeatureCollection readFC = NwwUtilities.readAndReproject(shpFile.getAbsolutePath());
            ReferencedEnvelope tmpBounds = readFC.getBounds();
            if (tmpBounds.getWidth() == 0 || tmpBounds.getHeight() == 0) {
                System.err.println("Ignoring: " + shpFile);
                continue;
            }
            // if (bounds == null) {
            // bounds = new ReferencedEnvelope(tmpBounds);
            // } else {
            // bounds.expandToInclude(tmpBounds);
            // }
            Style style = SldUtilities.getStyleFromFile(shpFile);
            if (style == null)
                style = SLD.createSimpleStyle(readFC.getSchema());

            FeatureLayer layer = new FeatureLayer(readFC, style);
            mapContent.addLayer(layer);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mapContent);
    return renderer;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:37,代码来源:RasterizedShapefilesFolderNwwLayer.java

示例2: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
private static GTRenderer getRenderer( File rasterFile ) {

        AbstractGridFormat format = GridFormatFinder.findFormat(rasterFile);
        AbstractGridCoverage2DReader coverageReader = format.getReader(rasterFile);

        MapContent mapContent = new MapContent();
        try {

            Style rasterStyle = SldUtilities.getStyleFromFile(rasterFile);
            if (rasterStyle == null) {
                RasterSymbolizer sym = SldUtilities.sf.getDefaultRasterSymbolizer();
                rasterStyle = SLD.wrapSymbolizers(sym);
            }

            GridReaderLayer layer = new GridReaderLayer(coverageReader, rasterStyle);
            mapContent.addLayer(layer);
            mapContent.getViewport().setCoordinateReferenceSystem(CrsUtilities.WGS84);
        } catch (Exception e) {
            e.printStackTrace();
        }
        GTRenderer renderer = new StreamingRenderer();
        renderer.setMapContent(mapContent);
        return renderer;
    }
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:25,代码来源:GridCoverageNwwLayer.java

示例3: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Gets the renderer, creating a default one if required.
 *
 * @return the renderer
 */
public GTRenderer getRenderer() {
    if (renderer == null) {
        doSetRenderer(new StreamingRenderer());
    }
    return renderer;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:12,代码来源:SLDMapPane.java

示例4: SwtMapFrame

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Constructs a new {@code JMapFrame} object with specified context and renderer
 * 
 * @param showLayerTable
 * @param showStatusBar
 *
 * @param context
 *            the map context with layers to be displayed
 * @param renderer
 *            the renderer to be used
 */
public SwtMapFrame(final boolean showMenu, final boolean showToolBar, final boolean showStatusBar,
		final boolean showLayerTable, final MapContent content, final GTRenderer renderer) {
	super(null);
	this.showLayerTable = showLayerTable;
	this.content = content;
	this.renderer = renderer;

	// drawAction = new DrawShapeAction();
	infoAction = new InfoAction();
	panAction = new PanAction();
	resetAction = new ResetAction();
	zoominAction = new ZoomInAction();
	zoomoutAction = new ZoomOutAction();
	openShapeAction = new OpenShapefileAction();
	openCoverageAction = new OpenGeotiffAction();

	toolSet = new HashSet<Tool>();
	toolSet.addAll(EnumSet.allOf(Tool.class));
	if (showToolBar) {
		addToolBar(SWT.FLAT | SWT.WRAP);
	}
	if (showStatusBar) {
		addStatusLine();
	}
	if (showMenu) {
		addMenuBar();
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:41,代码来源:SwtMapFrame.java

示例5: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
private static GTRenderer getRenderer( SimpleFeatureCollection featureCollectionLL, Style style ) {
    MapContent mapContent = new MapContent();
    try {
        FeatureLayer layer = new FeatureLayer(featureCollectionLL, style);
        mapContent.addLayer(layer);
    } catch (Exception e) {
        e.printStackTrace();
    }
    GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mapContent);
    return renderer;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:13,代码来源:RasterizedFeatureCollectionLayer.java

示例6: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
private static GTRenderer getRenderer( ASpatialDb db, String tableName, int featureLimit, Style style ) {
    MapContent mapContent = new MapContent();

    // read data and convert it to featurecollection
    try {
        long t1 = System.currentTimeMillis();
        System.out.println("STARTED READING: " + tableName);

        String databasePath = db.getDatabasePath();
        File dbFile = new File(databasePath);
        File parentFolder = dbFile.getParentFile();
        if (style == null) {
            File sldFile = new File(parentFolder, tableName + ".sld");
            if (sldFile.exists()) {
                style = SldUtilities.getStyleFromFile(sldFile);
            }
        }

        DefaultFeatureCollection fc = SpatialDbsImportUtils.tableToFeatureFCollection(db, tableName, featureLimit,
                NwwUtilities.GPS_CRS_SRID);
        long t2 = System.currentTimeMillis();
        System.out.println("FINISHED READING: " + tableName + " -> " + ((t2 - t1) / 1000) + "sec");
        if (style == null) {
            style = SLD.createSimpleStyle(fc.getSchema());
        }
        FeatureLayer layer = new FeatureLayer(fc, style);

        long t3 = System.currentTimeMillis();
        System.out.println("FINISHED BUILDING: " + tableName + " -> " + ((t3 - t2) / 1000) + "sec");

        mapContent.addLayer(layer);
    } catch (Exception e) {
        e.printStackTrace();
    }
    GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mapContent);
    return renderer;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:39,代码来源:RasterizedSpatialiteLayer.java

示例7: SwtMapPane

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Constructor - creates an instance of JMapPane with the given renderer and
 * map context.
 *
 * @param renderer
 *            a renderer object
 * @param content
 *            an instance of MapContext
 */
public SwtMapPane(final Composite parent, final int style, final GTRenderer renderer, final MapContent content) {
	super(parent, style);
	white = getDisplay().getSystemColor(SWT.COLOR_WHITE);
	yellow = getDisplay().getSystemColor(SWT.COLOR_YELLOW);

	addListener(SWT.Paint, this);
	addListener(SWT.MouseDown, this);
	addListener(SWT.MouseUp, this);

	imageOrigin = new Point(0, 0);

	acceptRepaintRequests = true;
	redrawBaseImage = true;
	clearLabelCache = false;

	setRenderer(renderer);
	setMapContent(content);

	toolManager = new MapToolManager(this);

	this.addMouseListener(toolManager);
	this.addMouseMoveListener(toolManager);
	this.addMouseWheelListener(toolManager);

	/*
	 * Listen for mouse entered events to (re-)set the current tool cursor,
	 * otherwise the cursor seems to default to the standard cursor
	 * sometimes (at least on OSX)
	 */
	this.addMouseMoveListener(event -> {
		if (mouseDown) {
			endX = event.x;
			endY = event.y;
			isDragging = true;
			if (!isDisposed())
				redraw();
		}
	});

	addControlListener(new ControlAdapter() {

		@Override
		public void controlResized(final ControlEvent e) {
			curPaintArea = getVisibleRect();
			doSetDisplayArea(SwtMapPane.this.content.getViewport().getBounds());
		}
	});

	cursorToolColor = getDisplay().getSystemColor(SWT.COLOR_YELLOW);
	cursorToolLineWidth = 2;
	cursorToolLineStyle = SWT.LINE_SOLID;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:62,代码来源:SwtMapPane.java

示例8: archieveRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
@Override
protected GTRenderer archieveRenderer() {
    return new StreamingRenderer();
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:5,代码来源:AsyncMapTilesCache.java

示例9: archieveRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
protected GTRenderer archieveRenderer() {
    return renderer;
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:4,代码来源:MapTilesCache.java

示例10: geoToolsBaseSettingsTest

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
@Test
public void geoToolsBaseSettingsTest() throws InterruptedException, FactoryException, ParseException {
    // cartesian view point
    Point2D.Double viewPoint = new Point2D.Double(2 * 111313.83923667614, 0);

    JFrame fr = new JFrame();
    fr.setTitle("geoToolsBaseSettingsTest");
    Container container = fr.getContentPane();
    container.setLayout(new BorderLayout());

    // Prepare styles
    // Create line symbolizer
    LineSymbolizer lineSymb = sb.createLineSymbolizer(Color.green, 1);

    Style lineStyle = sb.createStyle(lineSymb);

    ReferencedEnvelope aoi = new ReferencedEnvelope(new Rectangle2D.Double(viewPoint.x - 100, viewPoint.y - 100, 4 * 111000, 200), projectedCrs); // meters

    SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
    typeBuilder.setCRS(dataCrs);
    typeBuilder.setName("Line type");
    typeBuilder.add("graphicRepresentation", LineString.class);
    typeBuilder.add("name", String.class);
    SimpleFeatureType featureType = typeBuilder.buildFeatureType();

    List<SimpleFeature> lst = new ArrayList<>();
    
    Object[] attrs = new Object[2];
    int lNo = 0;
    for (LineString line : lineStrings) {
        attrs[0] = line;
        String lStringId = String.valueOf(lNo++);
        attrs[1] = "line " + lStringId;
        SimpleFeature feature = SimpleFeatureBuilder.build(featureType, attrs, lStringId);
        lst.add(feature);
    }
    
    FeatureCollection fcollection = new ListFeatureCollection(featureType, lst);
    
    final MapContent mainContent = new MapContent(projectedCrs);
    mainContent.getViewport().setBounds(aoi);

    Layer layer1 = new FeatureLayer(fcollection, lineStyle, "Main layer");
    mainContent.addLayer(layer1);

    final GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mainContent);

    final AffineTransform transform = new AffineTransform();
    transform.scale(8e-4, 8e-4);
    transform.translate(-viewPoint.x, -viewPoint.y);
    JPanel panel = new JPanel() {

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Dimension size = getSize();
            Graphics2D g2d = (Graphics2D) g;
            g2d.translate(size.width / 2, size.height / 2);
            Rectangle screenArea = new Rectangle(-200, -200, 400, 400);
            renderer.paint(g2d, new Rectangle(-200, -200, 400, 400), mainContent.getViewport().getBounds(), transform);
            //renderer.paint(g2d, screenArea, mainContext.getLayerBounds(), transform);
            g2d.draw(screenArea);
        }
    };
    container.add(panel, BorderLayout.CENTER);
    fr.setSize(600, 600);
    fr.setVisible(true);
    Thread.sleep(1000);
    fr.dispose();
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:72,代码来源:MapGraphicTest.java

示例11: makeLevels

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
private static LevelSet makeLevels( File imsf, GTRenderer renderer, Integer tileSize, Color colorToMakeTransparent ) throws MalformedURLException {
    AVList params = new AVListImpl();
    if (tileSize == null || tileSize < 256) {
        tileSize = TILESIZE;
    }

    int finalTileSize = tileSize;

    String tilesPart = "-tiles";
    String cacheRelativePath = "imagemosaics/" + imsf.getName() + tilesPart;

    String urlString = imsf.toURI().toURL().toExternalForm();
    params.setValue(AVKey.URL, urlString);
    params.setValue(AVKey.TILE_WIDTH, finalTileSize);
    params.setValue(AVKey.TILE_HEIGHT, finalTileSize);
    params.setValue(AVKey.DATA_CACHE_NAME, cacheRelativePath);
    params.setValue(AVKey.SERVICE, "*");
    params.setValue(AVKey.DATASET_NAME, "*");

    final String imageFormat = "png";
    params.setValue(AVKey.FORMAT_SUFFIX, "." + imageFormat);
    params.setValue(AVKey.NUM_LEVELS, 22);
    params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
    params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle.fromDegrees(22.5d), Angle.fromDegrees(45d)));
    params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
    File cacheRoot = CacheUtils.getCacheRoot();
    final File cacheFolder = new File(cacheRoot, cacheRelativePath);
    if (!cacheFolder.exists()) {
        cacheFolder.mkdirs();
    }

    params.setValue(AVKey.TILE_URL_BUILDER, new TileUrlBuilder(){

        public URL getURL( Tile tile, String altImageFormat ) throws MalformedURLException {
            int zoom = tile.getLevelNumber() + 3;
            Sector sector = tile.getSector();
            double north = sector.getMaxLatitude().degrees;
            double south = sector.getMinLatitude().degrees;
            double east = sector.getMaxLongitude().degrees;
            double west = sector.getMinLongitude().degrees;
            double centerX = west + (east - west) / 2.0;
            double centerY = south + (north - south) / 2.0;
            int[] tileNumber = NwwUtilities.getTileNumber(centerY, centerX, zoom);
            int x = tileNumber[0];
            int y = tileNumber[1];

            Rectangle imageBounds = new Rectangle(0, 0, finalTileSize, finalTileSize);
            BufferedImage image = new BufferedImage(imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_RGB);
            Graphics2D gr = image.createGraphics();
            gr.setPaint(Color.WHITE);
            gr.fill(imageBounds);
            gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

            try {
                synchronized (renderer) {
                    renderer.paint(gr, imageBounds,
                            new ReferencedEnvelope(west, east, south, north, DefaultGeographicCRS.WGS84));
                    File tileImageFolderFile = new File(cacheFolder, zoom + File.separator + x);
                    if (!tileImageFolderFile.exists()) {
                        tileImageFolderFile.mkdirs();
                    }
                    File imgFile = new File(tileImageFolderFile, y + ".png");
                    if (!imgFile.exists()) {
                        if (colorToMakeTransparent != null) {
                            image = ImageUtilities.makeColorTransparent(image, colorToMakeTransparent);
                        }
                        ImageIO.write(image, "png", imgFile);
                    }
                    return imgFile.toURI().toURL();
                }
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    });

    return new LevelSet(params);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:80,代码来源:GridCoverageNwwLayer.java

示例12: render

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
public static BufferedImage render( InternalMap map, Integer maxWidth, Integer maxHeight )
{
    MapContent mapContent = new MapContent();

    // Convert map objects to features, and add them to the map
    
    for ( InternalMapLayer mapLayer : map.getLayers() )
    {
        for ( InternalMapObject mapObject : mapLayer.getMapObjects() )
        {
            mapContent.addLayer( createFeatureLayerFromMapObject( mapObject ) );
        }
    }

    // Create a renderer for this map
    
    GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent( mapContent );

    // Calculate image height
    
    ReferencedEnvelope mapBounds = mapContent.getMaxBounds();
    double widthToHeightFactor = mapBounds.getSpan( 0 ) / mapBounds.getSpan( 1 );
    int[] widthHeight = getWidthHeight( maxWidth, maxHeight, LegendSet.LEGEND_TOTAL_WIDTH, TITLE_HEIGHT, widthToHeightFactor );
    
    //LegendSet.LEGEND_TOTAL_WIDTH;
    
    Rectangle imageBounds = new Rectangle( 0, 0, widthHeight[0], widthHeight[1] );

    // Create an image and get the graphics context from it
    
    BufferedImage image = new BufferedImage( imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_ARGB );
    Graphics2D graphics = (Graphics2D) image.getGraphics();

    graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    
    renderer.paint( graphics, imageBounds, mapBounds );

    mapContent.dispose();
    
    return image;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:43,代码来源:MapUtils.java

示例13: SLDMapPane

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Creates a new map pane. Any or all arguments may be {@code null}
 *
 * @param content the map content containing the layers to display
 * @param executor the rendering executor to manage drawing
 * @param renderer the renderer to use for drawing layers
 */
public SLDMapPane(MapContent content, RenderingExecutor executor, GTRenderer renderer) {
    super(content, executor);
    doSetRenderer(renderer);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:12,代码来源:SLDMapPane.java

示例14: setRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Sets the renderer to be used by this map pane.
 *
 * @param renderer the renderer to use
 */
public void setRenderer(GTRenderer renderer) {
    doSetRenderer(renderer);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:9,代码来源:SLDMapPane.java

示例15: getRenderer

import org.geotools.renderer.GTRenderer; //导入依赖的package包/类
/**
 * Get the renderer being used by this frame. Returns {@code null} if no renderer was set via the constructor or
 * {@linkplain #setRenderer}.
 *
 * @return the current {@code GTRenderer} object
 */
public GTRenderer getRenderer() {
	return mapPane.getRenderer();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:10,代码来源:SwtMapFrame.java


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