List of usage examples for java.lang Math sin
@HotSpotIntrinsicCandidate public static double sin(double a)
From source file:de.biomedical_imaging.ij.steger.Width.java
private void fix_locations(double[] width_l, double[] width_r, double[] grad_l, double[] grad_r, double[] pos_x, double[] pos_y, double[] correction, double[] contr, double[] asymm, double sigma, int mode, boolean correct_pos, Line cont) { int i;//from w w w .j a v a 2 s .co m int num_points; double px, py; double nx, ny; double w_est, r_est; MutableDouble w_real, h_real, corr; w_real = new MutableDouble(); h_real = new MutableDouble(); corr = new MutableDouble(); MutableDouble w_strong = new MutableDouble(); MutableDouble w_weak = new MutableDouble(); double correct, asymmetry, response, width, contrast; boolean weak_is_r; boolean correct_start, correct_end; Convol convol = new Convol(); fill_gaps(width_l, grad_l, null, cont); fill_gaps(width_r, grad_r, null, cont); num_points = cont.num; /* Calculate true line width, asymmetry, and position correction. */ if (correct_pos) { /* Do not correct the position of a junction point if its width is found by interpolation, i.e., if the position could be corrected differently for each junction point, thereby destroying the junction. */ correct_start = ((cont.getContourClass() == LinesUtil.contour_class.cont_no_junc || cont.getContourClass() == LinesUtil.contour_class.cont_end_junc || cont.getContourClass() == LinesUtil.contour_class.cont_closed) && (width_r[0] > 0 && width_l[0] > 0)); correct_end = ((cont.getContourClass() == LinesUtil.contour_class.cont_no_junc || cont.getContourClass() == LinesUtil.contour_class.cont_start_junc || cont.getContourClass() == LinesUtil.contour_class.cont_closed) && (width_r[(num_points - 1)] > 0 && width_l[(num_points - 1)] > 0)); /* Calculate the true width and assymetry, and its corresponding correction for each line point. */ for (i = 0; i < num_points; i++) { if (width_r[i] > 0 && width_l[i] > 0) { w_est = (width_r[i] + width_l[i]) * LINE_WIDTH_COMPENSATION; if (grad_r[i] <= grad_l[i]) { r_est = grad_r[i] / grad_l[i]; weak_is_r = true; } else { r_est = grad_l[i] / grad_r[i]; weak_is_r = false; } Correct.line_corrections(sigma, w_est, r_est, w_real, h_real, corr, w_strong, w_weak); w_real.setValue(w_real.getValue() / LINE_WIDTH_COMPENSATION); corr.setValue(corr.getValue() / LINE_WIDTH_COMPENSATION); width_r[i] = w_real.getValue(); width_l[i] = w_real.getValue(); if (weak_is_r) { asymm[i] = h_real.getValue(); correction[i] = -corr.getValue(); } else { asymm[i] = -h_real.getValue(); correction[i] = corr.getValue(); } } } fill_gaps(width_l, correction, asymm, cont); for (i = 0; i < num_points; i++) width_r[i] = width_l[i]; /* Adapt the correction for junction points if necessary. */ if (!correct_start) correction[0] = 0; if (!correct_end) correction[(num_points - 1)] = 0; for (i = 0; i < num_points; i++) { px = pos_x[i]; py = pos_y[i]; nx = Math.cos(cont.angle[i]); ny = Math.sin(cont.angle[i]); px = px + correction[i] * nx; py = py + correction[i] * ny; pos_x[i] = px; pos_y[i] = py; } } /* Update the position of a line and add the extracted width. */ cont.width_l = new float[num_points]; cont.width_r = new float[num_points]; for (i = 0; i < num_points; i++) { cont.width_l[i] = (float) width_l[i]; cont.width_r[i] = (float) width_r[i]; cont.row[i] = (float) pos_x[i]; cont.col[i] = (float) pos_y[i]; } /* Now calculate the true contrast. */ if (correct_pos) { cont.asymmetry = new float[num_points]; cont.intensity = new float[num_points]; for (i = 0; i < num_points; i++) { response = cont.response[i]; asymmetry = Math.abs(asymm[i]); correct = Math.abs(correction[i]); width = cont.width_l[i]; if (width < MIN_LINE_WIDTH) contrast = 0; else contrast = (response / Math.abs(convol.phi2(correct + width, sigma) + (asymmetry - 1) * convol.phi2(correct - width, sigma))); if (contrast > MAX_CONTRAST) contrast = 0; contr[i] = contrast; } fill_gaps(contr, null, null, cont); for (i = 0; i < num_points; i++) { cont.asymmetry[i] = (float) asymm[i]; if (mode == LinesUtil.MODE_LIGHT) cont.intensity[i] = (float) contr[i]; else cont.intensity[i] = (float) -contr[i]; } } }
From source file:com.ushahidi.android.presentation.util.GeoJsonLoadUtility.java
private static boolean windingOrder(JSONArray ring) throws JSONException { float area = 0; if (ring.length() > 2) { for (int i = 0; i < ring.length() - 1; i++) { JSONArray p1 = (JSONArray) ring.get(i); JSONArray p2 = (JSONArray) ring.get(i + 1); area += rad((Double) p2.get(0) - (Double) p1.get(0)) * (2 + Math.sin(rad((Double) p1.get(1))) + Math.sin(rad((Double) p2.get(1)))); }/*from w ww. ja v a2s . c o m*/ } return area > 0; }
From source file:GearTest.java
void addBodyDisks(float shaftRadius, float bodyOuterRadius, float thickness, Appearance look) { int gearBodySegmentVertexCount; // #(segments) per tooth-unit int gearBodyTotalVertexCount; // #(vertices) in a gear face int gearBodyStripCount[] = new int[1]; // per strip (1) vertex count // A ray from the gear center, used in normal calculations float xDirection, yDirection; // The x and y coordinates at each point of a facet and at each // point on the gear: at the shaft, the root of the teeth, and // the outer point of the teeth float xRoot0, yRoot0, xShaft0, yShaft0; float xRoot3, yRoot3, xShaft3, yShaft3; float xRoot4, yRoot4, xShaft4, yShaft4; // Temporary variables for storing coordinates and vectors Point3f coordinate = new Point3f(0.0f, 0.0f, 0.0f); // Gear start differential angle. All gears are constructed with the // center of a tooth at Z-axis angle = 0. double gearStartAngle = -1.0 * toothTopCenterAngle; // Temporaries that store start angle for each portion of tooth facet double toothStartAngle, toothTopStartAngle, toothDeclineStartAngle, toothValleyStartAngle, nextToothStartAngle;/*from ww w .ja v a 2 s . c om*/ Shape3D newShape; int index; // The z coordinates for the body disks final float frontZ = -0.5f * thickness; final float rearZ = 0.5f * thickness; /* * Construct the gear's front body (front facing torus disk) __2__ - | - * 4 - /| /- / / | /| \ 0\ / | / / > \ / | / | > \ / | / / | \ / ____|/ | > * \-- --__/ | 1 3 5 * */ gearBodySegmentVertexCount = 4; gearBodyTotalVertexCount = 2 + gearBodySegmentVertexCount * toothCount; gearBodyStripCount[0] = gearBodyTotalVertexCount; TriangleStripArray frontGearBody = new TriangleStripArray(gearBodyTotalVertexCount, GeometryArray.COORDINATES | GeometryArray.NORMALS, gearBodyStripCount); xDirection = (float) Math.cos(gearStartAngle); yDirection = (float) Math.sin(gearStartAngle); xShaft0 = shaftRadius * xDirection; yShaft0 = shaftRadius * yDirection; xRoot0 = bodyOuterRadius * xDirection; yRoot0 = bodyOuterRadius * yDirection; coordinate.set(xRoot0, yRoot0, frontZ); frontGearBody.setCoordinate(0, coordinate); frontGearBody.setNormal(0, frontNormal); coordinate.set(xShaft0, yShaft0, frontZ); frontGearBody.setCoordinate(1, coordinate); frontGearBody.setNormal(1, frontNormal); for (int count = 0; count < toothCount; count++) { index = 2 + count * 4; toothStartAngle = gearStartAngle + circularPitchAngle * (double) count; toothValleyStartAngle = toothStartAngle + toothValleyAngleIncrement; nextToothStartAngle = toothStartAngle + circularPitchAngle; xDirection = (float) Math.cos(toothValleyStartAngle); yDirection = (float) Math.sin(toothValleyStartAngle); xShaft3 = shaftRadius * xDirection; yShaft3 = shaftRadius * yDirection; xRoot3 = bodyOuterRadius * xDirection; yRoot3 = bodyOuterRadius * yDirection; xDirection = (float) Math.cos(nextToothStartAngle); yDirection = (float) Math.sin(nextToothStartAngle); xShaft4 = shaftRadius * xDirection; yShaft4 = shaftRadius * yDirection; xRoot4 = bodyOuterRadius * xDirection; yRoot4 = bodyOuterRadius * yDirection; coordinate.set(xRoot3, yRoot3, frontZ); frontGearBody.setCoordinate(index, coordinate); frontGearBody.setNormal(index, frontNormal); coordinate.set(xShaft3, yShaft3, frontZ); frontGearBody.setCoordinate(index + 1, coordinate); frontGearBody.setNormal(index + 1, frontNormal); coordinate.set(xRoot4, yRoot4, frontZ); frontGearBody.setCoordinate(index + 2, coordinate); frontGearBody.setNormal(index + 2, frontNormal); coordinate.set(xShaft4, yShaft4, frontZ); frontGearBody.setCoordinate(index + 3, coordinate); frontGearBody.setNormal(index + 3, frontNormal); } newShape = new Shape3D(frontGearBody, look); this.addChild(newShape); // Construct the gear's rear body (rear facing torus disc) TriangleStripArray rearGearBody = new TriangleStripArray(gearBodyTotalVertexCount, GeometryArray.COORDINATES | GeometryArray.NORMALS, gearBodyStripCount); xDirection = (float) Math.cos(gearStartAngle); yDirection = (float) Math.sin(gearStartAngle); xShaft0 = shaftRadius * xDirection; yShaft0 = shaftRadius * yDirection; xRoot0 = bodyOuterRadius * xDirection; yRoot0 = bodyOuterRadius * yDirection; coordinate.set(xShaft0, yShaft0, rearZ); rearGearBody.setCoordinate(0, coordinate); rearGearBody.setNormal(0, rearNormal); coordinate.set(xRoot0, yRoot0, rearZ); rearGearBody.setCoordinate(1, coordinate); rearGearBody.setNormal(1, rearNormal); for (int count = 0; count < toothCount; count++) { index = 2 + count * 4; toothStartAngle = gearStartAngle + circularPitchAngle * (double) count; toothValleyStartAngle = toothStartAngle + toothValleyAngleIncrement; nextToothStartAngle = toothStartAngle + circularPitchAngle; xDirection = (float) Math.cos(toothValleyStartAngle); yDirection = (float) Math.sin(toothValleyStartAngle); xShaft3 = shaftRadius * xDirection; yShaft3 = shaftRadius * yDirection; xRoot3 = bodyOuterRadius * xDirection; yRoot3 = bodyOuterRadius * yDirection; xDirection = (float) Math.cos(nextToothStartAngle); yDirection = (float) Math.sin(nextToothStartAngle); xShaft4 = shaftRadius * xDirection; yShaft4 = shaftRadius * yDirection; xRoot4 = bodyOuterRadius * xDirection; yRoot4 = bodyOuterRadius * yDirection; coordinate.set(xShaft3, yShaft3, rearZ); rearGearBody.setCoordinate(index, coordinate); rearGearBody.setNormal(index, rearNormal); coordinate.set(xRoot3, yRoot3, rearZ); rearGearBody.setCoordinate(index + 1, coordinate); rearGearBody.setNormal(index + 1, rearNormal); coordinate.set(xShaft4, yShaft4, rearZ); rearGearBody.setCoordinate(index + 2, coordinate); rearGearBody.setNormal(index + 2, rearNormal); coordinate.set(xRoot4, yRoot4, rearZ); rearGearBody.setCoordinate(index + 3, coordinate); rearGearBody.setNormal(index + 3, rearNormal); } newShape = new Shape3D(rearGearBody, look); this.addChild(newShape); }
From source file:DashboardInterface.LaunchGraph.java
@Override public void update(String msg) { String[] dataPoint = msg.split(";"); switch (dataPoint[0]) { case "STATE": //addStateMarker(Integer.parseInt(dataPoint[1]), curTime); if (dataPoint[1].equals("3")) { startTime = Double.parseDouble(dataPoint[2]); curTime = startTime;//from w w w . java2 s . co m running = true; } if (dataPoint[1].equals("1") && running) { running = false; } break; case "TENSION": curTime += Double.parseDouble(dataPoint[2]); if (running) addTensionValue(curTime - startTime, Float.parseFloat(dataPoint[1])); break; case "SPEED": if (running) addSpeedValue(curTime - startTime, Float.parseFloat(dataPoint[1])); break; case "OUT": float outLength = Float.parseFloat(dataPoint[1]); float height = (float) (outLength * Math.sin(Math.toRadians(currentAngle))); if (running) addHeightValue(curTime - startTime, height); break; case "ANGLE": currentAngle = Double.parseDouble(dataPoint[1]); break; } }
From source file:com.ibm.bi.dml.runtime.functionobjects.Builtin.java
public double execute(double in) throws DMLRuntimeException { switch (bFunc) { case SIN://from w w w . j a va2 s . c o m return FASTMATH ? FastMath.sin(in) : Math.sin(in); case COS: return FASTMATH ? FastMath.cos(in) : Math.cos(in); case TAN: return FASTMATH ? FastMath.tan(in) : Math.tan(in); case ASIN: return FASTMATH ? FastMath.asin(in) : Math.asin(in); case ACOS: return FASTMATH ? FastMath.acos(in) : Math.acos(in); case ATAN: return Math.atan(in); //faster in Math case CEIL: return FASTMATH ? FastMath.ceil(in) : Math.ceil(in); case FLOOR: return FASTMATH ? FastMath.floor(in) : Math.floor(in); case LOG: //if ( in <= 0 ) // throw new DMLRuntimeException("Builtin.execute(): logarithm can only be computed for non-negative numbers (input = " + in + ")."); // for negative numbers, Math.log will return NaN return FASTMATH ? FastMath.log(in) : Math.log(in); case LOG_NZ: return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in); case ABS: return Math.abs(in); //no need for FastMath case SQRT: //if ( in < 0 ) // throw new DMLRuntimeException("Builtin.execute(): squareroot can only be computed for non-negative numbers (input = " + in + ")."); return Math.sqrt(in); //faster in Math case PLOGP: if (in == 0.0) return 0.0; else if (in < 0) return Double.NaN; else return (in * (FASTMATH ? FastMath.log(in) : Math.log(in))); case EXP: return FASTMATH ? FastMath.exp(in) : Math.exp(in); case ROUND: return Math.round(in); //no need for FastMath case SPROP: //sample proportion: P*(1-P) return in * (1 - in); case SIGMOID: //sigmoid: 1/(1+exp(-x)) return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in)); case SELP: //select positive: x*(x>0) return (in > 0) ? in : 0; default: throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc); } }
From source file:edu.csun.ecs.cs.multitouchj.ui.control.Control.java
protected boolean isWithinWithRotation(Point position) { // topleft, topright, bottomright, bottomleft // get points centered at (0, 0) Size size = getSize();//from www . j a va2 s . c o m Point[] points = new Point[4]; points[0] = new Point(-1 * (size.getWidth() / 2.0f), (size.getHeight() / 2.0f)); points[1] = new Point((size.getWidth() / 2.0f), (size.getHeight() / 2.0f)); points[2] = new Point((size.getWidth() / 2.0f), -1 * (size.getHeight() / 2.0f)); points[3] = new Point(-1 * (size.getWidth() / 2.0f), -1 * (size.getHeight() / 2.0f)); /* log.info("Vertices:"); for(int i = 0; i < points.length; i++) { log.info("\t"+points[i].toString()); } */ // rotate at (0, 0) double rotationInDegree = getRotation(); double rotationInRadian = Math.toRadians(rotationInDegree); for (Point point : points) { double rotatedX = (point.getX() * Math.cos(rotationInRadian)) - (point.getY() * Math.sin(rotationInRadian)); double rotatedY = (point.getX() * Math.sin(rotationInRadian)) + (point.getY() * Math.cos(rotationInRadian)); point.set((float) rotatedX, (float) rotatedY); } /* log.info("Rotated Vertices:"); for(int i = 0; i < points.length; i++) { log.info("\t"+points[i].toString()); } */ // check to see if position is above or below the slope of sides of // this rectangle DisplayMode displayMode = windowManager.getDisplayManager().getCurrentDisplayMode(); Point center = getOpenGlPosition(); Point centeredPosition = OpenGlUtility .getOpenGlPosition(new Size(displayMode.getWidth(), displayMode.getHeight()), position); //log.info("Position GL: "+centeredPosition.toString()); centeredPosition.minus(center); //log.info("Center: "+center.toString()); //log.info("Position: "+position.toString()); //log.info("Centered: "+centeredPosition.toString()); boolean[] results = new boolean[points.length]; for (int i = 0; i < points.length; i++) { Point target1 = points[i]; Point target2 = points[((i + 1) % points.length)]; Point target3 = points[((i + 2) % points.length)]; double targetValue = (centeredPosition.getY() - target1.getY()); if (target2.getX() != target1.getX()) { targetValue = (centeredPosition.getY() - target1.getY()) - ((target2.getY() - target1.getY()) / (target2.getX() - target1.getX())) * (centeredPosition.getX() - target1.getX()); } double testValue = (target3.getY() - target1.getY()); if (target2.getX() != target1.getX()) { testValue = (target3.getY() - target1.getY()) - ((target2.getY() - target1.getY()) / (target2.getX() - target1.getX())) * (target3.getX() - target1.getX()); } //log.info("target: "+targetValue+", test: "+testValue); results[i] = (targetValue == 0.0); if (((targetValue > 0.0) && (testValue > 0.0)) || ((targetValue < 0.0) && (testValue < 0.0))) { results[i] = true; } } /* log.info("Results:"); for(int i = 0; i < results.length; i++) { log.info("\t"+results[i]); } */ boolean isWithin = true; for (boolean result : results) { if (!result) { isWithin = false; break; } } /* float[] results = new float[points.length]; for(int i = 0; i < points.length; i++) { Point target1 = points[i]; Point target2 = points[((i + 1) % points.length)]; float targetValue = (centeredPosition.getY() - target1.getY()); if(target2.getX() != target1.getX()) { targetValue = (centeredPosition.getY() - target1.getY()) - ((target2.getY() - target1.getY()) / (target2.getX() - target1.getX())) * (centeredPosition.getX() - target1.getX()); } results[i] = targetValue; } log.info("Results:"); for(int i = 0; i < results.length; i++) { log.info("\t"+results[i]); } boolean isWithin = false; for(float result : results) { if(result == 0.0f) { isWithin = true; break; } } if(!isWithin) { int numberOfAboves = 0; for(float result : results) { if(result > 0.0f) { numberOfAboves += 1; } } if(numberOfAboves == 2) { isWithin = true; } } */ //log.info("isWithin: "+isWithin); return isWithin; }
From source file:com.oncore.calorders.core.utils.FormatHelper.java
public static Double getGpsDistance(Double lat1, Double lon1, Double lat2, Double lon2) { Double distance;/* www. j av a 2s .co m*/ if (lat1 == null || lon1 == null || lat2 == null || lon2 == null) { //throw new IllegalArgumentException("Coordinates passed can not be null"); distance = 1000d; } else { double radius = 6371 * 0.621371; double dLat = (lat2 - lat1) * Math.PI / 180; double dLon = (lon2 - lon1) * Math.PI / 180; double arc = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2); double curve = 2 * Math.atan2(Math.sqrt(arc), Math.sqrt(1 - arc)); distance = radius * curve; } return distance; }
From source file:Matrix4x4.java
/** * Apply rotation around X axis to this matrix. * /*from w w w . j a v a2s . c om*/ * @param angle Angle to rotate [radians]. */ public void rotateX(double angle) { Matrix4x4 rotationMatrix = new Matrix4x4(); double cosAngle = Math.cos(angle); double sinAngle = Math.sin(angle); rotationMatrix.setElement(1, 1, cosAngle); rotationMatrix.setElement(1, 2, sinAngle); rotationMatrix.setElement(2, 1, -sinAngle); rotationMatrix.setElement(2, 2, cosAngle); multiply(rotationMatrix); }
From source file:electrical_parameters.Carson.java
public void calcRg() { // this.Rg = this.Dik.copy(); // this.Rg = clearMatrix(this.Rg); double[] b;/*from ww w . ja va2 s . c o m*/ double[] c; double[] d; double kik_rg; double fik; b = b(); c = c(); d = d(); calckik(); for (int i = 0; i < this.kik.getRowDimension(); i++) { for (int j = 0; j < this.kik.getColumnDimension(); j++) { fik = this.Fik.getEntry(i, j); kik_rg = this.kik.getEntry(i, j); this.Rg.setEntry(i, j, (4e-4) * omega * (Math.PI / 8 - b[0] * kik_rg * Math.cos(fik) + b[1] * ((c[1] - Math.log(kik_rg)) * pow(kik_rg, 2) * Math.cos(2 * fik) + fik * pow(kik_rg, 2) * Math.sin(2 * fik)) + b[2] * pow(kik_rg, 3) * Math.cos(3 * fik) - d[3] * pow(kik_rg, 4) * Math.cos(4 * fik) - b[4] * kik_rg * Math.cos(fik) + b[5] * ((c[5] - Math.log(kik_rg)) * pow(kik_rg, 2) * Math.cos(2 * fik) + fik * pow(kik_rg, 2) * Math.sin(2 * fik)) + b[6] * pow(kik_rg, 3) * Math.cos(3 * fik) - d[7] * pow(kik_rg, 4) * Math.cos(4 * fik))); } } }
From source file:org.trade.ui.chart.renderer.PivotRenderer.java
/** * Draws the annotation./*from w w w . jav a 2 s . c om*/ * * @param g2 * the graphics device. * @param plot * the plot. * @param dataArea * the data area. * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param rendererIndex * the renderer index. * @param info * the plot rendering info. * @param angle * double * @param x * double * @param y * double * @param ledgend * String */ public void drawPivotArrow(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info, double angle, double x, double y, String ledgend) { double tipRadius = DEFAULT_TIP_RADIUS; double baseRadius = DEFAULT_BASE_RADIUS; double arrowLength = DEFAULT_ARROW_LENGTH; double arrowWidth = DEFAULT_ARROW_WIDTH; double labelOffset = DEFAULT_LABEL_OFFSET; Font font = DEFAULT_FONT; Paint paint = DEFAULT_PAINT; boolean outlineVisible = false; Paint outlinePaint = Color.black; Stroke outlineStroke = new BasicStroke(0.5f); TextAnchor textAnchor = DEFAULT_TEXT_ANCHOR; TextAnchor rotationAnchor = DEFAULT_ROTATION_ANCHOR; double rotationAngle = DEFAULT_ROTATION_ANGLE; Stroke arrowStroke = new BasicStroke(1.0f); Paint arrowPaint = Color.black; PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); double j2DX = domainAxis.valueToJava2D(x, dataArea, domainEdge); double j2DY = rangeAxis.valueToJava2D(y, dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { double temp = j2DX; j2DX = j2DY; j2DY = temp; } double startX = j2DX + (Math.cos(angle) * baseRadius); double startY = j2DY + (Math.sin(angle) * baseRadius); double endX = j2DX + (Math.cos(angle) * tipRadius); double endY = j2DY + (Math.sin(angle) * tipRadius); double arrowBaseX = endX + (Math.cos(angle) * arrowLength); double arrowBaseY = endY + (Math.sin(angle) * arrowLength); double arrowLeftX = arrowBaseX + (Math.cos(angle + (Math.PI / 2.0)) * arrowWidth); double arrowLeftY = arrowBaseY + (Math.sin(angle + (Math.PI / 2.0)) * arrowWidth); double arrowRightX = arrowBaseX - (Math.cos(angle + (Math.PI / 2.0)) * arrowWidth); double arrowRightY = arrowBaseY - (Math.sin(angle + (Math.PI / 2.0)) * arrowWidth); GeneralPath arrow = new GeneralPath(); arrow.moveTo((float) endX, (float) endY); arrow.lineTo((float) arrowLeftX, (float) arrowLeftY); arrow.lineTo((float) arrowRightX, (float) arrowRightY); arrow.closePath(); g2.setStroke(arrowStroke); g2.setPaint(arrowPaint); Line2D line = new Line2D.Double(startX, startY, endX, endY); g2.draw(line); g2.fill(arrow); // draw the label double labelX = j2DX + (Math.cos(angle) * (baseRadius + labelOffset)); double labelY = j2DY + (Math.sin(angle) * (baseRadius + labelOffset)); g2.setFont(font); Shape hotspot = TextUtilities.calculateRotatedStringBounds(ledgend, g2, (float) labelX, (float) labelY, textAnchor, rotationAngle, rotationAnchor); g2.setPaint(paint); TextUtilities.drawRotatedString(ledgend, g2, (float) labelX, (float) labelY, textAnchor, rotationAngle, rotationAnchor); if (outlineVisible) { g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(hotspot); } // String toolTip = getToolTipText(); // String url = getURL(); // if (toolTip != null || url != null) { // addEntity(info, hotspot, rendererIndex, toolTip, url); // } }