本文整理汇总了Java中org.jdesktop.swingx.OSMTileFactoryInfo类的典型用法代码示例。如果您正苦于以下问题:Java OSMTileFactoryInfo类的具体用法?Java OSMTileFactoryInfo怎么用?Java OSMTileFactoryInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OSMTileFactoryInfo类属于org.jdesktop.swingx包,在下文中一共展示了OSMTileFactoryInfo类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的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);
}
示例2: initialize
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的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);
}
}
示例3: getCachedTileFactory
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的package包/类
protected TileFactory getCachedTileFactory() {
// Create a TileFactoryInfo for OpenStreetMap
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
tileFactory.setThreadPoolSize(8);
// Setup local file cache
File cache = new Cache().getCacheDir();
LocalResponseCache.installResponseCache(info.getBaseURL(), cache, false);
return tileFactory;
}
示例4: init
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的package包/类
private void init()
{
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
/**
* Set the entity painter as the overlay painter and register this panel
* to receive new messages (plots)
*/
mMapViewer.setOverlayPainter(mMapPainter);
mMapService.addListener(this);
/**
* Map image source
*/
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
mMapViewer.setTileFactory(tileFactory);
/**
* Defines how many threads will be used to fetch the background map
* tiles (graphics)
*/
tileFactory.setThreadPoolSize(8);
/**
* Set initial location and zoom for the map upon display
*/
GeoPosition syracuse = new GeoPosition(43.048, -76.147);
int zoom = 7;
MapViewSetting view = mSettingsManager.getMapViewSetting("Default", syracuse, zoom);
mMapViewer.setAddressLocation(view.getGeoPosition());
mMapViewer.setZoom(view.getZoom());
/**
* Add a mouse adapter for panning and scrolling
*/
MapMouseListener listener = new MapMouseListener(mMapViewer, mSettingsManager);
mMapViewer.addMouseListener(listener);
mMapViewer.addMouseMotionListener(listener);
/* Map zoom listener */
mMapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mMapViewer));
/* Keyboard panning listener */
mMapViewer.addKeyListener(new PanKeyListener(mMapViewer));
/**
* Add a selection listener
*/
SelectionAdapter sa = new SelectionAdapter(mMapViewer);
mMapViewer.addMouseListener(sa);
mMapViewer.addMouseMotionListener(sa);
/**
* Map component
*/
add(mMapViewer, "span");
}
示例5: main
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的package包/类
/**
* @param args the program args (ignored)
*/
public static <T> void main(String[] args)
{
JXMapViewer mapViewer = new JXMapViewer();
// Create a TileFactoryInfo for OpenStreetMap
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
tileFactory.setThreadPoolSize(8);
mapViewer.setTileFactory(tileFactory);
GeoPosition frankfurt = new GeoPosition(50, 7, 0, 8, 41, 0);
GeoPosition wiesbaden = new GeoPosition(50, 5, 0, 8, 14, 0);
GeoPosition mainz = new GeoPosition(50, 0, 0, 8, 16, 0);
GeoPosition darmstadt = new GeoPosition(49, 52, 0, 8, 39, 0);
GeoPosition offenbach = new GeoPosition(50, 6, 0, 8, 46, 0);
// Set the focus
mapViewer.setZoom(10);
mapViewer.setAddressLocation(frankfurt);
// Create a track from the geo-positions
List<GeoPosition> track = Arrays.asList(frankfurt, wiesbaden, mainz, darmstadt, offenbach);
RoutePainter routePainter = new RoutePainter(track);
// Create waypoints from the geo-positions
Set<Waypoint> waypoints = new HashSet<Waypoint>(Arrays.asList(
new DefaultWaypoint(frankfurt),
new DefaultWaypoint(wiesbaden),
new DefaultWaypoint(mainz),
new DefaultWaypoint(darmstadt),
new DefaultWaypoint(offenbach)));
// Create a waypoint painter that takes all the waypoints
WaypointPainter<Waypoint> waypointPainter = new WaypointPainter<Waypoint>();
waypointPainter.setWaypoints(waypoints);
// Create a compound painter that uses both the route-painter and the waypoint-painter
List<Painter<JXMapViewer>> painters = new ArrayList<Painter<JXMapViewer>>();
painters.add(routePainter);
painters.add(waypointPainter);
CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
mapViewer.setOverlayPainter(painter);
// Display the viewer in a JFrame
JFrame frame = new JFrame("JXMapviewer2 Example 2");
frame.getContentPane().add(mapViewer);
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
示例6: main
import org.jdesktop.swingx.OSMTileFactoryInfo; //导入依赖的package包/类
/**
* @param args the program args (ignored)
*/
public static void main(String[] args)
{
// Create a TileFactoryInfo for OpenStreetMap
TileFactoryInfo info = new OSMTileFactoryInfo();
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
tileFactory.setThreadPoolSize(8);
// Setup local file cache
File cacheDir = new File(System.getProperty("user.home") + File.separator + ".jxmapviewer2");
LocalResponseCache.installResponseCache(info.getBaseURL(), cacheDir, false);
// Setup JXMapViewer
JXMapViewer mapViewer = new JXMapViewer();
mapViewer.setTileFactory(tileFactory);
GeoPosition frankfurt = new GeoPosition(50.11, 8.68);
// Set the focus
mapViewer.setZoom(7);
mapViewer.setAddressLocation(frankfurt);
// Add interactions
MouseInputListener mia = new PanMouseInputListener(mapViewer);
mapViewer.addMouseListener(mia);
mapViewer.addMouseMotionListener(mia);
mapViewer.addMouseListener(new CenterMapListener(mapViewer));
mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mapViewer));
mapViewer.addKeyListener(new PanKeyListener(mapViewer));
// Add a selection painter
SelectionAdapter sa = new SelectionAdapter(mapViewer);
SelectionPainter sp = new SelectionPainter(sa);
mapViewer.addMouseListener(sa);
mapViewer.addMouseMotionListener(sa);
mapViewer.setOverlayPainter(sp);
// Display the viewer in a JFrame
JFrame frame = new JFrame("JXMapviewer2 Example 3");
frame.setLayout(new BorderLayout());
frame.add(new JLabel("Use left mouse button to pan, mouse wheel to zoom and right mouse to select"), BorderLayout.NORTH);
frame.add(mapViewer);
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}