(int width, int height)
| 2129 | } |
| 2130 | |
| 2131 | @AstroImageJ(reason = "Support scaled plots") |
| 2132 | public BufferedImage getBufferedImage(int width, int height) { |
| 2133 | if (isAijPlot()) { |
| 2134 | draw(); |
| 2135 | |
| 2136 | var buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| 2137 | var bufferGraphics = buffer.createGraphics(); |
| 2138 | |
| 2139 | if (VectorPlotDrawing.SCALED_PLOT.orElse(true)) { |
| 2140 | bufferGraphics.scale(Prefs.getGuiScale(), Prefs.getGuiScale()); |
| 2141 | } |
| 2142 | |
| 2143 | bufferGraphics.setColor(Color.WHITE); |
| 2144 | bufferGraphics.fillRect(0, 0, width, height); |
| 2145 | |
| 2146 | var vectorPlotDrawing = new VectorPlotDrawing(this); |
| 2147 | vectorPlotDrawing.drawVectorForm(bufferGraphics); |
| 2148 | |
| 2149 | bufferGraphics.dispose(); |
| 2150 | |
| 2151 | return buffer; |
| 2152 | } |
| 2153 | |
| 2154 | // MP has a race condition as setSize sets the ip to null, and it disposes of the plot as well |
| 2155 | // So, make a copy of the plot and draw there |
| 2156 | var ip = getProcessor(); |
| 2157 | if (ip == null) { |
| 2158 | var p = duplicate(); |
| 2159 | p.draw(); |
| 2160 | ip = p.getProcessor(); |
| 2161 | } |
| 2162 | |
| 2163 | return ip.getBufferedImage(); |
| 2164 | } |
| 2165 | |
| 2166 | /** Creates the processor if not existing, clears the background and prepares |
| 2167 | * it for plotting. Also called by the PlotWindow class to prepare the window. */ |
no test coverage detected