/** * Gets a PolygonOption * * @return new PolygonOptions */ public PolygonOptions getPolygonOptions() { if (mInlineStyle == null){ return null; } return mInlineStyle.getPolygonOptions(); }
public void testFillColor() throws Exception { KmlStyle kmlStyle = new KmlStyle(); assertNotNull(kmlStyle); assertNotNull(kmlStyle.getPolygonOptions()); kmlStyle.setFillColor("000000"); int fillColor = Color.parseColor("#000000"); assertEquals(fillColor, kmlStyle.getPolygonOptions().getFillColor()); }
public void testColorFormatting() throws Exception { KmlStyle kmlStyle = new KmlStyle(); // AABBGGRR -> AARRGGBB. kmlStyle.setFillColor("ff579D00"); assertEquals(Color.parseColor("#009D57"), kmlStyle.getPolygonOptions().getFillColor()); // Alpha w/ missing 0. kmlStyle.setFillColor(" D579D00"); assertEquals(Color.parseColor("#0D009D57"), kmlStyle.getPolygonOptions().getFillColor()); }
public void testWidth() throws Exception { KmlStyle kmlStyle = new KmlStyle(); assertNotNull(kmlStyle); assertNotNull(kmlStyle.getPolygonOptions()); assertNotNull(kmlStyle.getPolylineOptions()); assertEquals(kmlStyle.getPolylineOptions().getWidth(), 10.0f); assertEquals(kmlStyle.getPolygonOptions().getStrokeWidth(), 10.0f); kmlStyle.setWidth(11.0f); assertEquals(kmlStyle.getPolylineOptions().getWidth(), 11.0f); assertEquals(kmlStyle.getPolygonOptions().getStrokeWidth(), 11.0f); }
public void testLineColor() throws Exception { KmlStyle kmlStyle = new KmlStyle(); assertNotNull(kmlStyle); assertNotNull(kmlStyle.getPolygonOptions()); assertNotNull(kmlStyle.getPolylineOptions()); assertEquals(Color.BLACK, kmlStyle.getPolylineOptions().getColor()); assertEquals(Color.BLACK, kmlStyle.getPolygonOptions().getStrokeColor()); kmlStyle.setOutlineColor("FFFFFF"); assertEquals(Color.WHITE, kmlStyle.getPolylineOptions().getColor()); assertEquals(Color.WHITE, kmlStyle.getPolygonOptions().getStrokeColor()); }
public void testInlineStyle() throws Exception { XmlPullParser parser = createParser(com.google.maps.android.test.R.raw.amu_inline_style); KmlParser mParser = new KmlParser(parser); mParser.parseKml(); assertNotNull(mParser.getPlacemarks()); assertEquals(mParser.getPlacemarks().size(), 1); for (KmlPlacemark placemark : mParser.getPlacemarks().keySet()) { KmlStyle inlineStyle = placemark.getInlineStyle(); assertNotNull(inlineStyle); assertEquals(inlineStyle.getPolylineOptions().getColor(), Color.parseColor("#000000")); assertEquals(inlineStyle.getPolygonOptions().getFillColor(), Color.parseColor("#ffffff")); assertEquals(inlineStyle.getPolylineOptions().getColor(), inlineStyle.getPolygonOptions().getStrokeColor()); assertEquals(placemark.getGeometry().getGeometryType(), "MultiGeometry"); } }
/** * Sets the inline polygon style by copying over the styles that have been set * * @param polygonOptions polygon options object to add inline styles to * @param inlineStyle inline styles to apply */ private void setInlinePolygonStyle(PolygonOptions polygonOptions, KmlStyle inlineStyle) { PolygonOptions inlinePolygonOptions = inlineStyle.getPolygonOptions(); if (inlineStyle.hasFill() && inlineStyle.isStyleSet("fillColor")) { polygonOptions.fillColor(inlinePolygonOptions.getFillColor()); } if (inlineStyle.hasOutline()) { if (inlineStyle.isStyleSet("outlineColor")) { polygonOptions.strokeColor(inlinePolygonOptions.getStrokeColor()); } if (inlineStyle.isStyleSet("width")) { polygonOptions.strokeWidth(inlinePolygonOptions.getStrokeWidth()); } } if (inlineStyle.isPolyRandomColorMode()) { polygonOptions.fillColor(KmlStyle.computeRandomColor(inlinePolygonOptions.getFillColor())); } }
PolygonOptions polygonOptions = style.getPolygonOptions(); if (inlineStyle != null) { setInlinePolygonStyle(polygonOptions, inlineStyle);