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


Java JXMapViewer类代码示例

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


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

示例1: paint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
public void paint(Graphics2D g, JXMapViewer jxMapViewer, int w, int h) {
	Settings settings = StaticSettings.INSTANCE;
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	g.setRenderingHint(RenderingHints.KEY_RENDERING,
			RenderingHints.VALUE_RENDER_QUALITY);

	Statistics stats = this.track.getStatistics();
	String text = DateFormat.getDateInstance()
			.format(new Date(Iterables.get(this.track.getTrackpoints(), 0)
					.getTime().longValue()))
			+ ": " + new DistanceFormatter( //$NON-NLS-1$
					com.github.pfichtner.jrunalyser.ui.format.DistanceFormatter.Type.SHORT)
					.format(stats.getDistance().convertTo(
							settings.getDistanceUnit()))
			+ " " //$NON-NLS-1$
			+ new DurationFormatter(Type.SHORT).format(stats.getDuration()
					.convertTo(settings.getTimeUnit()));
	drawTextBox(g, text, this.font, this.theme.getBgColor(),
			this.theme.getFgColor(), 10, 20);
}
 
开发者ID:pfichtner,项目名称:jrunalyzer,代码行数:22,代码来源:InfoBoxPainter.java

示例2: doPaint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
@Override
protected void doPaint(Graphics2D g, JXMapViewer map, int width, int height)
{
	if (renderer == null)
	{
		return;
	}

	Rectangle viewportBounds = map.getViewportBounds();

	g.translate(-viewportBounds.getX(), -viewportBounds.getY());

	for (W w : getWaypoints())
	{
		renderer.paintWaypoint(g, map, w);
	}

	g.translate(viewportBounds.getX(), viewportBounds.getY());

}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:21,代码来源:WaypointPainter.java

