private void btnShowActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnShowActionPerformed double[] yVal = new double[calculator.getResponseFunctionCalculatorSettings().getLevels()]; for (int i = 0; i < yVal.length; i++) { yVal[i] = i; } PlotWindow plot; switch (out.getType()) { case ImagePlus.COLOR_RGB: plot = new PlotWindow("Response Function", "x", "y", out.getG()[0], yVal); plot.setColor(Color.GREEN); plot.addPoints(out.getG()[1], yVal, PlotWindow.LINE); plot.setColor(Color.BLUE); plot.addPoints(out.getG()[2], yVal, PlotWindow.LINE); plot.setColor(Color.RED); plot.draw(); break; case ImagePlus.GRAY16: plot = new PlotWindow("Response Function", "x", "y", out.getG()[0], yVal); plot.draw(); break; } } // GEN-LAST:event_btnShowActionPerformed
public void run(String arg) { int wOld, hOld, wNew, hNew; boolean fIsStack = false; ImagePlus imp = IJ.getImage(); wOld = imp.getWidth(); hOld = imp.getHeight(); ImageStack stackOld = imp.getStack(); if ((stackOld != null) && (stackOld.getSize() > 1)) fIsStack = true; String[] sPositions = { "Top-Left", "Top-Center", "Top-Right", "Center-Left", "Center", "Center-Right", "Bottom-Left", "Bottom-Center", "Bottom-Right" }; String strTitle = fIsStack ? "Resize Stack Canvas" : "Resize Image Canvas"; GenericDialog gd = new GenericDialog(strTitle); gd.addNumericField("Width:", wOld, 0, 5, "pixels"); gd.addNumericField("Height:", hOld, 0, 5, "pixels"); gd.addChoice("Position:", sPositions, sPositions[4]); gd.addCheckbox("Zero Fill", zeroFill); gd.showDialog(); if (gd.wasCanceled()) return; wNew = (int) gd.getNextNumber(); hNew = (int) gd.getNextNumber(); int iPos = gd.getNextChoiceIndex(); zeroFill = gd.getNextBoolean(); Prefs.set("resizer.zero", zeroFill); int xOff, yOff; int xC = (wNew - wOld) / 2; // offset for centered int xR = (wNew - wOld); // offset for right int yC = (hNew - hOld) / 2; // offset for centered int yB = (hNew - hOld); // offset for bottom switch (iPos) { case 0: // TL xOff = 0; yOff = 0; break; case 1: // TC xOff = xC; yOff = 0; break; case 2: // TR xOff = xR; yOff = 0; break; case 3: // CL xOff = 0; yOff = yC; break; case 4: // C xOff = xC; yOff = yC; break; case 5: // CR xOff = xR; yOff = yC; break; case 6: // BL xOff = 0; yOff = yB; break; case 7: // BC xOff = xC; yOff = yB; break; case 8: // BR xOff = xR; yOff = yB; break; default: // center xOff = xC; yOff = yC; break; } if (fIsStack) { ImageStack stackNew = expandStack(stackOld, wNew, hNew, xOff, yOff); imp.setStack(null, stackNew); } else { if (!IJ.macroRunning()) Undo.setup(Undo.COMPOUND_FILTER, imp); ImageWindow win = imp.getWindow(); if (win != null && (win instanceof PlotWindow)) ((PlotWindow) win).getPlot().setFrozen(true); ImageProcessor newIP = expandImage(imp.getProcessor(), wNew, hNew, xOff, yOff); imp.setProcessor(null, newIP); if (!IJ.macroRunning()) Undo.setup(Undo.COMPOUND_FILTER_DONE, imp); } Overlay overlay = imp.getOverlay(); if (overlay != null) overlay.translate(xOff, yOff); }