Skip to content

Commit

Permalink
vtm-jts: PathLayer improvements, #53
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Aug 2, 2016
1 parent 5eae87e commit 4a663f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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;
Expand All @@ -47,7 +47,7 @@ public void onCreate(Bundle savedInstanceState) {
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);
}
Expand All @@ -74,7 +74,7 @@ protected void onResume() {
mMap.setMapPosition(0, 0, 1 << 2);
}

ArrayList<JtsPathLayer> mPathLayers = new ArrayList<JtsPathLayer>();
ArrayList<PathLayer> mPathLayers = new ArrayList<>();

void createLayers(float pos) {

Expand Down
Original file line number Diff line number Diff line change
@@ -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).
*
Expand All @@ -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;
Expand All @@ -33,32 +32,33 @@
/**
* 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()
mStyle = style;

mPoints = new ArrayList<>();
}

public PathLayer(Map map, int lineColor, float lineWidth) {
this(map, Style.builder()
.strokeColor(lineColor)
.strokeWidth(lineWidth)
.build();

mPoints = new ArrayList<GeoPoint>();
.build());
}

public JtsPathLayer(Map map, int lineColor) {
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() {
Expand Down
8 changes: 4 additions & 4 deletions vtm-playground/src/org/oscim/test/PathLayerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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;

Expand Down Expand Up @@ -52,7 +52,7 @@ public void onMapEvent(Event e, MapPosition mapPosition) {
});
}

ArrayList<JtsPathLayer> mPathLayers = new ArrayList<>();
ArrayList<PathLayer> mPathLayers = new ArrayList<>();

void createLayers(float pos, boolean init) {

Expand Down Expand Up @@ -80,10 +80,10 @@ void createLayers(float pos, boolean init) {

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 {
Expand Down

0 comments on commit 4a663f9

Please sign in to comment.