no edit summary
= Compile & Execute a Class =
You do not need to call
''javac '' yourself with a long classpath:
Sometimes, the compiler complains about a class not having a certain method or interface, but you ''know'' it must contain it. More often than not, that class exists in different versions in your classpath. Find out with
If you want to do that with an installed Fiji (i.e. when bin/ is missing), you can start the [[Script Editor]] and execute a BeanShell like this:
This will output the URL to the ''.class'' file, including the path to the enclosing ''.jar'' file.
== How to show a plot ==
ImageJ offers the
''ij.gui.Plot '' class to make a window showing a plot. Use it like this:
To add another plot to the same window, use the
''addPoints() '' method:
You might need to adjust the bounding box if the second plot does not match the bounding box of the first one by using the
''setLimits() '' method before the call to ''plot.draw(); ''
== Duplicate, or convert between, ''ImageProcessor'' types ==
''ImageProcessor '' class has several useful methods: [http://fiji.sc/javadoc/ij/process/ImageProcessor.html#duplicate() duplicate()], [http://fiji.sc/javadoc/ij/process/ImageProcessor.html#convertToByte(boolean) convertToByte()], [http://fiji.sc/javadoc/ij/process/ImageProcessor.html#convertToFloat() convertToFloat()],
[http://fiji.sc/javadoc/ij/process/ImageProcessor.html#convertToRGB() convertToRGB()], and [http://fiji.sc/javadoc/ij/process/ImageProcessor.html#convertToShort(boolean) convertToShort()].
'''Note:''' do <u>not</u> use the
''getString() '' or ''getInt() ''; These methods do not have any setter methods, and they do <u>not</u> access the same values as the ''get() '' method ( ''get() '' actually prefixes the keys with a dot)!
== How to turn a number into a string, using a given number of decimal places ==
''d2s() '' method of the ''ij.IJ '' class:
:''Once a Swing component has been realized, all code that might affect or depend on the state of that component should be executed in the event-dispatching thread.''
When has a Swing component been realized? When it is visible inside Window or JFrame that got a call to
''setVisible(true) ''. This implies that its ''paint(Graphics) '' method has been called or will be called soon.
These are the methods that can realize a component, or rather, methods called on a Window or Frame or JFrame that will realize all its children components:
There is a class which helps you with all this: [http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html SwingUtilities]. Example: to call
''pack() '' from within the constructor (which might or might not be called from the Event Dispatch Thread):