/** * 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 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 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()); }