/** * Returns a shape from an external mark definition * * @param mark * @return */ public Shape getShape(ExternalMark mark) { if (!"ttf".equals(mark.getFormat())) { return null; } String link = mark.getOnlineResource().getLinkage().toString(); // if it does not start with the right prefix, it's not our business if (!link.startsWith("ttf://")) return null; String family; try { family = URLDecoder.decode(link.substring(6), "UTF-8"); } catch (UnsupportedEncodingException e) { // UTF-8 not supported?? throw new RuntimeException(e); } int markIdx = mark.getMarkIndex(); char character = (char) markIdx; return getShape(family, character); }
public ExternalMarkBuilder reset(ExternalMark mark) { if (mark == null) { return reset(); } this.format = mark.getFormat(); this.index = mark.getMarkIndex(); this.inline = mark.getInlineContent(); this.resource = mark.getOnlineResource(); this.unset = false; return this; }
private ExternalMark copy(org.geotools.styling.ExternalMark other) { if (other == null) { return null; } else if (other.getInlineContent() != null) { return sf.externalMark(other.getInlineContent()); } else { return sf.externalMark( other.getOnlineResource(), other.getFormat(), other.getMarkIndex()); } }
public void testExternalMark() throws URISyntaxException { OnLineResourceImpl or = new OnLineResourceImpl(); or.setLinkage(new URI("ttf://wingdings")); ExternalMark externalMark = sf.externalMark(or, "ttf", 15); Mark mark = sf.createMark(); mark.setExternalMark(externalMark); Mark clone = visitor.copy(mark); assertCopy(mark, clone); assertCopy(mark.getExternalMark(), clone.getExternalMark()); ExternalMark emCopy = clone.getExternalMark(); assertEquals("ttf", emCopy.getFormat()); assertEquals("ttf://wingdings", emCopy.getOnlineResource().getLinkage().toASCIIString()); assertEquals(15, emCopy.getMarkIndex()); }