本文整理汇总了Java中org.mapsforge.map.rendertheme.ExternalRenderTheme类的典型用法代码示例。如果您正苦于以下问题:Java ExternalRenderTheme类的具体用法?Java ExternalRenderTheme怎么用?Java ExternalRenderTheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExternalRenderTheme类属于org.mapsforge.map.rendertheme包,在下文中一共展示了ExternalRenderTheme类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadExternalRenderTheme
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
protected void loadExternalRenderTheme(File xmlRenderThemeFile) throws FileNotFoundException {
XmlRenderThemeMenuCallback callBack = new XmlRenderThemeMenuCallback() {
@Override
public Set<String> getCategories(XmlRenderThemeStyleMenu styleMenu) {
renderThemeStyleMenu = styleMenu;
String id = styleMenu.getDefaultValue();
XmlRenderThemeStyleLayer baseLayer = styleMenu.getLayer(id);
Set<String> result = baseLayer.getCategories();
for (XmlRenderThemeStyleLayer overlay : baseLayer.getOverlays()) {
LOG.trace("Overlay " + overlay.getId() + " enabled: " + overlay.isEnabled());
if (overlay.isEnabled()) {
result.addAll(overlay.getCategories());
}
}
return result;
}
};
this.xmlRenderTheme = new ExternalRenderTheme(xmlRenderThemeFile, callBack);
}
示例2: validRenderThemeTest
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
@Test
public void validRenderThemeTest() throws SAXException, ParserConfigurationException, IOException {
XmlRenderTheme xmlRenderTheme = new ExternalRenderTheme(new File(RENDER_THEME_PATH));
RenderTheme renderTheme = RenderThemeHandler.getRenderTheme(new DummyGraphicAdapter(), xmlRenderTheme);
Assert.assertEquals(3, renderTheme.getLevels());
renderTheme.scaleStrokeWidth(12.34f);
renderTheme.scaleTextSize(56.78f);
RenderCallback renderCallback = new DummyRenderCallback();
List<Tag> closedWayTags = Arrays.asList(new Tag("amenity", "parking"));
List<Tag> linearWayTags = Arrays.asList(new Tag("highway", "primary"), new Tag("oneway", "yes"));
List<Tag> nodeTags = Arrays.asList(new Tag("place", "city"), new Tag("highway", "turning_circle"));
for (byte zoomLevel = 0; zoomLevel < 25; ++zoomLevel) {
renderTheme.matchClosedWay(renderCallback, closedWayTags, zoomLevel);
renderTheme.matchLinearWay(renderCallback, linearWayTags, zoomLevel);
renderTheme.matchNode(renderCallback, nodeTags, zoomLevel);
}
renderTheme.destroy();
}
示例3: onStart
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
// warp to 'unter den linden'
mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
tileLayer.setTextScale(1.5f);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE0)), false, false);
try {
tileLayer.setXmlRenderTheme(new ExternalRenderTheme(new File(THEMEFILE))); // set a different render theme
}
catch (FileNotFoundException ignore) {
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER); // fallback if not founr
}
mapView.getLayerManager().getLayers().add(tileLayer);
mapView.getLayerManager().getLayers().add( // add a grid around each tile
new TileGridLayer(AndroidGraphicFactory.INSTANCE, mapView.getModel().displayModel));
mapView.getLayerManager().getLayers().add( // add text to show x/y/z of each tile
new TileCoordinatesLayer(AndroidGraphicFactory.INSTANCE, mapView.getModel().displayModel));
}
示例4: getRenderThemeFuture
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
private synchronized RenderThemeFuture getRenderThemeFuture(String themeName) throws FileNotFoundException {
if (RENDER_THEME_FUTURE_TABLE.containsKey(themeName)) {
return RENDER_THEME_FUTURE_TABLE.get(themeName);
} else {
String themePath = String.format("res/themes/%s/theme.xml", themeName);
XmlRenderTheme theme = new ExternalRenderTheme(themePath);
RenderThemeFuture rtf = new RenderThemeFuture(GRAPHIC_FACTORY, theme, DISPLAY_MODEL);
RENDER_THEME_FUTURE_TABLE.put(themeName, rtf);
new Thread(rtf).start();
return rtf;
}
}
示例5: initialize
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
public static boolean initialize(String locationOfMapFile,String renderThemeAddr, Context _context) {
Log.i(TAG, "Initilizing started");
mapFilePath = locationOfMapFile;
androidGraphicFactory = AndroidGraphicFactory.INSTANCE;
mapFile = new File(mapFilePath);
displayModel = new DisplayModel();
mapViewPosition = new MapViewPosition(displayModel);
mapDataStore = new MapFile(mapFile);
displayModel.setFixedTileSize(256);
TileCache tileCache = AndroidUtil.createTileCache(context, "111", 256, 1.0f, 1d);
// TileCache tileCache = null;
databaseRenderer = new DatabaseRenderer(mapDataStore, androidGraphicFactory, tileCache);
context = _context;
try {
xmlRenderTheme = new ExternalRenderTheme(new File(renderThemeAddr ));
Log.i(TAG, "xmlRenderTheme initialized successfully");
}
catch(Throwable e)
{
Log.i(TAG, "xmlRenderTheme error initializing ");
e.printStackTrace();
}
renderThemeFuture = new RenderThemeFuture(AndroidGraphicFactory.INSTANCE, xmlRenderTheme, displayModel);
new Thread(renderThemeFuture).run();
Log.i(TAG, "Mapsforge Initializing Ended");
return true;
}
示例6: initialize
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
@Override
public void initialize() throws MapSourceInitializationException {
xmlRenderThemeFileName = xmlRenderThemeFileName.trim();
// The custom map xml file used for loading this map
MapSourceLoaderInfo loaderInfo = getLoaderInfo();
File mapSourceXmlDir = null;
if (loaderInfo != null) {
File mapSourceXmlFile = this.getLoaderInfo().getSourceFile();
mapSourceXmlDir = mapSourceXmlFile.getParentFile();
}
this.mapFile = Utilities.findFile(mapFileName, mapSourceXmlDir, DirectoryManager.currentDir,
DirectoryManager.mapSourcesDir, DirectoryManager.userAppDataDir);
if (mapFile == null) {
JOptionPane.showMessageDialog(null, "Unable to find map file \"" + mapFileName + "\"",
I18nUtils.localizedStringForKey("Error"), JOptionPane.ERROR_MESSAGE);
return;
}
if (xmlRenderThemeFileName.length() > 0) {
File renderFile = Utilities.findFile(xmlRenderThemeFileName, mapSourceXmlDir, DirectoryManager.currentDir,
DirectoryManager.mapSourcesDir, DirectoryManager.userAppDataDir);
if (renderFile == null) {
JOptionPane.showMessageDialog(null, "Unable to find xmlRenderTheme file \"" + xmlRenderThemeFileName
+ "\"", I18nUtils.localizedStringForKey("Error"), JOptionPane.ERROR_MESSAGE);
return;
}
try {
this.xmlRenderTheme = new ExternalRenderTheme(renderFile);
} catch (FileNotFoundException e) {
log.error("", e);
return;
}
}
super.initialize();
}
示例7: verifyInvalid
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
private static void verifyInvalid(String pathname) throws ParserConfigurationException, IOException {
XmlRenderTheme xmlRenderTheme = new ExternalRenderTheme(new File(pathname));
try {
RenderThemeHandler.getRenderTheme(new DummyGraphicAdapter(), xmlRenderTheme);
Assert.fail();
} catch (SAXException e) {
Assert.assertTrue(true);
}
}
示例8: getRenderTheme
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
private static XmlRenderTheme getRenderTheme(String xmlRenderThemeFilename){
if(Strings.isEmpty(xmlRenderThemeFilename)==false){
File renderThemeFile = RelativeFiles.validateRelativeFiles(xmlRenderThemeFilename, AppConstants.ODL_CONFIG_DIR);
if (renderThemeFile != null) {
try {
return new ExternalRenderTheme(renderThemeFile.getAbsoluteFile());
} catch (Exception e) {
// just return the default theme
}
}
}
return InternalRenderTheme.OSMARENDER;
}
示例9: setRenderTheme
import org.mapsforge.map.rendertheme.ExternalRenderTheme; //导入依赖的package包/类
/**
* Sets the XML file which is used for rendering the map.
*
* @param renderThemeFile
* the XML file which defines the rendering theme.
* @throws IllegalArgumentException
* if the supplied internalRenderTheme is null.
* @throws FileNotFoundException
* if the supplied file does not exist, is a directory or cannot be read.
*/
public void setRenderTheme(File renderThemeFile) throws FileNotFoundException {
if (renderThemeFile == null) {
throw new IllegalArgumentException("render theme file must not be null");
}
org.mapsforge.map.rendertheme.XmlRenderTheme jobTheme = new ExternalRenderTheme(renderThemeFile);
this.jobParameters = new JobParameters(jobTheme, this.jobParameters.textScale);
clearAndRedrawMapView();
}