use of com.google.android.libraries.maps.model.PatternItem in project android-samples by googlemaps.
the class CircleDemoActivity method onMapReady.
@Override
public void onMapReady(GoogleMap googleMap) {
// Override the default content description on the view, for accessibility mode.
googleMap.setContentDescription(getString(R.string.map_circle_description));
map = googleMap;
map.setOnMarkerDragListener(this);
map.setOnMapLongClickListener(this);
fillColorArgb = Color.HSVToColor(fillAlphaBar.getProgress(), new float[] { fillHueBar.getProgress(), 1, 1 });
strokeColorArgb = Color.HSVToColor(strokeAlphaBar.getProgress(), new float[] { strokeHueBar.getProgress(), 1, 1 });
fillHueBar.setOnSeekBarChangeListener(this);
fillAlphaBar.setOnSeekBarChangeListener(this);
strokeWidthBar.setOnSeekBarChangeListener(this);
strokeHueBar.setOnSeekBarChangeListener(this);
strokeAlphaBar.setOnSeekBarChangeListener(this);
strokePatternSpinner.setOnItemSelectedListener(this);
DraggableCircle circle = new DraggableCircle(SYDNEY, DEFAULT_RADIUS_METERS);
circles.add(circle);
// Move the map so that it is centered on the initial circle
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 4.0f));
// Set up the click listener for the circle.
googleMap.setOnCircleClickListener(new OnCircleClickListener() {
@Override
public void onCircleClick(Circle circle) {
// Flip the red, green and blue components of the circle's stroke color.
circle.setStrokeColor(circle.getStrokeColor() ^ 0x00ffffff);
}
});
List<PatternItem> pattern = getSelectedPattern(strokePatternSpinner.getSelectedItemPosition());
for (DraggableCircle draggableCircle : circles) {
draggableCircle.setStrokePattern(pattern);
}
}
use of com.google.android.libraries.maps.model.PatternItem in project android-samples by googlemaps.
the class PolylinePatternControlFragment method toString.
private static String toString(List<PatternItem> pattern) {
if (pattern == null) {
return "<SOLID>";
}
StringBuilder sb = new StringBuilder("");
for (PatternItem item : pattern) {
if (item instanceof Dot) {
sb.append("DOT");
} else if (item instanceof Dash) {
sb.append(String.format("%.1fpx-DASH", ((Dash) item).length));
} else if (item instanceof Gap) {
sb.append(String.format("%.1fpx-GAP", ((Gap) item).length));
}
sb.append(" ");
}
sb.append("<repeat>");
return sb.toString();
}
use of com.google.android.libraries.maps.model.PatternItem in project android-samples by googlemaps.
the class PolylinePatternControlFragment method onClick.
@Override
public void onClick(View view) {
if (polyline == null) {
return;
}
int id = view.getId();
List<PatternItem> pattern;
if (id == R.id.patternSolidBtn) {
pattern = null;
} else if (id == R.id.patternDottedBtn) {
pattern = Arrays.asList(new Dot(), new Gap(RANDOM.nextFloat() * MAX_GAP_LENGTH));
} else if (id == R.id.patternDashedBtn) {
pattern = Arrays.asList(new Dash(RANDOM.nextFloat() * MAX_DASH_LENGTH), new Gap(RANDOM.nextFloat() * MAX_GAP_LENGTH));
} else if (id == R.id.patternMixedBtn) {
int size = 2 * (1 + RANDOM.nextInt(MAX_PATTERN_SIZE / 2));
pattern = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
if ((i % 2) == 0) {
pattern.add(RANDOM.nextBoolean() ? new Dot() : new Dash(RANDOM.nextFloat() * MAX_DASH_LENGTH));
} else {
pattern.add(new Gap(RANDOM.nextFloat() * MAX_GAP_LENGTH));
}
}
} else {
throw new IllegalStateException("Unknown button");
}
polyline.setPattern(pattern);
patternTextView.setText(toString(pattern));
}
Aggregations