Adds a legend. The legend will be always drawn last (on top of everything). To modify the legend's style, call 'setFont' and 'setLineWidth' before 'addLegend' @param labels labels of the points or curves in the sequence of the data were added, tab-delimited or linefeed-delimited. The labels of the d
(String labels, int flags)
| 1098 | * @param flags Bitwise or of position (AUTO_POSITION, TOP_LEFT etc.), LEGEND_TRANSPARENT, and LEGEND_BOTTOM_UP if desired. |
| 1099 | * Updates the image (if it is shown already). */ |
| 1100 | public void setLegend(String labels, int flags) { |
| 1101 | if (labels != null && labels.length()>0) { |
| 1102 | String[] allLabels = labels.split("[\n\t]"); |
| 1103 | int iPart = 0; |
| 1104 | for (PlotObject plotObject : allPlotObjects) |
| 1105 | if (plotObject.type == PlotObject.XY_DATA && !plotObject.hasFlag(PlotObject.HIDDEN)) |
| 1106 | if (iPart < allLabels.length) { |
| 1107 | String label = allLabels[iPart++]; |
| 1108 | if (label!=null && label.length()>0) |
| 1109 | plotObject.label = label; |
| 1110 | } |
| 1111 | } |
| 1112 | pp.legend = new PlotObject(currentLineWidth == 0 ? 1 : currentLineWidth, |
| 1113 | currentFont, currentColor == null ? Color.black : currentColor, flags); |
| 1114 | if (plotDrawn) updateImage(); |
| 1115 | } |
| 1116 | |
| 1117 | /** Sets the label for the plot object number 'index' in the sequence they were added. |
| 1118 | * With index=-1, sets the label for the last object added. |
no test coverage detected