List of usage examples for com.google.gwt.canvas.dom.client Context2d arc
public final native void arc(double x, double y, double radius, double startAngle, double endAngle) ;
From source file:com.google.gwt.maeglin89273.shared.test.volcanogame.component.FireBall.java
@Override public void draw(Context2d context) { context.setFillStyle(ballColor);/*from w ww .ja v a2s.co m*/ //context.setShadowColor(ballShadowColor.toString()); context.beginPath(); context.arc(position.getX(), position.getY(), radius, 0, 2 * Math.PI); context.closePath(); context.fill(); }
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.PieChart.java
License:Apache License
/** * Redraw the pie chart.//from ww w . ja v a 2s . co m */ public void redraw() { if (!isAttached()) { return; } // Get the dimensions of the chart. int width = canvas.getCoordinateSpaceWidth(); int height = canvas.getCoordinateSpaceHeight(); double radius = Math.min(width, height) / 2.0; double cx = width / 2.0; double cy = height / 2.0; // Clear the context. Context2d context = canvas.getContext2d(); context.clearRect(0, 0, width, height); // Get the total weight of all slices. double totalWeight = 0; for (Slice slice : slices) { totalWeight += slice.weight; } // Draw the slices. double startAngle = -0.5 * Math.PI; for (Slice slice : slices) { double weight = slice.weight / totalWeight; double endAngle = startAngle + (weight * RADIANS_IN_CIRCLE); context.setFillStyle(slice.fill); context.beginPath(); context.moveTo(cx, cy); context.arc(cx, cy, radius, startAngle, endAngle); context.fill(); startAngle = endAngle; } }
From source file:com.sencha.gxt.chart.client.draw.engine.Canvas2d.java
License:sencha.com license
/** * In the Canvas2d class, this method does more or less what renderSprite does in SVG and VML - it * actually renders the sprite to the dom. * @param sprite the sprite to draw/*from w w w . j a v a 2 s. c om*/ */ protected void append(Sprite sprite) { if (sprite.isHidden() || sprite.getOpacity() == 0) { return; } Context2d ctx = getContext(); ctx.save(); //set global stuff, fill, stroke, clip, etc //clip - deal with translation or normal rectangle if (sprite.getClipRectangle() != null) { PreciseRectangle clip = sprite.getClipRectangle(); if (sprite.getScaling() != null || sprite.getTranslation() != null || sprite.getRotation() != null) { PathSprite transPath = new PathSprite(new RectangleSprite(clip)); transPath = transPath.map(sprite.transformMatrix()); appendPath(ctx, transPath); } else { ctx.beginPath(); ctx.rect(clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight()); ctx.closePath(); } ctx.clip(); } if (sprite.getScaling() != null || sprite.getTranslation() != null || sprite.getRotation() != null || (component.isViewBox() && viewbox != null)) { Matrix matrix = sprite.transformMatrix(); if (matrix != null) { //TODO consider replacing this transform call with three distinct calls to translate/scale/rotate if cheaper ctx.transform(matrix.get(0, 0), matrix.get(1, 0), matrix.get(0, 1), matrix.get(1, 1), matrix.get(0, 2), matrix.get(1, 2)); } if (component.isViewBox() && viewbox != null) { double size = Math.min(getWidth() / viewbox.getWidth(), getHeight() / viewbox.getHeight()); ctx.scale(size, size); ctx.translate(-viewbox.getX(), -viewbox.getY()); } } //TODO see about caching colors via the dirty flag? If we don't use a color/gradient for a pass or three, dump it double opacity = Double.isNaN(sprite.getOpacity()) ? 1.0 : sprite.getOpacity(); PreciseRectangle untransformedBbox = sprite.getPathSprite().dimensions(); if (sprite.getStroke() != null && sprite.getStroke() != Color.NONE && sprite.getStrokeWidth() != 0) { ctx.setLineWidth(Double.isNaN(sprite.getStrokeWidth()) ? 1.0 : sprite.getStrokeWidth()); ctx.setStrokeStyle(getColor(sprite.getStroke(), untransformedBbox));//TODO read bbox from cache } if (sprite.getFill() != null && sprite.getFill() != Color.NONE) { ctx.setFillStyle(getColor(sprite.getFill(), untransformedBbox));//TODO read bbox from cache } if (sprite instanceof PathSprite) { appendPath(ctx, (PathSprite) sprite); } else if (sprite instanceof TextSprite) { TextSprite text = (TextSprite) sprite; //TODO style and weight ctx.setFont(text.getFontSize() + "px " + text.getFont()); ctx.setTextAlign(getTextAlign(text.getTextAnchor())); ctx.setTextBaseline(getTextBaseline(text.getTextBaseline())); ctx.fillText(text.getText(), text.getX(), text.getY()); } else if (sprite instanceof RectangleSprite) { RectangleSprite rect = (RectangleSprite) sprite; if (Double.isNaN(rect.getRadius()) || rect.getRadius() == 0) { if (sprite.getFill() != null && sprite.getFill() != Color.NONE) { ctx.setGlobalAlpha( Double.isNaN(sprite.getFillOpacity()) ? opacity : opacity * sprite.getFillOpacity()); ctx.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); } if (sprite.getStroke() != null && sprite.getStroke() != Color.NONE && sprite.getStrokeWidth() != 0) { ctx.setGlobalAlpha(Double.isNaN(sprite.getStrokeOpacity()) ? opacity : opacity * sprite.getStrokeOpacity()); ctx.strokeRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); } } else { appendPath(ctx, rect.getPathSprite()); } } else if (sprite instanceof CircleSprite) { CircleSprite circle = (CircleSprite) sprite; ctx.beginPath(); ctx.arc(circle.getCenterX(), circle.getCenterY(), circle.getRadius(), 0, 2 * Math.PI); ctx.closePath(); 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.setGlobalAlpha( Double.isNaN(sprite.getStrokeOpacity()) ? opacity : opacity * sprite.getStrokeOpacity()); ctx.stroke(); } } else if (sprite instanceof EllipseSprite) { appendPath(ctx, sprite.getPathSprite()); } else if (sprite instanceof ImageSprite) { ImageSprite image = (ImageSprite) sprite; ImageElement elt = Document.get().createImageElement(); elt.setSrc(image.getResource().getSafeUri().asString()); ctx.drawImage(elt, image.getX(), image.getY(), image.getWidth(), image.getHeight()); } ctx.restore(); if (!REDRAW_ALL) { renderedBbox.put(sprite, getBBox(sprite)); } sprite.clearDirtyFlags(); }
From source file:edu.umb.jsPedigrees.client.Pelican.PelicanPerson.java
License:Open Source License
public void drawSymbol() { Context2d ctx = canvas.getContext2d(); // clear old symbol ctx.clearRect(0, 0, symbolSize + 1, symbolSize + 1); ctx.setStrokeStyle(CssColor.make("0,0,0")); ctx.setLineWidth(1.0f);/*from w w w. j a v a 2 s. c o m*/ if (sex == male) { ctx.strokeRect(0, 0, symbolSize, symbolSize); if (affection == affected) { ctx.fillRect(0, 0, symbolSize, symbolSize); } } if (sex == female) { // g2.drawArc(0,0,symbolSize,symbolSize,0,360); ctx.beginPath(); ctx.arc(symbolSize / 2, symbolSize / 2, (symbolSize / 2) - 1, 0, 360); if (affection == affected) { ctx.fill(); } else { ctx.stroke(); } } }
From source file:examples.geometry.AbstractExample.java
License:Open Source License
@Override public void draw() { Context2d context = canvas.getContext2d(); // reset/* w ww.ja va2 s . c o m*/ context.clearRect(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight()); context.setFillStyle("black"); context.setStrokeStyle("black"); context.setLineWidth(1); for (ControllableShape shape : getControllableShapes()) { // e.gc.setForeground(canvas.getDisplay().getSystemColor(shape.shapeColor)); // e.gc.setBackground(canvas.getDisplay().getSystemColor(shape.shapeColor)); shape.onDraw(canvas); } for (ControllableShape shape : getControllableShapes()) { if (shape.isActive()) { FillStrokeStyle fillStyle = context.getFillStyle(); for (ControlPoint cp : shape.controlPoints) { context.beginPath(); context.arc(cp.getX(), cp.getY(), shape.controlRadius, 0, 180); context.setFillStyle(shape.controlColor); context.fill(); context.closePath(); } context.setFillStyle(fillStyle); } } }
From source file:examples.geometry.demos.CubicCurveDeCasteljauExample.java
License:Open Source License
@Override protected ControllableShape[] createShapes(Canvas canvas, EventBus eventBus) { return new ControllableShape[] { new ControllableShape(canvas, eventBus) { {//from w w w .j a v a2 s. c o m /* * These are the control points used to construct the CubicCurve * later. */ addControlPoints(new Point(100, 200), new Point(200, 100), new Point(300, 300), new Point(400, 200)); } @Override public CubicCurve getShape() { /* * Constructs the CubicCurve of the defined control points. */ return new CubicCurve(getPoints()); } @Override public void onDraw(Canvas canvas) { Context2d context = canvas.getContext2d(); /* * Draws the CubicCurve and the de Casteljau construction for * the current parameter value. */ // Construct the CubicCurve from the defined control points. CubicCurve curve = getShape(); CanvasDrawer.strokePath(curve.toPath(), context); /* * Retrieve control points to compute the linear interpolations * of the de Casteljau algorithm. */ Point[] points = getPoints(); /* * Define the colors for the intermediate lines. We have three * stages and therefore three different colors for a cubic * Bezier curve. This is the case, because the de Casteljau * algorithm reduces the number of control points in each * iteration until it reaches the actual point on the curve. */ String[] colors = new String[] { "green", "blue", "red" }; for (int ci = 0; ci < colors.length; ci++) { for (int i = 0; i < 3 - ci; i++) { context.beginPath(); context.moveTo(points[i].x, points[i].y); context.lineTo(points[i + 1].x, points[i + 1].y); context.setStrokeStyle(colors[ci]); context.stroke(); context.closePath(); // interpolate point for the next iteration points[i] = new Line(points[i], points[i + 1]).get(parameterValue); // draw point context.beginPath(); context.arc(points[i].x, points[i].y, 2, 0, 180); context.setStrokeStyle("black"); context.stroke(); context.closePath(); } } } } }; }
From source file:org.primordion.xholon.io.GridPanel.java
License:Open Source License
/** * Draw agents within the current grid cell. * Only one agent is drawn, for now./*from w ww . j a v a 2 s . c om*/ * GWT code to draw a triangle: <code> Canvas canvas = Canvas.createIfSupported(); Context2d context1 = canvas.getContext2d(); context1.beginPath(); context1.moveTo(25,0); context1.lineTo(0,20); context1.lineTo(25,40); context1.lineTo(25,0); context1.fill(); context1.closePath(); </code> * @param ctx A GWT Context2d object. * @param currentCell The grid cell that the agents will draw themselves in. * @param x X coordinate of the grid cell. * @param y Y coordinate of the grid cell. */ protected void drawAgents(Context2d ctx, AbstractGrid currentCell, int x, int y) { IXholon agent = currentCell.getFirstChild(); // this should remain as getFirstChild() if (agent != null) { if (useIcons) { // Test of drawImage() String icon = ((IDecoration) agent.getXhc()).getIcon(); if (icon != null) { drawImage(ctx, icon, x, y, cellSize, cellSize); return; } } ctx.setFillStyle(getColor(agent)); int shape = getShape(agent); switch (shape) { case GPSHAPE_CIRCLE: // OK { ctx.beginPath(); int xcentre = x + (int) (cellSize * 0.5); int ycentre = y + (int) (cellSize * 0.5); int radius = (int) (cellSize * 0.45); ctx.arc(xcentre, ycentre, radius, 0, Math.PI * 2); ctx.closePath(); ctx.fill(); } break; case GPSHAPE_TRIANGLE: // OK { int xCoor[] = { (int) (0.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize) }; int yCoor[] = { (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.0 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 3); //Polygon triangle = new Polygon(xCoor, yCoor, 3); //triangle.translate(x, y); //g.fillPolygon(triangle); /*ctx.save(); ctx.translate(x, y); ctx.beginPath(); ctx.moveTo(0.0*cellSize, 1.0*cellSize); ctx.lineTo(1.0*cellSize, 1.0*cellSize); ctx.lineTo(0.5*cellSize, 0.0*cellSize); ctx.lineTo(0.0*cellSize, 1.0*cellSize); ctx.fill(); ctx.closePath(); ctx.restore();*/ } break; case GPSHAPE_RECTANGLE: // OK { int xCoor[] = { (int) (0.1 * cellSize), (int) (0.9 * cellSize), (int) (0.9 * cellSize), (int) (0.1 * cellSize) }; int yCoor[] = { (int) (0.9 * cellSize), (int) (0.9 * cellSize), (int) (0.1 * cellSize), (int) (0.1 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 4); //Polygon rectangle = new Polygon(xCoor, yCoor, 4); //rectangle.translate(x, y); //g.fillPolygon(rectangle); /*ctx.save(); ctx.translate(x, y); ctx.beginPath(); ctx.moveTo(0.1*cellSize, 0.9*cellSize); ctx.lineTo(0.9*cellSize, 0.9*cellSize); ctx.lineTo(0.9*cellSize, 0.1*cellSize); ctx.lineTo(0.1*cellSize, 0.1*cellSize); ctx.lineTo(0.1*cellSize, 0.9*cellSize); ctx.fill(); ctx.closePath(); ctx.restore();*/ } break; case GPSHAPE_PENTAGON: { int xCoor[] = { (int) (0.2 * cellSize), (int) (0.8 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize), (int) (0.0 * cellSize), (int) (0.5 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 5); //Polygon pentagon = new Polygon(xCoor, yCoor, 5); //pentagon.translate(x, y); //g.fillPolygon(pentagon); } break; case GPSHAPE_HEXAGON: { int xCoor[] = { (int) (0.25 * cellSize), (int) (0.75 * cellSize), (int) (1.0 * cellSize), (int) (0.75 * cellSize), (int) (0.25 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize), (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (0.5 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 6); //ctx.beginPath(); //drawPolygon(ctx, x, y, 0.5, 6, 0, false); //ctx.fill(); //Polygon hexagon = new Polygon(xCoor, yCoor, 6); //hexagon.translate(x, y); //g.fillPolygon(hexagon); } break; case GPSHAPE_OCTOGON: { int xCoor[] = { (int) (0.3 * cellSize), (int) (0.7 * cellSize), (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.7 * cellSize), (int) (0.3 * cellSize), (int) (0.0 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.7 * cellSize), (int) (0.3 * cellSize), (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (0.3 * cellSize), (int) (0.7 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 8); //Polygon octogon = new Polygon(xCoor, yCoor, 8); //octogon.translate(x, y); //g.fillPolygon(octogon); } break; case GPSHAPE_STAR: { int xCoor[] = { (int) (0.5 * cellSize), (int) (1.0 * cellSize), (int) (0.8 * cellSize), (int) (1.0 * cellSize), (int) (0.7 * cellSize), (int) (0.5 * cellSize), (int) (0.3 * cellSize), (int) (0.0 * cellSize), (int) (0.2 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (0.8 * cellSize), (int) (1.0 * cellSize), (int) (0.7 * cellSize), (int) (0.4 * cellSize), (int) (0.4 * cellSize), (int) (0.0 * cellSize), (int) (0.4 * cellSize), (int) (0.4 * cellSize), (int) (0.7 * cellSize), (int) (1.0 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 10); //Polygon star = new Polygon(xCoor, yCoor, 10); //star.translate(x, y); //g.fillPolygon(star); } break; case GPSHAPE_TURTLE: { int xCoor[] = { (int) (0.5 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (0.7 * cellSize), (int) (1.0 * cellSize), (int) (0.0 * cellSize), (int) (1.0 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 4); //Polygon turtle = new Polygon(xCoor, yCoor, 4); //turtle.translate(x, y); //g.fillPolygon(turtle); } break; case GPSHAPE_SMALLCIRCLE: { ctx.beginPath(); int xcentre = x + (int) (cellSize * 0.5); int ycentre = y + (int) (cellSize * 0.5); int radius = (int) (cellSize * 0.25); ctx.arc(xcentre, ycentre, radius, 0, Math.PI * 2); ctx.closePath(); ctx.fill(); } break; case GPSHAPE_SMALLRECTANGLE: { int xCoor[] = { (int) (0.25 * cellSize), (int) (0.75 * cellSize), (int) (0.75 * cellSize), (int) (0.25 * cellSize) }; int yCoor[] = { (int) (0.75 * cellSize), (int) (0.75 * cellSize), (int) (0.25 * cellSize), (int) (0.25 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 4); } break; case GPSHAPE_REVERSETRIANGLE: { int xCoor[] = { (int) (0.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize) }; int yCoor[] = { (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (1.0 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 3); } break; case GPSHAPE_CROSS: { int xCoor[] = { (int) (0.33 * cellSize), (int) (0.67 * cellSize), (int) (0.67 * cellSize), (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.67 * cellSize), (int) (0.67 * cellSize), (int) (0.33 * cellSize), (int) (0.33 * cellSize), (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (0.33 * cellSize) }; int yCoor[] = { (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (0.33 * cellSize), (int) (0.33 * cellSize), (int) (0.67 * cellSize), (int) (0.67 * cellSize), (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.67 * cellSize), (int) (0.67 * cellSize), (int) (0.33 * cellSize), (int) (0.33 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 12); } break; case GPSHAPE_DIAMOND: { int xCoor[] = { (int) (0.5 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (0.0 * cellSize), (int) (0.5 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 4); } break; case GPSHAPE_WYE: { int xCoor[] = { (int) (0.25 * cellSize), (int) (0.5 * cellSize), (int) (0.75 * cellSize), (int) (1.0 * cellSize), (int) (0.75 * cellSize), (int) (0.75 * cellSize), (int) (0.25 * cellSize), (int) (0.25 * cellSize), (int) (0.0 * cellSize), }; int yCoor[] = { (int) (0.0 * cellSize), (int) (0.25 * cellSize), (int) (0.0 * cellSize), (int) (0.25 * cellSize), (int) (0.75 * cellSize), (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.75 * cellSize), (int) (0.25 * cellSize), }; drawPolygon(ctx, x, y, xCoor, yCoor, 9); } break; case GPSHAPE_LRTRIANGLE: { int xCoor[] = { (int) (0.0 * cellSize), (int) (0.0 * cellSize), (int) (1.0 * cellSize) }; int yCoor[] = { (int) (0.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 3); } break; case GPSHAPE_RLTRIANGLE: { int xCoor[] = { (int) (1.0 * cellSize), (int) (1.0 * cellSize), (int) (0.0 * cellSize) }; int yCoor[] = { (int) (0.0 * cellSize), (int) (1.0 * cellSize), (int) (0.5 * cellSize) }; drawPolygon(ctx, x, y, xCoor, yCoor, 3); } break; case GPSHAPE_JAVASCRIPTCODE: this.makeJsShape(ctx, ((IDecoration) agent.getXhc()).getSymbol().substring(JSCODE_INDICATOR_LEN), x, y, cellSize); break; case GPSHAPE_NOSHAPE: break; default: // the agent's shape directly specifies the number of sides { ctx.beginPath(); drawPolygon(ctx, x, y, cellSize * 0.5, shape, 0, false); ctx.fill(); } } } }
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);/*w w w. java 2 s . c o m*/ 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(); }
From source file:stroom.widget.htree.client.BracketConnectorRenderer.java
License:Apache License
private void drawTop(final Context2d ctx, final double midX, final double minX, final double maxX, final double y1, final double y2) { final double maxY = y1 - RADIUS; final double minY = y2 + RADIUS; // Draw top of bracket ctx.beginPath();//w ww . jav a 2 s . c o m ctx.moveTo(midX, maxY); ctx.arc(minX, maxY, RADIUS, 0, HALF_PI); ctx.moveTo(midX, maxY); ctx.lineTo(midX, minY); ctx.moveTo(midX, minY); ctx.arc(maxX, minY, RADIUS, Math.PI, ONE_AND_HALF_PI); ctx.setStrokeStyle(lineColor); ctx.stroke(); }
From source file:stroom.widget.htree.client.BracketConnectorRenderer.java
License:Apache License
private void drawBottom(final Context2d ctx, final double midX, final double minX, final double maxX, final double y1, final double y2) { final double minY = y1 + RADIUS; final double maxY = y2 - RADIUS; // Draw bottom of bracket ctx.beginPath();/*from www . ja v a2s . com*/ ctx.moveTo(minX, y1); ctx.arc(minX, minY, RADIUS, ONE_AND_HALF_PI, 0); ctx.moveTo(midX, minY); ctx.lineTo(midX, maxY); ctx.moveTo(maxX, y2); ctx.arc(maxX, maxY, RADIUS, HALF_PI, Math.PI); ctx.setStrokeStyle(lineColor); ctx.stroke(); }