示例3: doPaint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
@Override
protected void doPaint(Graphics2D g, JXMapViewer map, int width, int height)
{
    Rectangle viewportBounds = map.getViewportBounds();

    g.translate(-viewportBounds.getX(), -viewportBounds.getY());

    Set<PlottableEntity> entities = getEntities();

    for(PlottableEntity entity : entities)
    {
        mRenderer.paintPlottableEntity(g, map, entity, true);
    }

    g.translate(viewportBounds.getX(), viewportBounds.getY());
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:17,代码来源:PlottableEntityPainter.java

示例4: paintRoute

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
/**
 * Paints a two-tone route from the entity's list of plottables (locations).
 * using black as a wider background route, and the entity's preferred color
 * as a narrower foreground route.
 */
private void paintRoute(Graphics2D graphics,
                        JXMapViewer viewer,
                        PlottableEntity entity)
{
    Set<Plottable> plottables = entity.getPlottables();

    if(plottables.size() > 1)
    {
        // Draw the route with a black background line
        graphics.setColor(Color.BLACK);
        graphics.setStroke(new BasicStroke(3));

        drawRoute(plottables, graphics, viewer);

        // Draw the route again, in the entity's preferred color
        graphics.setColor(entity.getColor());
        graphics.setStroke(new BasicStroke(1));

        drawRoute(plottables, graphics, viewer);
    }
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:27,代码来源:PlottableEntityRenderer.java

示例5: drawRoute

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
/**
 * Draws a route from a list of plottables
 */
private void drawRoute(Set<Plottable> plottables,
                       Graphics2D g,
                       JXMapViewer viewer)
{
    Point2D lastPoint = null;

    for(Plottable plottable : plottables)
    {
        // convert geo-coordinate to world bitmap pixel
        Point2D currentPoint = viewer.getTileFactory()
            .geoToPixel(plottable.getGeoPosition(), viewer.getZoom());

        if(lastPoint != null)
        {
            g.drawLine((int) lastPoint.getX(), (int) lastPoint.getY(),
                (int) currentPoint.getX(), (int) currentPoint.getY());
        }

        lastPoint = currentPoint;
    }
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:25,代码来源:PlottableEntityRenderer.java

示例6: drawStreet

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
private void drawStreet(Graphics2D g, JXMapViewer map, MapPath street) {
	int lastX = 0;
	int lastY = 0;

	boolean first = true;

	for (MapNode node : street.getNodes()) {
		GeoPosition position = nodeToPosition(node);

		// convert geo-coordinate to world bitmap pixel
		Point2D pt = map.getTileFactory().geoToPixel(position,
				map.getZoom());

		if (first) {
			first = false;
		} else {
			g.drawLine(lastX, lastY, (int) pt.getX(), (int) pt.getY());
		}

		lastX = (int) pt.getX();
		lastY = (int) pt.getY();
	}
}
 
开发者ID:TomTasche,项目名称:mapsracer,代码行数:24,代码来源:GraphPainter.java

示例7: calcMaxZoomLevel

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
public static int calcMaxZoomLevel(JXMapKit mapKit, Track track) {
	JXMapViewer mapViewer = mapKit.getMainMap();
	int mmw = mapViewer.getWidth();
	int mmh = mapViewer.getHeight();
	TileFactory tileFactory = mapViewer.getTileFactory();
	int maximumZoomLevel = tileFactory.getInfo().getMaximumZoomLevel();
	int minimumZoomLevel = tileFactory.getInfo().getMinimumZoomLevel();
	for (int i = maximumZoomLevel; i >= minimumZoomLevel; i--) {
		Rectangle2D tr = getBounds(track, i, tileFactory);
		if (tr.getWidth() > mmw || tr.getHeight() > mmh) {
			return i + 1;
		}
	}
	return minimumZoomLevel;
}
 
开发者ID:pfichtner,项目名称:jrunalyzer,代码行数:16,代码来源:GeoUtil.java

示例8: paint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
@Override
public void paint(Graphics2D gd, JXMapViewer t, int i, int i1) {
	if (selectedArea != null) {
		Rectangle drawArea = createDrawArea(selectedArea, map.getZoom());

		if (!drawArea.isEmpty()) {
			if (drawArea.contains(map.getBounds()))
				drawArea = map.getBounds();			

			gd.setColor(regionColor);
			gd.fillRect(drawArea.x, drawArea.y, drawArea.width, drawArea.height);

			gd.setColor(borderColor);
			gd.drawRect(drawArea.x, drawArea.y, drawArea.width, drawArea.height);
		}
	}
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:18,代码来源:BBoxSelectionPainter.java

示例9: paint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
@Override
public void paint(Graphics2D g, JXMapViewer map, int w, int h)
{
	g = (Graphics2D) g.create();

	// convert from viewport to world bitmap
	Rectangle rect = map.getViewportBounds();
	g.translate(-rect.x, -rect.y);

	if (antiAlias)
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	// do the drawing
	g.setColor(Color.BLACK);
	g.setStroke(new BasicStroke(4));

	drawRoute(g, map);

	// do the drawing again
	g.setColor(color);
	g.setStroke(new BasicStroke(2));

	drawRoute(g, map);

	g.dispose();
}
 
开发者ID:klamann,项目名称:maps4cim,代码行数:27,代码来源:RoutePainter.java

示例10: drawRoute

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
/**
 * @param g the graphics object
 * @param map the map
 */
private void drawRoute(Graphics2D g, JXMapViewer map)
{
	int lastX = 0;
	int lastY = 0;
	
	boolean first = true;
	
	for (GeoPosition gp : track)
	{
		// convert geo-coordinate to world bitmap pixel
		Point2D pt = map.getTileFactory().geoToPixel(gp, map.getZoom());

		if (first)
		{
			first = false;
		}
		else
		{
			g.drawLine(lastX, lastY, (int) pt.getX(), (int) pt.getY());
		}
		
		lastX = (int) pt.getX();
		lastY = (int) pt.getY();
	}
}
 
开发者ID:klamann,项目名称:maps4cim,代码行数:30,代码来源:RoutePainter.java

示例11: main

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
/**
 * @param args the program args (ignored)
 */
public static void main(String[] args)
{
	JXMapViewer mapViewer = new JXMapViewer();

	// Create a TileFactoryInfo for OpenStreetMap
	TileFactoryInfo info = new OSMTileFactoryInfo();
	DefaultTileFactory tileFactory = new DefaultTileFactory(info);
	mapViewer.setTileFactory(tileFactory);

	// Use 8 threads in parallel to load the tiles
	tileFactory.setThreadPoolSize(8);

	// Set the focus
	GeoPosition frankfurt = new GeoPosition(50.11, 8.68);

	mapViewer.setZoom(7);
	mapViewer.setAddressLocation(frankfurt);

	// Display the viewer in a JFrame
	JFrame frame = new JFrame("JXMapviewer2 Example 1");
	frame.getContentPane().add(mapViewer);
	frame.setSize(800, 600);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
}
 
开发者ID:klamann,项目名称:maps4cim,代码行数:29,代码来源:Sample1.java

示例12: imprimir

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
private void imprimir(boolean visualizar) {
	try {

		// Testes para verificar modo de imprimir mapa.

		JXMapViewer mp2 = mapa.getMainMap();
		// Container cnt = mp2.getParent();

		Graphics gr = mp2.getGraphics();
		gr.drawRect(10, 10, 100, 100);

		HashMap<Object, Object> hParam = new HashMap<Object, Object>();
		hParam.put("MAPA", img);

		/*
		 * FPrinterJob dlGr = new FPrinterJob( "relatorios/Mapa.jasper",
		 * "Mapa", null, this, hParam, con );
		 * 
		 * if ( visualizar == TYPE_PRINT.VIEW ) { dlGr.setVisible( true ); } else {
		 * JasperPrintManager.printReport( dlGr.getRelatorio(), true ); }
		 */
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:cams7,项目名称:erp,代码行数:27,代码来源:FMapa.java

示例13: paintWaypoint

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
@Override
public void paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint w)
{
	if (img == null)
		return;

	Point2D point = map.getTileFactory().geoToPixel(w.getPosition(), map.getZoom());
	
	int x = (int)point.getX() -img.getWidth() / 2;
	int y = (int)point.getY() -img.getHeight();
	
	g.drawImage(img, x, y, null);
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:14,代码来源:DefaultWaypointRenderer.java

示例14: getMapGeoBounds

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
/**
 * Gets the bounds as a set of two <code>GeoPosition</code> objects.
 * @param mapViewer The map viewer.
 * @return Returns the set of two <code>GeoPosition</code> objects that represent the north west and south east
 * corners of the map.
 */
private static Set<GeoPosition> getMapGeoBounds(JXMapViewer mapViewer)
{
	Set<GeoPosition> set = new HashSet<GeoPosition>();
	TileFactory tileFactory = mapViewer.getTileFactory();
	int zoom = mapViewer.getZoom();
	Rectangle2D bounds = mapViewer.getViewportBounds();
	Point2D pt = new Point2D.Double(bounds.getX(), bounds.getY());
	set.add(tileFactory.pixelToGeo(pt, zoom));
	pt = new Point2D.Double(bounds.getX() + bounds.getWidth(), bounds.getY() + bounds.getHeight());
	set.add(tileFactory.pixelToGeo(pt, zoom));
	return set;
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:19,代码来源:GeoUtil.java

示例15: initialize

import org.jdesktop.swingx.JXMapViewer; //导入依赖的package包/类
public void initialize(NodeManager nodeManager, Map<String, Car> allCars) {
	this.nodeManager = nodeManager;

	mapViewer = new JXMapViewer();

	TileFactoryInfo info = new OSMTileFactoryInfo();
	DefaultTileFactory tileFactory = new DefaultTileFactory(info);
	tileFactory.setThreadPoolSize(8);

	mapViewer.setTileFactory(tileFactory);

	mapViewer.setAddressLocation(new GeoPosition(48.14650327493638,
			16.329095363616943));

	mapViewer.setZoom(3);

	CarPainter carPainter = new CarPainter();
	GraphPainter graphPainter = new GraphPainter();
	ClusterPainter clusterPainter = new ClusterPainter();

	CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>();
	painter.addPainter(carPainter);
	if (MapsRacer.DEBUG) {
		painter.addPainter(graphPainter);
		painter.addPainter(clusterPainter);
	}

	carPainter.initialize(allCars);
	graphPainter.initialize(nodeManager.getStreets());
	clusterPainter.initialize(nodeManager.getClusters());

	mapViewer.setOverlayPainter(painter);

	if (MapsRacer.DEBUG) {
		MouseInputListener mouseListener = new PanMouseInputListener(
				mapViewer);
		mapViewer.addMouseListener(mouseListener);
		mapViewer.addMouseMotionListener(mouseListener);
	}
}
 
开发者ID:TomTasche,项目名称:mapsracer,代码行数:41,代码来源:MapManager.java


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