List of usage examples for org.jfree.chart.annotations XYPointerAnnotation setText
public void setText(String text)
From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java
private void _drawSelectedPoint(XYPlot xyplot, int position) { TrackPoint point = this.getTrack().getPointAt(position); // Strelicu crtamo samo ako je samo jedna tocka oznacena: if (this.startSelectedPoints < 0 || this.endSelectedPoints < 0 || this.startSelectedPoints == this.endSelectedPoints) { double angle = point.getAngle(); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("", point.getPosition(), //$NON-NLS-1$ point.getElevation(), Math.PI - angle); xypointerannotation.setTipRadius(3.0D); xypointerannotation.setBaseRadius(30); xypointerannotation.setTextAnchor(TextAnchor.BASELINE_RIGHT); xypointerannotation.setFont(GUIConstants.SANS_SERIF_11); if (angle > 0) { xypointerannotation.setPaint(Color.red); } else if (angle < 0) { xypointerannotation.setPaint(Color.green); } else {/* w w w .j a va 2 s.c o m*/ xypointerannotation.setPaint(Color.gray); } xypointerannotation.setText((TrackProfilerMath.round(100 * angle, 1)) + " %"); //$NON-NLS-1$ xyplot.addAnnotation(xypointerannotation); } ValueMarker valuemarker = new ValueMarker(point.getPosition()); valuemarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); valuemarker.setStroke(new BasicStroke(1.0F)); if (this.startSelectedPoints != this.endSelectedPoints && position == this.startSelectedPoints) { valuemarker.setLabelPaint(Color.blue); valuemarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); // Ispisuje udaljenost i kut: TrackPoint t1 = this.getTrack().getPointAt(this.startSelectedPoints); TrackPoint t2 = this.getTrack().getPointAt(this.endSelectedPoints); double distance3D = TrackProfilerMath.round(t1.getPosition() - t2.getPosition(), 1); String angle = Math.abs(TrackProfilerMath.round(t1.getAngle(t2) * 100, 1)) + "%"; //$NON-NLS-1$ String label = Message.get(Messages.SELECTED_DISTANCE_LABEL) + distance3D + ", " //$NON-NLS-1$ + Message.get(Messages.SELECTED_ANGLE_LABEL) + angle; valuemarker.setLabel(" " + label); //$NON-NLS-1$ valuemarker.setLabelFont(GUIConstants.SANS_SERIF_11); } xyplot.addDomainMarker(valuemarker); }