public void testStyleId() throws Exception { KmlStyle kmlStyle = new KmlStyle(); kmlStyle.setStyleId("BlueLine"); assertEquals("BlueLine", kmlStyle.getStyleId()); }
/** * Gets a MarkerOption * * @return A new MarkerOption */ public MarkerOptions getMarkerOptions(){ if (mInlineStyle == null){ return null; } return mInlineStyle.getMarkerOptions(); }
/** * 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())); } }
/** * Sets the inline linestring style by copying over the styles that have been set * * @param polylineOptions polygon options object to add inline styles to * @param inlineStyle inline styles to apply */ private void setInlineLineStringStyle(PolylineOptions polylineOptions, KmlStyle inlineStyle) { PolylineOptions inlinePolylineOptions = inlineStyle.getPolylineOptions(); if (inlineStyle.isStyleSet("outlineColor")) { polylineOptions.color(inlinePolylineOptions.getColor()); } if (inlineStyle.isStyleSet("width")) { polylineOptions.width(inlinePolylineOptions.getWidth()); } if (inlineStyle.isLineRandomColorMode()) { polylineOptions.color(KmlStyle.computeRandomColor(inlinePolylineOptions.getColor())); } }
MarkerOptions markerOptions = style.getMarkerOptions(); if (inlineStyle != null) { setInlinePointStyle(markerOptions, inlineStyle, style.getIconUrl()); } else if (style.getIconUrl() != null) { addMarkerIcons(style.getIconUrl(), markerOptions); PolylineOptions polylineOptions = style.getPolylineOptions(); if (inlineStyle != null) { setInlineLineStringStyle(polylineOptions, inlineStyle); } else if (style.isLineRandomColorMode()) { polylineOptions.color(KmlStyle.computeRandomColor(polylineOptions.getColor())); PolygonOptions polygonOptions = style.getPolygonOptions(); if (inlineStyle != null) { setInlinePolygonStyle(polygonOptions, inlineStyle); } else if (style.isPolyRandomColorMode()) { polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.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 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()); }
/** * Sets relevant styling properties to the KmlStyle object that are found in the PolyStyle tag * Supported tags include color, outline, fill * * @param style Style object to add properties to */ private static void createPolyStyle(XmlPullParser parser, KmlStyle style) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); while (!(eventType == END_TAG && parser.getName().equals("PolyStyle"))) { if (eventType == START_TAG) { if (parser.getName().equals(COLOR_STYLE_COLOR)) { style.setFillColor(parser.nextText()); } else if (parser.getName().equals(POLY_STYLE_OUTLINE)) { style.setOutline(KmlBoolean.parseBoolean(parser.nextText())); } else if (parser.getName().equals(POLY_STYLE_FILL)) { style.setFill(KmlBoolean.parseBoolean(parser.nextText())); } else if (parser.getName().equals(COLOR_STYLE_MODE)) { style.setPolyColorMode(parser.nextText()); } } eventType = parser.next(); } }
public void testHeading() throws Exception { KmlStyle kmlStyle = new KmlStyle(); assertNotNull(kmlStyle); assertNotNull(kmlStyle.getMarkerOptions()); assertEquals(kmlStyle.getMarkerOptions().getRotation(), 0.0f); kmlStyle.setHeading(3); assertEquals(kmlStyle.getMarkerOptions().getRotation(), 3.0f); }
/** * Recieves input from an XMLPullParser and assigns relevant properties to a KmlStyle. * * @param style Style to apply properties to * @return true if icon style has been set */ private static void createIconStyle(XmlPullParser parser, KmlStyle style) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); while (!(eventType == END_TAG && parser.getName().equals("IconStyle"))) { if (eventType == START_TAG) { if (parser.getName().equals(ICON_STYLE_HEADING)) { style.setHeading(Float.parseFloat(parser.nextText())); } else if (parser.getName().equals(ICON_STYLE_URL)) { setIconUrl(parser, style); } else if (parser.getName().equals(ICON_STYLE_HOTSPOT)) { setIconHotSpot(parser, style); } else if (parser.getName().equals(ICON_STYLE_SCALE)) { style.setIconScale(Double.parseDouble(parser.nextText())); } else if (parser.getName().equals(COLOR_STYLE_COLOR)) { style.setMarkerColor(parser.nextText()); } else if (parser.getName().equals(COLOR_STYLE_MODE)) { style.setIconColorMode(parser.nextText()); } } eventType = parser.next(); } }
public void testPolyStyleBooleanAlpha() throws Exception { XmlPullParser parser = createParser(com.google.maps.android.test.R.raw.amu_poly_style_boolean_alpha); KmlParser mParser = new KmlParser(parser); mParser.parseKml(); assertNotNull(mParser.getPlacemarks()); assertEquals(1, mParser.getContainers().size()); KmlContainer kmlContainer = mParser.getContainers().get(0); assertEquals(true, kmlContainer.hasPlacemarks()); HashMap<String, KmlStyle> styles = kmlContainer.getStyles(); KmlStyle kmlStyle = styles.get("#fireadvisory"); assertNotNull(kmlStyle); assertEquals(true, kmlStyle.hasFill()); assertEquals(false, kmlStyle.hasOutline()); }
/** * Sets the inline point style by copying over the styles that have been set * * @param markerOptions marker options object to add inline styles to * @param inlineStyle inline styles to apply * @param markerUrlIconUrl default marker icon URL from shared style */ private void setInlinePointStyle(MarkerOptions markerOptions, KmlStyle inlineStyle, String markerUrlIconUrl) { MarkerOptions inlineMarkerOptions = inlineStyle.getMarkerOptions(); if (inlineStyle.isStyleSet("heading")) { markerOptions.rotation(inlineMarkerOptions.getRotation()); } if (inlineStyle.isStyleSet("hotSpot")) { markerOptions .anchor(inlineMarkerOptions.getAnchorU(), inlineMarkerOptions.getAnchorV()); } if (inlineStyle.isStyleSet("markerColor")) { markerOptions.icon(inlineMarkerOptions.getIcon()); } if (inlineStyle.isStyleSet("iconUrl")) { addMarkerIcons(inlineStyle.getIconUrl(), markerOptions); } else if (markerUrlIconUrl != null) { // Inline style with no icon defined addMarkerIcons(markerUrlIconUrl, markerOptions); } }
mStyles.put(style.getStyleId(), style); mStyles.put(null, new KmlStyle());
public void testMarkerColor() { KmlStyle kmlStyle = new KmlStyle(); assertNotNull(kmlStyle); assertNotNull(kmlStyle.getMarkerOptions()); }
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"); } }
/** * Parses the IconStyle, LineStyle and PolyStyle tags into a KmlStyle object */ /* package */ static KmlStyle createStyle(XmlPullParser parser) throws IOException, XmlPullParserException { KmlStyle styleProperties = new KmlStyle(); setStyleId(parser.getAttributeValue(null, "id"), styleProperties); int eventType = parser.getEventType(); while (!(eventType == END_TAG && parser.getName().equals("Style"))) { if (eventType == START_TAG) { if (parser.getName().equals("IconStyle")) { createIconStyle(parser, styleProperties); } else if (parser.getName().equals("LineStyle")) { createLineStyle(parser, styleProperties); } else if (parser.getName().equals("PolyStyle")) { createPolyStyle(parser, styleProperties); } else if (parser.getName().equals("BalloonStyle")) { createBalloonStyle(parser, styleProperties); } } eventType = parser.next(); } return styleProperties; }
/** * Gets a PolygonOption * * @return new PolygonOptions */ public PolygonOptions getPolygonOptions() { if (mInlineStyle == null){ return null; } return mInlineStyle.getPolygonOptions(); }
/** * Gets a PolylineOption * * @return new PolylineOptions */ public PolylineOptions getPolylineOptions(){ if (mInlineStyle == null){ return null; } return mInlineStyle.getPolylineOptions(); }