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

Method drawContents

ij/src/main/java/ij/gui/Plot.java:2069–2129  ·  view source on GitHub ↗

Draws the plot contents (all PlotObjects and the frame and legend), without axes etc.

(ImageProcessor ip)

Source from the content-addressed store, hash-verified

2067
2068 /** Draws the plot contents (all PlotObjects and the frame and legend), without axes etc. */
2069 void drawContents(ImageProcessor ip) {
2070 makeRangeGetSteps();
2071 ip.setColor(Color.black);
2072 ip.setLineWidth(sc(1));
2073 float lineWidth = 1;
2074 Color color = Color.black;
2075 Font font = defaultFont;
2076
2077 // draw all the plot objects in the sequence they were added, except for the one of the constructor
2078 for (PlotObject plotObject : allPlotObjects)
2079 if (!plotObject.hasFlag(PlotObject.CONSTRUCTOR_DATA)) {
2080 //properties lineWidth, Font, Color set for one object remain for the next object unless changed
2081 if (plotObject.lineWidth > 0)
2082 lineWidth = plotObject.lineWidth;
2083 else
2084 plotObject.lineWidth = lineWidth;
2085 if (plotObject.color != null)
2086 color = plotObject.color;
2087 else
2088 plotObject.color = color;
2089 if (plotObject.getFont() != null)
2090 font = plotObject.getFont();
2091 else
2092 plotObject.setFont(font);
2093 //IJ.log("type="+plotObject.type+" color="+plotObject.color);
2094 drawPlotObject(plotObject, ip);
2095 }
2096
2097 // draw the line passed with the constructor last, using the settings present when calling 'draw'
2098 if (allPlotObjects.size()>0 && allPlotObjects.get(0).hasFlag(PlotObject.CONSTRUCTOR_DATA)) {
2099 PlotObject mainPlotObject = allPlotObjects.get(0);
2100 if (mainPlotObject.lineWidth == 0)
2101 mainPlotObject.lineWidth = currentLineWidth == 0 ? 1 : currentLineWidth;
2102 lineWidth = mainPlotObject.lineWidth;
2103 if (mainPlotObject.color == null)
2104 mainPlotObject.color = currentColor == null ? Color.black : currentColor;
2105 drawPlotObject(mainPlotObject, ip);
2106 } else {
2107 if (currentLineWidth > 0) lineWidth = currentLineWidth; //linewidth when drawing determines frame linewidth
2108 }
2109
2110 // finally draw the frame & legend
2111 if (!plotDrawn && pp.frame.lineWidth==DEFAULT_FRAME_LINE_WIDTH) { //when modifying PlotObjects styles later, don't change the frame line width any more
2112 pp.frame.lineWidth = lineWidth;
2113 if (pp.frame.lineWidth == 0) pp.frame.lineWidth = 1;
2114 if (pp.frame.lineWidth > 3) pp.frame.lineWidth = 3;
2115 }
2116 ip.setLineWidth(sc(pp.frame.lineWidth));
2117 ip.setColor(pp.frame.color);
2118 int x2 = frame.x + frame.width - 1;
2119 int y2 = frame.y + frame.height - 1;
2120 ip.moveTo(frame.x, frame.y); // draw the frame. Can't use ip.drawRect because it is inconsistent for different lineWidths
2121 ip.lineTo(x2, frame.y);
2122 ip.lineTo(x2, y2);
2123 ip.lineTo(frame.x, y2);
2124 ip.lineTo(frame.x, frame.y);
2125 if (pp.legend != null && (pp.legend.flags & LEGEND_POSITION_MASK) != 0)
2126 drawPlotObject(pp.legend, ip);

Callers 2

drawMethod · 0.95
updateImageMethod · 0.95

Calls 12

makeRangeGetStepsMethod · 0.95
scMethod · 0.95
drawPlotObjectMethod · 0.95
setColorMethod · 0.65
setLineWidthMethod · 0.65
hasFlagMethod · 0.65
getFontMethod · 0.65
setFontMethod · 0.65
sizeMethod · 0.45
getMethod · 0.45
moveToMethod · 0.45
lineToMethod · 0.45

Tested by

no test coverage detected