public virtual void draw(Graphics2D canvas, int offsetX, int offsetY, double factorX, double factorY) { //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int x = (int)System.Math.Round((this.x - offsetX) * factorX); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int y = (int)System.Math.Round((this.y - offsetY) * factorY); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int width = (int)System.Math.Round(this.width * factorX); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int height = (int)System.Math.Round(this.height * factorY); // draw the left oval canvas.setColor(bgcolor); canvas.fillOval(x, y, height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawOval(x, y, height, height); // draw the right oval canvas.setColor(bgcolor); canvas.fillOval(x + width - height, y, height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawOval(x + width - height, y, height, height); // draw the center rectangle canvas.setColor(bgcolor); canvas.fillRect(x + (height / 2), y, width - height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawLine(x + (height / 2), y, x + width - height / 2, y); canvas.drawLine(x + (height / 2), y + height + 1, x + width - height / 2, y + height + 1); // draw the text canvas.setColor(System.Drawing.Color.Black); //UPGRADE_TODO: The equivalent in .NET for method 'java.awt.Color.getRGB' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' if (bgcolor.ToArgb() == System.Drawing.Color.Black.ToArgb()) { canvas.setColor(System.Drawing.Color.White); } if (height > 10) { System.Drawing.Point textpos = calculateTextPosition(text, canvas, width, height); canvas.drawString(text, (int)textpos.X + x, (int)textpos.Y + y); } }
public virtual void draw(Graphics2D canvas, int offsetX, int offsetY, double factorX, double factorY) { //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int x = (int) System.Math.Round((this.x - offsetX) * factorX); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int y = (int) System.Math.Round((this.y - offsetY) * factorY); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int width = (int) System.Math.Round(this.width * factorX); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int height = (int) System.Math.Round(this.height * factorY); // draw the left oval canvas.setColor(bgcolor); canvas.fillOval(x, y, height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawOval(x, y, height, height); // draw the right oval canvas.setColor(bgcolor); canvas.fillOval(x + width - height, y, height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawOval(x + width - height, y, height, height); // draw the center rectangle canvas.setColor(bgcolor); canvas.fillRect(x + (height / 2), y, width - height + 1, height + 1); canvas.setColor(bordercolor); canvas.drawLine(x + (height / 2), y, x + width - height / 2, y); canvas.drawLine(x + (height / 2), y + height + 1, x + width - height / 2, y + height + 1); // draw the text canvas.setColor(System.Drawing.Color.Black); //UPGRADE_TODO: The equivalent in .NET for method 'java.awt.Color.getRGB' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' if (bgcolor.ToArgb() == System.Drawing.Color.Black.ToArgb()) canvas.setColor(System.Drawing.Color.White); if (height > 10) { System.Drawing.Point textpos = calculateTextPosition(text, canvas, width, height); canvas.drawString(text, (int) textpos.X + x, (int) textpos.Y + y); } }
/// <summary> Draws an arrow from the From-Shape to the To-Shape /// with the choosen color. The draw-position is translated /// by (-offsetX,-offsetY) and then scaled by (factorX,factorY). /// </summary> /// <param name="canvas">The canvas to draw the arrow on /// </param> /// <param name="offsetX">Translation-Vector's negative x-component /// </param> /// <param name="offsetY">Translation-Vector's negative y-component /// </param> /// <param name="factorX">Scaling-Vector*s x-component /// </param> /// <param name="factorY">Scaling-Vector*s y-component /// /// </param> public virtual void draw(Graphics2D canvas, int offsetX, int offsetY, double factorX, double factorY) { canvas.setColor(color); /* angleFromTo is this angle ;) * (between -PI;+PI) * TO * ----------------(x)------------------- * / * /) * / @ ) * --------(x)--------------------------- * FROM */ double angleFromTo = System.Math.Atan2(- to.Y + from.Y, to.X - from.X); /* angleToFrom is this angle ;) * (between -PI;+PI) * TO * ----------------(x)------------------- * ( @ / * (/ * / * --------(x)--------------------------- * FROM */ double angleToFrom; if (angleFromTo > 0) { angleToFrom = angleFromTo - System.Math.PI; } else { angleToFrom = angleFromTo + System.Math.PI; } System.Drawing.Point pfrom = from.calculateIntersection(angleFromTo); System.Drawing.Point pto = to.calculateIntersection(angleToFrom); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' System.Drawing.Point parrow1 = new System.Drawing.Point((int) System.Math.Round(6 * System.Math.Cos(angleToFrom + System.Math.PI / 4.0)), (int) System.Math.Round(6 * System.Math.Sin(angleToFrom + System.Math.PI / 4.0))); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' System.Drawing.Point parrow2 = new System.Drawing.Point((int) System.Math.Round(6 * System.Math.Cos(angleToFrom - System.Math.PI / 4.0)), (int) System.Math.Round(6 * System.Math.Sin(angleToFrom - System.Math.PI / 4.0))); pfrom.X -= offsetX; pfrom.Y -= offsetY; pto.X -= offsetX; pto.Y -= offsetY; pfrom.X *= (int) (factorX); pfrom.Y *= (int) (factorY); pto.X *= (int) (factorX); pto.Y *= (int) (factorY); parrow1.X *= (int) (factorX); parrow1.Y *= (int) (factorY); parrow2.X *= (int) (factorX); parrow2.Y *= (int) (factorY); //calculate a good line width //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int linewidth = (int) System.Math.Round(1 * System.Math.Min(factorX, factorY)); if (linewidth == 0) linewidth = 1; canvas.setStroke(new BasicStroke(linewidth)); //draw the arrow canvas.drawLine(pfrom.X, pfrom.Y, pto.X, pto.Y); canvas.drawLine(pto.X + parrow1.X, pto.Y - parrow1.Y, pto.X, pto.Y); canvas.drawLine(pto.X + parrow2.X, pto.Y - parrow2.Y, pto.X, pto.Y); }
/// <summary> Draws an arrow from the From-Shape to the To-Shape /// with the choosen color. The draw-position is translated /// by (-offsetX,-offsetY) and then scaled by (factorX,factorY). /// </summary> /// <param name="canvas">The canvas to draw the arrow on /// </param> /// <param name="offsetX">Translation-Vector's negative x-component /// </param> /// <param name="offsetY">Translation-Vector's negative y-component /// </param> /// <param name="factorX">Scaling-Vector*s x-component /// </param> /// <param name="factorY">Scaling-Vector*s y-component /// /// </param> public virtual void draw(Graphics2D canvas, int offsetX, int offsetY, double factorX, double factorY) { canvas.setColor(color); /* angleFromTo is this angle ;) * (between -PI;+PI) * TO * ----------------(x)------------------- * / * /) * / @ ) * --------(x)--------------------------- * FROM */ double angleFromTo = System.Math.Atan2(-to.Y + from.Y, to.X - from.X); /* angleToFrom is this angle ;) * (between -PI;+PI) * TO * ----------------(x)------------------- * ( @ / * (/ * / * --------(x)--------------------------- * FROM */ double angleToFrom; if (angleFromTo > 0) { angleToFrom = angleFromTo - System.Math.PI; } else { angleToFrom = angleFromTo + System.Math.PI; } System.Drawing.Point pfrom = from.calculateIntersection(angleFromTo); System.Drawing.Point pto = to.calculateIntersection(angleToFrom); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' System.Drawing.Point parrow1 = new System.Drawing.Point((int)System.Math.Round(6 * System.Math.Cos(angleToFrom + System.Math.PI / 4.0)), (int)System.Math.Round(6 * System.Math.Sin(angleToFrom + System.Math.PI / 4.0))); //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' System.Drawing.Point parrow2 = new System.Drawing.Point((int)System.Math.Round(6 * System.Math.Cos(angleToFrom - System.Math.PI / 4.0)), (int)System.Math.Round(6 * System.Math.Sin(angleToFrom - System.Math.PI / 4.0))); pfrom.X -= offsetX; pfrom.Y -= offsetY; pto.X -= offsetX; pto.Y -= offsetY; pfrom.X *= (int)(factorX); pfrom.Y *= (int)(factorY); pto.X *= (int)(factorX); pto.Y *= (int)(factorY); parrow1.X *= (int)(factorX); parrow1.Y *= (int)(factorY); parrow2.X *= (int)(factorX); parrow2.Y *= (int)(factorY); //calculate a good line width //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"' int linewidth = (int)System.Math.Round(1 * System.Math.Min(factorX, factorY)); if (linewidth == 0) { linewidth = 1; } canvas.setStroke(new BasicStroke(linewidth)); //draw the arrow canvas.drawLine(pfrom.X, pfrom.Y, pto.X, pto.Y); canvas.drawLine(pto.X + parrow1.X, pto.Y - parrow1.Y, pto.X, pto.Y); canvas.drawLine(pto.X + parrow2.X, pto.Y - parrow2.Y, pto.X, pto.Y); }