@Test public void Create() { PathBuilderFactory factory = new PathBuilderFactory(); PathBuilder<Object> pathBuilder = factory.create(Object.class); assertEquals("object", pathBuilder.toString()); assertEquals(Object.class, pathBuilder.getType()); pathBuilder.get("prop", Object.class); pathBuilder.get("prop", String.class); pathBuilder.get("prop", Object.class); }
protected int encodeRuler(ChannelBuffer buf, Locator locator, Ruler ruler) { BufferHelper helper = m_bufferHelper; XmlBuilder b = new XmlBuilder(); StringBuilder sb = b.getResult(); PathBuilder p = new PathBuilder(); int height = ruler.getHeight(); b.tag1( "g", "id", "ruler", "font-size", "12", "text-anchor", "middle", "stroke", "black", "stroke-width", "1"); int unitNum = ruler.getUnitNum(); int unitStep = ruler.getUnitStep(); int unit = (int) ruler.getUnit(); int x = ruler.getOffsetX(); int y = 10; for (int i = 0; i <= unitNum; i++) { String text; if (unitStep >= 1000) { text = (i * unitStep / 1000) + "ms"; } else { text = (i * unitStep) + "us"; } b.tagWithText("text", text, "x", x + i * unit, "y", y, "stroke-width", "0"); } for (int i = 0; i <= unitNum; i++) { b.tag( "path", "d", p.moveTo(x + i * unit, y + 6).v(height).build(), "stroke-dasharray", "3,4"); } b.tag2("g"); return helper.write(buf, sb.toString()); }
public void branch(Locator locator, int x, int y, int width, int height) { PathBuilder p = new PathBuilder(); int w = width / 2; int h = height / 2; int r = 2; for (Integer flag : locator.getFlags()) { int cx = x + w; int cy = y - h; if ((flag & 2) != 0) { // 00010 tag("path", "d", p.moveTo(cx, cy).h(w).build()); } if ((flag & 4) != 0) { // 00100 tag("path", "d", p.moveTo(cx, cy).v(-h).build()); } if ((flag & 8) != 0) { // 01000 tag("path", "d", p.moveTo(cx, cy).h(-w).build()); } if ((flag & 16) != 0) { // 10000 tag("path", "d", p.moveTo(cx, cy).v(h).build()); } if ((flag & 1) != 0) { // 00001 m_sb.append("<circle cx=\"") .append(cx) .append("\" cy=\"") .append(cy) .append("\" r=\"") .append(r) .append("\" stroke=\"red\" fill=\"white\"/>"); } x += width; } }
@Override public UrlBuilder path(String path) { /* * Will be an encoded parameter in url ex: * http://stage.bioontology.org/ajax * /jsonp?path=%2Fvirtual%2Fontology%2F1078%2Fall&apikey=YourApiKey */ /* * NOTE: remove /bioportal at front if it is present */ pathBuilder.setPath(path.replaceFirst("^/?bioportal", "")); return this; }
/** * Get the current write version in a plain string. * * @return The current write version * @throws StateAccessException */ @Override public String getWriteVersion() throws StateAccessException { log.trace("Entered ZkSystemDataProvider.getWriteVersion"); String version = cachedWriteVersion.get(); if (version == null) { byte[] data = zk.get(paths.getWriteVersionPath(), writeVersionWatcher); if (data != null) { version = new String(data); cachedWriteVersion.set(version); } } log.trace("Exiting ZkSystemDataProvider.getWriteVersion. " + "Version={}", version); return version; }
private Path createEllipsePath( double centerX, double centerY, double radiusX, double radiusY, double rotate) { ArcTo arcTo = new ArcTo(); arcTo.setX(centerX - radiusX + 1); // to simulate a full 360 degree celcius circle. arcTo.setY(centerY - radiusY); arcTo.setSweepFlag(false); arcTo.setLargeArcFlag(true); arcTo.setRadiusX(radiusX); arcTo.setRadiusY(radiusY); arcTo.setXAxisRotation(rotate); Path path = PathBuilder.create() .elements( new MoveTo(centerX - radiusX, centerY - radiusY), arcTo, new ClosePath()) // close 1 px gap. .build(); path.setStroke(Color.DODGERBLUE); path.getStrokeDashArray().setAll(5d, 5d); return path; }
// @method *static* Move to the x and y without drawing. public static PathBuilder moveTo(double x, double y) { PathBuilder path = new PathBuilder(); path.append(new Segment(Type.MoveTo, x, y)); return path; }
/** Adds a parameter to the "path" attribute which should end up singly-encoded. */ @Override public UrlBuilder parameter(String key, String... values) { pathBuilder.addParameter(key, values); return this; }
@Override public UrlBuilder hash(String hash) { pathBuilder.addHash(hash); return this; }
@Override public String toString() { overallUrlBuilder.parameter("path", pathBuilder.toEncodedString()); return overallUrlBuilder.toString(); }