Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.maps.android.data.geojson;

import com.google.android.gms.maps.model.Cap;
import com.google.android.gms.maps.model.PatternItem;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.android.data.Style;
Expand All @@ -27,7 +28,7 @@
/**
* A class that allows for GeoJsonLineString objects to be styled and for these styles to be
* translated into a PolylineOptions object. {@see
* <a href="https://developer.android.com/reference/com/google/android/gms/maps/model/PolylineOptions.html">
* <a href="https://developers.google.com/android/reference/com/google/android/gms/maps/model/PolylineOptions">
* PolylineOptions docs</a> for more details about the options.}
*/
public class GeoJsonLineStringStyle extends Style implements GeoJsonStyle {
Expand All @@ -43,144 +44,72 @@ public GeoJsonLineStringStyle() {
mPolylineOptions.clickable(true);
}

/**
* {@inheritDoc}
*/
@Override
public String[] getGeometryType() {
return GEOMETRY_TYPE;
}

/**
* Gets the color of the GeoJsonLineString as a 32-bit ARGB color
*
* @return color of the GeoJsonLineString
*/
public int getColor() {
return mPolylineOptions.getColor();
}

/**
* Sets the color of the GeoJsonLineString as a 32-bit ARGB color
*
* @param color color value of the GeoJsonLineString
*/
public void setColor(int color) {
mPolylineOptions.color(color);
styleChanged();
}

/**
* Gets the clickability setting for this Options object
*
* @return true if the GeoJsonLineString is clickable; false if it is not
*/
public boolean isClickable() {
return mPolylineOptions.isClickable();
}

/**
* Specifies whether this GeoJsonLineString is clickable
*
* @param clickable - new clickability setting for the GeoJsonLineString
*/
public void setClickable(boolean clickable) {
mPolylineOptions.clickable(clickable);
styleChanged();
}

/**
* Gets whether the GeoJsonLineString is geodesic
*
* @return true if GeoJsonLineString is geodesic, false otherwise
*/
public boolean isGeodesic() {
return mPolylineOptions.isGeodesic();
}

/**
* Sets whether the GeoJsonLineString is geodesic
*
* @param geodesic true if GeoJsonLineString is geodesic, false otherwise
*/
public void setGeodesic(boolean geodesic) {
mPolylineOptions.geodesic(geodesic);
styleChanged();
}

/**
* Gets the width of the GeoJsonLineString in screen pixels
*
* @return width of the GeoJsonLineString
*/
public float getWidth() {
return mPolylineOptions.getWidth();
}

/**
* Sets the width of the GeoJsonLineString in screen pixels
*
* @param width width value of the GeoJsonLineString
*/
public void setWidth(float width) {
setLineStringWidth(width);
styleChanged();
}

/**
* Gets the z index of the GeoJsonLineString
*
* @return z index of the GeoJsonLineString
*/
public float getZIndex() {
return mPolylineOptions.getZIndex();
}

/**
* Sets the z index of the GeoJsonLineString
*
* @param zIndex z index value of the GeoJsonLineString
*/
public void setZIndex(float zIndex) {
mPolylineOptions.zIndex(zIndex);
styleChanged();
}

/**
* Gets whether the GeoJsonLineString is visible
*
* @return true if the GeoJsonLineString visible, false if not visible
*/
@Override
public boolean isVisible() {
return mPolylineOptions.isVisible();
}

/**
* Sets whether the GeoJsonLineString is visible
*
* @param visible true if the GeoJsonLineString is visible, false if not visible
*/
@Override
public void setVisible(boolean visible) {
mPolylineOptions.visible(visible);
styleChanged();
}

/**
* Notifies the observers, GeoJsonFeature objects, that the style has changed. Indicates to the
* GeoJsonFeature that it should check whether a redraw is needed for the feature.
*/
private void styleChanged() {
setChanged();
notifyObservers();
}

/**
* Gets a new PolylineOptions object containing styles for the GeoJsonLineString
*
* @return new PolylineOptions object
*/
public PolylineOptions toPolylineOptions() {
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.color(mPolylineOptions.getColor());
Expand All @@ -190,6 +119,8 @@ public PolylineOptions toPolylineOptions() {
polylineOptions.width(mPolylineOptions.getWidth());
polylineOptions.zIndex(mPolylineOptions.getZIndex());
polylineOptions.pattern(getPattern());
polylineOptions.startCap(getStartCap());
polylineOptions.endCap(getEndCap());
return polylineOptions;
}

Expand All @@ -205,27 +136,36 @@ public String toString() {
sb.append(",\n width=").append(getWidth());
sb.append(",\n z index=").append(getZIndex());
sb.append(",\n pattern=").append(getPattern());
sb.append(",\n startCap=").append(getStartCap());
sb.append(",\n endCap=").append(getEndCap());
sb.append("\n}\n");
return sb.toString();
}

/**
* Gets the pattern of the GeoJsonLineString
*
* @return line style of GeoJsonLineString
*/
public List<PatternItem> getPattern() {
return mPolylineOptions.getPattern();
}

/**
* Sets the pattern of the GeoJsonLineString
*
* @param pattern line style of GeoJsonLineString
*/
public void setPattern(List<PatternItem> pattern) {
mPolylineOptions.pattern(pattern);
styleChanged();
}

public void setStartCap(@NonNull Cap cap) {
mPolylineOptions.startCap(cap);
styleChanged();
}

public void setEndCap(@NonNull Cap cap) {
mPolylineOptions.endCap(cap);
styleChanged();
}

public Cap getStartCap() {
return mPolylineOptions.getStartCap();
}

public Cap getEndCap() {
return mPolylineOptions.getEndCap();
}
}