List of usage examples for com.google.gwt.canvas.dom.client Context2d setLineJoin
public final native void setLineJoin(String lineJoin) ;
From source file:com.sencha.gxt.chart.client.draw.engine.Canvas2d.java
License:sencha.com license
protected void appendPath(Context2d ctx, PathSprite sprite) { ctx.beginPath();// w w w.j a v a 2 s . co m sprite.toAbsolute(); // sprite = sprite.copy().toCurve(); PrecisePoint currentPoint = new PrecisePoint(); PrecisePoint movePoint = new PrecisePoint(); PrecisePoint curvePoint = new PrecisePoint(); PrecisePoint quadraticPoint = new PrecisePoint(); appendPathCommands(ctx, sprite.getCommands(), currentPoint, movePoint, curvePoint, quadraticPoint); double opacity = Double.isNaN(sprite.getOpacity()) ? 1.0 : sprite.getOpacity(); if (sprite.getFill() != null && sprite.getFill() != Color.NONE) { ctx.setGlobalAlpha(Double.isNaN(sprite.getFillOpacity()) ? opacity : opacity * sprite.getFillOpacity()); ctx.fill(); } if (sprite.getStroke() != null && sprite.getStroke() != Color.NONE && sprite.getStrokeWidth() != 0) { ctx.setLineCap(sprite.getStrokeLineCap() == null ? LineCap.BUTT : sprite.getStrokeLineCap()); ctx.setLineJoin(sprite.getStrokeLineJoin() == null ? LineJoin.MITER : sprite.getStrokeLineJoin()); ctx.setMiterLimit(sprite.getMiterLimit() == Double.NaN ? 4 : sprite.getMiterLimit()); ctx.setGlobalAlpha( Double.isNaN(sprite.getStrokeOpacity()) ? opacity : opacity * sprite.getStrokeOpacity()); ctx.stroke(); } }
From source file:org.oscim.gdx.client.GwtCanvas.java
License:Open Source License
@Override public void setBitmap(Bitmap bitmap) { this.bitmap = (GwtBitmap) bitmap; Context2d ctx = this.bitmap.pixmap.getContext(); ctx.clearRect(0, 0, this.bitmap.getWidth(), this.bitmap.getHeight()); ctx.setLineJoin(LineJoin.BEVEL); }
From source file:org.rstudio.studio.client.workbench.views.vcs.dialog.graph.GraphLine.java
License:Open Source License
private void draw(Canvas canvas, GraphTheme theme) { int height = theme.getRowHeight(); int colWidth = theme.getColumnWidth(); double pad = theme.getVerticalLinePadding(); canvas.setCoordinateSpaceHeight(height); canvas.setCoordinateSpaceWidth(colWidth * getTotalWidth(theme)); Context2d ctx = canvas.getContext2d(); //ctx.clearRect(0, 0, colWidth * columns_.length, height); ctx.translate(colWidth / 2.0, 0);//from ww w .j a v a 2 s. c om int startPos = -1; int endPos = -1; int nexusColumn = -1; for (int i = 0; i < columns_.length; i++) { GraphColumn c = columns_[i]; if (!c.start) startPos++; if (!c.end) endPos++; ctx.setStrokeStyle(theme.getColorForId(c.id)); ctx.setLineWidth(theme.getStrokeWidth()); ctx.setLineJoin(LineJoin.ROUND); if (!c.nexus && !c.start && !c.end) { // Just draw a line from start to end position ctx.beginPath(); ctx.moveTo(startPos * colWidth, 0); ctx.lineTo(startPos * colWidth, pad); // This next lineTo helps ensure that the shape of the line looks // congruous to any specials on the same line ctx.lineTo(Math.min(startPos, endPos) * colWidth, height / 2.0); ctx.lineTo(endPos * colWidth, height - pad); ctx.lineTo(endPos * colWidth, height); ctx.stroke(); } else { // something special if (c.nexus) { nexusColumn = i; ctx.setFillStyle(theme.getColorForId(c.id)); } if (!c.start) { // draw from i to nexusColumn; ctx.beginPath(); ctx.moveTo(startPos * colWidth, 0); ctx.lineTo(startPos * colWidth, pad); ctx.lineTo(nexusColumn * colWidth, height / 2.0); ctx.stroke(); } if (!c.end) { // draw from nexusColumn to endPosition ctx.beginPath(); ctx.moveTo(nexusColumn * colWidth, height / 2.0); ctx.lineTo(endPos * colWidth, height - pad); ctx.lineTo(endPos * colWidth, height); ctx.stroke(); } } } // draw a circle on the nexus ctx.beginPath(); ctx.arc(nexusColumn * colWidth, height / 2.0, theme.getCircleRadius() + theme.getStrokeWidth(), 0, Math.PI * 2); ctx.closePath(); ctx.fill(); ctx.beginPath(); ctx.arc(nexusColumn * colWidth, height / 2.0, theme.getCircleRadius(), 0, Math.PI * 2); ctx.closePath(); ctx.setFillStyle("white"); ctx.fill(); }