vtm-jts: PathLayer improvements, #53
This commit is contained in:
parent
5eae87e892
commit
4a663f949e
@ -22,7 +22,7 @@ import android.os.Bundle;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.layers.JtsPathLayer;
|
||||
import org.oscim.layers.vector.PathLayer;
|
||||
import org.oscim.map.Map.UpdateListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -47,7 +47,7 @@ public class PathOverlayActivity extends BitmapTileMapActivity {
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
for (double lat = -90; lat <= 90; lat += 5) {
|
||||
int c = Color.fade(Color.rainbow((float) (lat + 90) / 180), 0.5f);
|
||||
JtsPathLayer pathLayer = new JtsPathLayer(mMap, c, 6);
|
||||
PathLayer pathLayer = new PathLayer(mMap, c, 6);
|
||||
mMap.layers().add(pathLayer);
|
||||
mPathLayers.add(pathLayer);
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class PathOverlayActivity extends BitmapTileMapActivity {
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
|
||||
ArrayList<JtsPathLayer> mPathLayers = new ArrayList<JtsPathLayer>();
|
||||
ArrayList<PathLayer> mPathLayers = new ArrayList<>();
|
||||
|
||||
void createLayers(float pos) {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2012 osmdroid authors: Viesturs Zarins, Martin Pearman
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -15,13 +16,11 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oscim.layers;
|
||||
package org.oscim.layers.vector;
|
||||
|
||||
import com.vividsolutions.jts.geom.LineString;
|
||||
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.vector.VectorLayer;
|
||||
import org.oscim.layers.vector.geometries.LineDrawable;
|
||||
import org.oscim.layers.vector.geometries.Style;
|
||||
import org.oscim.map.Map;
|
||||
@ -33,32 +32,33 @@ import java.util.List;
|
||||
/**
|
||||
* This class draws a path line in given color.
|
||||
*/
|
||||
public class JtsPathLayer extends VectorLayer {
|
||||
public class PathLayer extends VectorLayer {
|
||||
|
||||
protected final ArrayList<GeoPoint> mPoints;
|
||||
|
||||
protected Style mStyle;
|
||||
protected LineDrawable mDrawable;
|
||||
|
||||
public JtsPathLayer(Map map, int lineColor, float lineWidth) {
|
||||
public PathLayer(Map map, Style style) {
|
||||
super(map);
|
||||
mStyle = Style.builder()
|
||||
.strokeColor(lineColor)
|
||||
.strokeWidth(lineWidth)
|
||||
.build();
|
||||
mStyle = style;
|
||||
|
||||
mPoints = new ArrayList<GeoPoint>();
|
||||
mPoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
public JtsPathLayer(Map map, int lineColor) {
|
||||
public PathLayer(Map map, int lineColor, float lineWidth) {
|
||||
this(map, Style.builder()
|
||||
.strokeColor(lineColor)
|
||||
.strokeWidth(lineWidth)
|
||||
.build());
|
||||
}
|
||||
|
||||
public PathLayer(Map map, int lineColor) {
|
||||
this(map, lineColor, 2);
|
||||
}
|
||||
|
||||
public void setStyle(int lineColor, float lineWidth) {
|
||||
mStyle = Style.builder()
|
||||
.strokeColor(lineColor)
|
||||
.strokeWidth(lineWidth)
|
||||
.build();
|
||||
public void setStyle(Style style) {
|
||||
mStyle = style;
|
||||
}
|
||||
|
||||
public void clearPath() {
|
@ -21,8 +21,8 @@ import org.oscim.core.GeoPoint;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.layers.JtsPathLayer;
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.layers.vector.PathLayer;
|
||||
import org.oscim.map.Map.UpdateListener;
|
||||
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||
|
||||
@ -52,7 +52,7 @@ public class PathLayerTest extends GdxMapApp {
|
||||
});
|
||||
}
|
||||
|
||||
ArrayList<JtsPathLayer> mPathLayers = new ArrayList<>();
|
||||
ArrayList<PathLayer> mPathLayers = new ArrayList<>();
|
||||
|
||||
void createLayers(float pos, boolean init) {
|
||||
|
||||
@ -80,10 +80,10 @@ public class PathLayerTest extends GdxMapApp {
|
||||
|
||||
pts.add(new GeoPoint(latitude, longitude));
|
||||
}
|
||||
JtsPathLayer pathLayer;
|
||||
PathLayer pathLayer;
|
||||
if (init) {
|
||||
int c = Color.fade(Color.rainbow((float) (lat + 90) / 180), 0.5f);
|
||||
pathLayer = new JtsPathLayer(mMap, c, 6);
|
||||
pathLayer = new PathLayer(mMap, c, 6);
|
||||
mMap.layers().add(pathLayer);
|
||||
mPathLayers.add(pathLayer);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user