/** * Show a stack trace using the {@link IJ} class. * * @param throwable * the exception to show */ @Override public void handleException(Throwable exception) { IJ.handleException(exception); }
/** * Delegate exception handling to ImageJ 1.x. * * @param e the exception to handle */ public void handleException(final Throwable e) { IJ.handleException(e); }
@Override protected void log(final Throwable t) { IJ.handleException(t); } }
@Override public void actionPerformed(ActionEvent e) { try { showInTextWindow(); } catch(IOException ex) { IJ.handleException(ex); } } }
@Override protected Object doInBackground() throws Exception { try { highlightMolecules(); } catch(Exception e) { IJ.handleException(e); } return null; } }.execute();
/** * Since exceptions can be catched only within the active thread, this method is * called when an exception is catched. * * @param ex an exception */ public void exCatch(Throwable ex) { IJ.handleException(ex); }
@Override public void error(Throwable t) { IJ.handleException(t); }
@Override public void error(Throwable t) { IJ.handleException(t); }
public void resetBoundingRect() { if (resetBoundsMethod == null) return; // work around spline fit changing the bounding box try { resetBoundsMethod.invoke(this, new Object[0]); } catch (Exception e) { IJ.handleException(e); } }
protected static int getNCoordinates(PolygonRoi roi) { if (nPointsField == null) return -1; try { return ((Integer)nPointsField.get(roi)).intValue(); } catch (Exception e) { IJ.handleException(e); return -1; } }
protected void copyXpfToXp() { if (xpfField != null) try { xp = toIntR((float[])xpfField.get(this)); } catch (IllegalAccessException e) { IJ.handleException(e); } if (ypfField != null) try { yp = toIntR((float[])ypfField.get(this)); } catch (IllegalAccessException e) { IJ.handleException(e); } }
@Override public void run() { if (in != null) try { super.run(); out.flush(); if (closeAfterRun) out.close(); } catch (IOException e) { IJ.handleException(e); } }
protected void copyXpToXpf() { if (xpfField != null) try { xpfField.set(this, toFloat(xp)); } catch (IllegalAccessException e) { IJ.handleException(e); } if (ypfField != null) try { ypfField.set(this, toFloat(yp)); } catch (IllegalAccessException e) { IJ.handleException(e); } }
public static boolean openIJ1Editor(String title, String body) { try { Class<?> clazz = IJ.getClassLoader().loadClass("ij.plugin.frame.Editor"); Constructor<?> ctor = clazz.getConstructor(new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE }); Object ed = ctor.newInstance(new Object[] { 16, 60, 0, 3 }); Method method = clazz.getMethod(title.endsWith(".ijm") ? "createMacro" : "create", new Class[] { String.class, String.class }); method.invoke(ed, new Object[] { title, body }); return true; } catch (Exception e) { IJ.handleException(e); } return false; }
protected static int[] getXCoordinates(PolygonRoi roi) { try { Rectangle bounds = roi.getBounds(); int[] xp = (int[])xpField.get(roi); int[] result = new int[xp.length]; for (int i = 0; i < xp.length; i++) result[i] = xp[i] + bounds.x; return result; } catch (Exception e) { IJ.handleException(e); return null; } }
protected static int[] getYCoordinates(PolygonRoi roi) { try { Rectangle bounds = roi.getBounds(); int[] yp = (int[])ypField.get(roi); int[] result = new int[yp.length]; for (int i = 0; i < yp.length; i++) result[i] = yp[i] + bounds.y; return result; } catch (Exception e) { IJ.handleException(e); return null; } }
public static boolean openEditor(File file, File templateFile) { try { Class<?> clazz = IJ.getClassLoader().loadClass("fiji.scripting.TextEditor"); Constructor<?> ctor = clazz.getConstructor(new Class[] { File.class, File.class }); Frame frame = (Frame)ctor.newInstance(new Object[] { file, templateFile }); frame.setVisible(true); return true; } catch (Exception e) { IJ.handleException(e); } return false; }
private void save16BitImage(ImageProcessor ip, String path) { ip.resetMinAndMax(); int max = (int)ip.getMax(); if (max<256) max=256; try { DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path))); output.writeBytes("P5\n# Written by ImageJ PNM Writer\n" + ip.getWidth() + " " + ip.getHeight() + "\n"+max+"\n"); for (int i=0; i<ip.getPixelCount(); i++) output.writeShort(ip.get(i)); output.close(); } catch(IOException e) { IJ.handleException(e); } }
@Override public void run(String command) { try { GUI.setLookAndFeel(); if(getInput()) { runGenerator(); } } catch(Exception ex) { IJ.handleException(ex); } }
public static void main(String[] args) { try { SimpleExecuter executer = new SimpleExecuter(args); IJ.log("status: " + executer.getExitCode()); IJ.log("output: " + executer.getOutput()); IJ.log("error: " + executer.getError()); } catch (IOException e) { IJ.handleException(e); } } }