Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bioimage Analysis
Plugin template
Commits
ee0d7d2d
Commit
ee0d7d2d
authored
Aug 27, 2020
by
Jean-Yves TINEVEZ
Browse files
Demo of an EzPlug plugin.
parent
01f6ed80
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/plugins/authorname/MyEzPlugIcyPlugin.java
0 → 100644
View file @
ee0d7d2d
package
plugins.authorname
;
import
java.lang.reflect.InvocationTargetException
;
import
javax.swing.SwingUtilities
;
import
icy.file.Loader
;
import
icy.gui.dialog.MessageDialog
;
import
icy.gui.viewer.Viewer
;
import
icy.main.Icy
;
import
icy.plugin.PluginLauncher
;
import
icy.plugin.PluginLoader
;
import
icy.sequence.Sequence
;
import
icy.system.thread.ThreadUtil
;
import
plugins.adufour.ezplug.EzButton
;
import
plugins.adufour.ezplug.EzPlug
;
import
plugins.adufour.ezplug.EzVarBoolean
;
import
plugins.adufour.ezplug.EzVarInteger
;
public
class
MyEzPlugIcyPlugin
extends
EzPlug
{
private
final
EzVarInteger
age
=
new
EzVarInteger
(
"Your age"
,
30
,
10
,
100
,
1
);
private
final
EzVarBoolean
yummy
=
new
EzVarBoolean
(
"Like chocolate?"
,
true
);
private
final
EzButton
button
=
new
EzButton
(
"Load an show an image now"
,
l
->
loadAndShow
()
);
@Override
protected
void
initialize
()
{
// Add elements in order of appearance.
addEzComponent
(
age
);
addEzComponent
(
yummy
);
addEzComponent
(
button
);
}
@Override
public
void
clean
()
{
// Nothing to do
}
@Override
protected
void
execute
()
{
final
String
str
=
"This plugin start button does not do anything useful.\n "
+
"You say you are "
+
age
.
getValue
()
+
" years old and you "
+
(
yummy
.
getValue
().
booleanValue
()
?
"like"
:
"don't like"
)
+
" chocolate."
;
MessageDialog
.
showDialog
(
str
);
}
private
void
loadAndShow
()
{
final
String
imagePath
=
"samples/Cont1.lsm"
;
// Load in a separate thread.
ThreadUtil
.
bgRun
(
new
Runnable
()
{
@Override
public
void
run
()
{
final
Sequence
sequence
=
Loader
.
loadSequence
(
imagePath
,
0
,
true
);
// Display the images.
try
{
SwingUtilities
.
invokeAndWait
(
()
->
{
new
Viewer
(
sequence
);
}
);
}
catch
(
InvocationTargetException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
);
}
public
static
void
main
(
final
String
[]
args
)
{
// Launch the application.
Icy
.
main
(
args
);
/*
* Programmatically launch a plugin, as if the user had clicked its
* button.
*/
PluginLauncher
.
start
(
PluginLoader
.
getPlugin
(
MyEzPlugIcyPlugin
.
class
.
getName
()
)
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment