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


Java AndroidGraphicFactory类代码示例

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


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

示例1: initMap

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
private void initMap() {
    AndroidGraphicFactory.createInstance(getApplication());
    mapView = new MapView(this);

    mapView.setClickable(true);
    mapView.getMapScaleBar().setVisible(false);
    mapView.setBuiltInZoomControls(false);
    mapView.setZoomLevelMin((byte) 2);
    mapView.setZoomLevelMax((byte) 10);

    mapView.setZoomLevel((byte) 2);
    mapView.getModel().displayModel.setBackgroundColor(ContextCompat.getColor(this, R.color.mapBackground));

    layers = mapView.getLayerManager().getLayers();

    MapCreator mapCreator = new MapCreator(this, layers);
    mapCreator.parseGeoJson("world_map.geo.json");

    initServerOnMap(layers);

    LinearLayout map = (LinearLayout) findViewById(R.id.map);
    map.addView(mapView);
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:24,代码来源:HomeActivity.java

示例2: createLayers

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@AfterPermissionGranted(PERMISSIONS_REQUEST_READ_STORAGE)
private void createLayers() {
    if (EasyPermissions.hasPermissions(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
        TileCache tileCache = AndroidUtil.createTileCache(getContext(),
                "mapFragment",
                this.mapView.getModel().displayModel.getTileSize(),
                1.0f,
                this.mapView.getModel().frameBufferModel.getOverdrawFactor());

        final Layers layers = this.mapView.getLayerManager().getLayers();
        final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;

        initializePosition(mapViewPosition);

        TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapViewPosition,
                getMapFile(), getRenderTheme());
        layers.add(tileRendererLayer);

        LabelLayer labelLayer = new LabelLayer(AndroidGraphicFactory.INSTANCE, tileRendererLayer.getLabelStore());
        mapView.getLayerManager().getLayers().add(labelLayer);

        // overlay with a marker to show the goal position
        this.goalLocationOverlay = new Marker(null, null, 0, 0);
        layers.add(this.goalLocationOverlay);

        createLocationLayer();
    } else {
        EasyPermissions.requestPermissions(
                this,
                "",
                PERMISSIONS_REQUEST_READ_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE);
    }
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:35,代码来源:MapFragment.java

示例3: MapsforgeTileSource

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
/**
     * The reason this constructor is protected is because all parameters,
     * except file should be determined from the archive file. Therefore a
     * factory method is necessary.
     *
     * @param file
     * @param xmlRenderTheme the themeFuture to render tiles with
     */
    protected MapsforgeTileSource(Application app,
                                  File file,
                                  XmlRenderTheme xmlRenderTheme,
                                  MultiMapDataStore.DataPolicy dataPolicy) {

        AndroidGraphicFactory.createInstance(app);

//        model.setFixedTileSize(256);

        mapDatabase = new MultiMapDataStore(dataPolicy);
        mapDatabase.addMapDataStore(new MapFile(file), false, false);

        InMemoryTileCache tileCache = new InMemoryTileCache(5);
        renderer = new DatabaseRenderer(mapDatabase, factory, tileCache,
                new TileBasedLabelStore(tileCache.getCapacityFirstLevel()), true, true, null);

        Log.d(TAG, "min=" + MIN_ZOOM + " max=" + MAX_ZOOM + " tilesize=" + TILE_SIZE_PIXELS);

        themeFuture = new RenderThemeFuture(factory, xmlRenderTheme, model);
        //super important!! without the following line, all rendering activities will block until the themeFuture is created.
        new Thread(themeFuture).start();

    }
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:32,代码来源:MapsforgeTileSource.java

示例4: MapsforgeOSMTileSource

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
public MapsforgeOSMTileSource(@NonNull Context context,
                              @NonNull String name,
                              @NonNull String mapFile,
                              @NonNull TileCache cache) {
    this.context = context;
    this.name = name;
    this.mapFile = mapFile;
    //this.tileCache = cache;
    //this.tileWeakCache = new WeakHashMap<>();

    MapDatabase mapDatabase = new MapDatabase();
    mapGenerator = new DatabaseRenderer(mapDatabase, AndroidGraphicFactory.INSTANCE);
    xmlRenderTheme = new RenderTheme();
    displayModel = new Model().displayModel;

    mapDatabase.closeFile();
    mapDatabase.openFile(new File(mapFile));
    mapBounds = mapDatabase.getMapFileInfo().boundingBox;
    zoomBounds = -1;
}
 
开发者ID:yuviii,项目名称:OfflineMap,代码行数:21,代码来源:MapsforgeOSMTileSource.java

示例5: onDrawSurface

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
private void onDrawSurface(Canvas androidCanvas) {
    if (getParentViewGroup()!=null) {
        org.mapsforge.core.graphics.Canvas graphicContext = AndroidGraphicFactory.createGraphicContext(androidCanvas);

        parallelMapView.getFrameBuffer().draw(graphicContext);
        parallelMapView.getMapScaleBar().draw(graphicContext);
        parallelMapView.getFpsCounter().draw(graphicContext);

        graphicContext.destroy();
    }

    if (TRACE) {
        long thId = Thread.currentThread().getId();
        String msg = String.format(Locale.getDefault(), "Draw MySurface at thread #%d", thId);
        Log.d(TAG, msg);
    }
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:18,代码来源:FixedFpsSurfaceView.java

示例6: onSensorChanged

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType()==Sensor.TYPE_ROTATION_VECTOR) {
        long    currMillis  = System.currentTimeMillis();
        double  currAzimuth = Math.toDegrees(Math.asin(event.values[2])*2);
        boolean overAzimuthThreshold = Math.abs(currAzimuth-prevAzimuth)>=AZIMUTH_THRESHOLD;
        boolean overMillisThreshold  = (currMillis-prevMillis)>=MILLIS_THRESHOLD;

        if (overAzimuthThreshold || overMillisThreshold) {
            prevMillis  = currMillis;
            prevAzimuth = currAzimuth;
            mState.myAzimuth = currAzimuth;

            // Change marker angle.
            Matrix m = AndroidGraphicFactory.INSTANCE.createMatrix();
            m.translate(64, 64);
            m.rotate((float)Math.toRadians(-currAzimuth));
            m.translate(-64, -64);
            mMarkerCanvas.fillColor(0x00000000);
            mMarkerCanvas.drawBitmap(mLocationBitmapSrc, m);
            mLocationMarker.requestRedraw();

            triggerStateChange();
        }
    }
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:27,代码来源:TaiwanMapView.java

示例7: onCreate

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());

    // 配置 Android 繪圖資源,必須在 inflate 之前完成
    AndroidGraphicFactory.createInstance(getApplication());
    setContentView(R.layout.activity_main);

    // 配置廣播接收器
    this.registerReceiver(receiver, MainUtils.buildFragmentSwitchIntentFilter());

    // 清理儲存空間
    MainUtils.cleanStorage(this);

    // 檢查是否殘留除錯設定,釋出前使用
    checkDebugParameters();

    // 先進入更新介面
    changeFragment(mUpdateFragment);
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:22,代码来源:MainActivity.java

示例8: initDetailsServerOnMap

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
private void initDetailsServerOnMap() {
    if (markerList != null && markerList.size() > 0) {
        for (Marker marker : markerList) {
            layers.remove(marker);
        }
    }
    List<Server> serverList = dbHelper.getServersWithGPS();

    markerList = new ArrayList<Marker>();
    for (Server server : serverList) {
        LatLong position = new LatLong(server.getLat(), server.getLon());
        Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(ContextCompat.getDrawable(this,
                getResources().getIdentifier(ConnectionQuality.getSimplePointIcon(server.getQuality()),
                        "drawable",
                        getPackageName())));
        Marker serverMarker = new Marker(position, bitmap, 0, 0);
        markerList.add(serverMarker);
        layers.add(serverMarker);
    }
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:21,代码来源:HomeActivity.java

示例9: createPolygons

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
private void createPolygons(JSONArray coordinates) {
    Polygon polygon = new Polygon(paintFill, paintStroke,
            AndroidGraphicFactory.INSTANCE);

    List<LatLong> polygonList = polygon.getLatLongs();

    for (int j = 0; j < coordinates.length(); j++) {
        try {
            JSONArray arrLatLong = new JSONArray(coordinates.get(j).toString());
            polygonList.add(new LatLong(arrLatLong.getDouble(1), arrLatLong.getDouble(0)));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    layers.add(polygon);
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:18,代码来源:MapCreator.java

示例10: onHeatmapCompleted

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
public final void onHeatmapCompleted(final Bitmap backbuffer) {
	// zoom level has changed in the mean time - regenerate
	if (mMapView.getModel().mapViewPosition.getZoomLevel() != zoomAtTrigger) {
		updatePending = false;
		Log.i(TAG, "Zoom level has changed - have to re-generate heat-map");
		clearLayer();
		proceedAfterHeatmapCompleted();
		return;
	}

	final BitmapDrawable drawable = new BitmapDrawable(backbuffer);
	final org.mapsforge.core.graphics.Bitmap mfBitmap = AndroidGraphicFactory.convertToBitmap(drawable);
	if (heatmapLayer != null && mfBitmap != null) {
		heatmapLayer.setBitmap(mfBitmap);
	} else {
		Log.w(TAG, "Skipped heatmap draw: either layer or bitmap is null");
	}
	updatePending = false;
	//saveHeatmapToFile(backbuffer);
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:22,代码来源:WifiDetailsMap.java

示例11: onCreate

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
public final void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setHasOptionsMenu(true);

	// get shared preferences
	prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

	// Register our gps broadcast mReceiver
	registerReceiver();

	catalogObjects = new ArrayList<Layer>();
	sessionObjects = new ArrayList<Layer>();
	gpxObjects = new Polyline(MapUtils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLACK), STROKE_GPX_WIDTH,
			Style.STROKE), AndroidGraphicFactory.INSTANCE);
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:17,代码来源:MapViewActivity.java

示例12: onHeatmapCompleted

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
public final void onHeatmapCompleted(final Bitmap backbuffer) {
	// zoom level has changed in the mean time - regenerate
	if (mMapView.getModel().mapViewPosition.getZoomLevel() != mZoomAtTrigger) {
		mUpdatePending = false;
		Log.i(TAG, "Zoom level has changed - have to re-generate heat-map");
		clearLayer();
		proceedAfterHeatmapCompleted();
		return;
	}

	final BitmapDrawable drawable = new BitmapDrawable(backbuffer);
	final org.mapsforge.core.graphics.Bitmap mfBitmap = AndroidGraphicFactory.convertToBitmap(drawable);
	if (mHeatmapLayer != null && mfBitmap != null) {
		mHeatmapLayer.setBitmap(mfBitmap);
	} else {
		Log.w(TAG, "Skipped heatmap draw: either layer or bitmap is null");
	}
	mUpdatePending = false;
	//saveHeatmapToFile(backbuffer);

}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:23,代码来源:CellDetailsMap.java

示例13: onCreate

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 5, this);
    Variable.getVariable().setContext(getApplicationContext());
    Variable.getVariable().setZoomLevels(22, 1);
    AndroidGraphicFactory.createInstance(getApplication());
    mapView = new MapView(this);
    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(false);
    MapHandler.getMapHandler()
            .init(this, mapView, Variable.getVariable().getCountry(), Variable.getVariable().getMapsFolder());
    MapHandler.getMapHandler().loadMap(new File(Variable.getVariable().getMapsFolder().getAbsolutePath(),
            Variable.getVariable().getCountry() + "-gh"));
    customMapView();
    checkGpsAvailability();

    getMyLastLocation();
    updateCurrentLocation(null);
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:22,代码来源:MapActivity.java

示例14: createPolyline

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
/**
 * draws a connected series of line segments specified by a list of LatLongs.
 *
 * @param pointList
 * @param color:       the color of the polyline
 * @param strokeWidth: the stroke width of the polyline
 * @return Polyline
 */
public Polyline createPolyline(PointList pointList, int color, int strokeWidth) {
    Paint paintStroke = AndroidGraphicFactory.INSTANCE.createPaint();

    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setColor(color);
    //        paintStroke.setDashPathEffect(new float[]{25, 25});
    paintStroke.setStrokeWidth(strokeWidth);

    // TODO: new mapsforge version wants an mapsforge-paint, not an android paint.
    // This doesn't seem to support transparceny
    //paintStroke.setAlpha(128);
    Polyline line = new Polyline((Paint) paintStroke, AndroidGraphicFactory.INSTANCE);
    List<LatLong> geoPoints = line.getLatLongs();
    PointList tmp = pointList;
    for (int i = 0; i < pointList.getSize(); i++) {
        geoPoints.add(new LatLong(tmp.getLatitude(i), tmp.getLongitude(i)));
    }
    return line;
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:30,代码来源:MapHandler.java

示例15: onCreate

import org.mapsforge.map.android.graphics.AndroidGraphicFactory; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidGraphicFactory.createInstance(this.getApplication());

    setContentView(R.layout.activity_main);
    btn_simplemap = (Button)findViewById(R.id.btn_simple_map);
    btn_multimap = (Button)findViewById(R.id.btn_multi_map);

    btn_simplemap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(),SimpleMapView.class);
            startActivity(intent);
        }
    });

    checker = new EnvironmentCheck(this);
    downloadManager = new MapDownloadManager(this);
}
 
开发者ID:lienching,项目名称:MapsforgeSample,代码行数:21,代码来源:MainActivity.java


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