MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / drawPlotObject

Method drawPlotObject

ij/src/main/java/ij/gui/Plot.java:3235–3483  ·  view source on GitHub ↗
(PlotObject plotObject, ImageProcessor ip)

Source from the content-addressed store, hash-verified

3233 }
3234
3235 @AstroImageJ(reason = """
3236 widen access
3237 don't draw transparent objects
3238 support drawing labels inline with x axis label
3239 """, modified = true)
3240 protected void drawPlotObject(PlotObject plotObject, ImageProcessor ip) {
3241 //var plotObject = (PlotObject) iPlotObject;
3242 //IJ.log("DRAWING type="+plotObject.type+" lineWidth="+plotObject.lineWidth+" shape="+plotObject.shape);
3243 if (plotObject.hasFlag(PlotObject.HIDDEN)) return;
3244 if (plotObject.color.getAlpha() == 0) return;
3245 ip.setColor(plotObject.color);
3246 ip.setLineWidth(sc(plotObject.lineWidth));
3247 int type = plotObject.type;
3248 switch (type) {
3249 case PlotObject.XY_DATA:
3250 ip.setClipRect(frame);
3251 int nPoints = Math.min(plotObject.xValues.length, plotObject.yValues.length);
3252
3253 if (plotObject.shape==BAR || plotObject.shape==SEPARATED_BAR)
3254 drawBarChart(plotObject); // (separated) bars
3255
3256 if (plotObject.shape == FILLED) { // filling below line
3257 ip.setColor(plotObject.color2 != null ? plotObject.color2 : plotObject.color);
3258 drawFloatPolyLineFilled(ip, plotObject.xValues, plotObject.yValues, nPoints);
3259 }
3260 ip.setColor(plotObject.color);
3261 ip.setLineWidth(sc(plotObject.lineWidth));
3262
3263 if (plotObject.yEValues != null) // error bars in front of bars and fill area below the line, but behind lines and marker symbols
3264 drawVerticalErrorBars(plotObject.xValues, plotObject.yValues, plotObject.yEValues);
3265 if (plotObject.xEValues != null)
3266 drawHorizontalErrorBars(plotObject.xValues, plotObject.yValues, plotObject.xEValues);
3267
3268 if (plotObject.hasFilledMarker()) { // fill markers with secondary color
3269 int markSize = plotObject.getMarkerSize();
3270 ip.setColor(plotObject.color2);
3271 ip.setLineWidth(1);
3272 for (int i=0; i<nPoints; i++)
3273 if ((!logXAxis || plotObject.xValues[i]>0) && (!logYAxis || plotObject.yValues[i]>0)
3274 && !Double.isNaN(plotObject.xValues[i]) && !Double.isNaN(plotObject.yValues[i]))
3275 fillShape(plotObject.shape, scaleX(plotObject.xValues[i]), scaleY(plotObject.yValues[i]), markSize);
3276 ip.setColor(plotObject.color);
3277 ip.setLineWidth(sc(plotObject.lineWidth));
3278 }
3279 if (plotObject.hasCurve()) { // draw the lines between the points
3280 if (plotObject.shape == CONNECTED_CIRCLES)
3281 ip.setColor(plotObject.color2 == null ? Color.black : plotObject.color2);
3282 drawFloatPolyline(ip, plotObject.xValues, plotObject.yValues, nPoints);
3283 ip.setColor(plotObject.color);
3284 }
3285 if (plotObject.hasMarker()) { // draw the marker symbols
3286 int markSize = plotObject.getMarkerSize();
3287 ip.setColor(plotObject.color);
3288 Font saveFont = ip.getFont();
3289 for (int i=0; i<Math.min(plotObject.xValues.length, plotObject.yValues.length); i++) {
3290 if ((!logXAxis || plotObject.xValues[i]>0) && (!logYAxis || plotObject.yValues[i]>0)
3291 && !Double.isNaN(plotObject.xValues[i]) && !Double.isNaN(plotObject.yValues[i]))
3292 drawShape(plotObject, scaleX(plotObject.xValues[i]), scaleY(plotObject.yValues[i]), plotObject.shape, markSize, i);

Callers 1

drawContentsMethod · 0.95

Calls 15

scMethod · 0.95
drawBarChartMethod · 0.95
drawVerticalErrorBarsMethod · 0.95
fillShapeMethod · 0.95
scaleXMethod · 0.95
scaleYMethod · 0.95
drawFloatPolylineMethod · 0.95
drawShapeMethod · 0.95
calculateDistanceMethod · 0.95
drawArrowMethod · 0.95

Tested by

no test coverage detected