-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathBigDataViewerActions.java
172 lines (152 loc) · 7.29 KB
/
BigDataViewerActions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package bdv;
import java.awt.Dialog;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import org.scijava.ui.behaviour.KeyStrokeAdder;
import org.scijava.ui.behaviour.util.Actions;
import org.scijava.ui.behaviour.util.InputActionBindings;
import bdv.tools.HelpDialog;
import bdv.tools.RecordMaxProjectionDialog;
import bdv.tools.RecordMovieDialog;
import bdv.tools.RecordPathMovieDialog;
import bdv.tools.ToggleDialogAction;
import bdv.tools.VisibilityAndGroupingDialog;
import bdv.tools.bookmarks.BookmarksEditor;
import bdv.tools.brightness.BrightnessDialog;
import bdv.tools.crop.CropDialog;
import bdv.tools.transformation.ManualTransformationEditor;
public class BigDataViewerActions extends Actions
{
public static final String BRIGHTNESS_SETTINGS = "brightness settings";
public static final String VISIBILITY_AND_GROUPING = "visibility and grouping";
public static final String SHOW_HELP = "help";
public static final String CROP = "crop";
public static final String MANUAL_TRANSFORM = "toggle manual transformation";
public static final String SAVE_SETTINGS = "save settings";
public static final String LOAD_SETTINGS = "load settings";
public static final String RECORD_MOVIE = "record movie";
public static final String RECORD_PATH_MOVIE = "record path movie";
public static final String RECORD_MAX_PROJECTION_MOVIE = "record max projection movie";
public static final String SET_BOOKMARK = "set bookmark";
public static final String GO_TO_BOOKMARK = "go to bookmark";
public static final String GO_TO_BOOKMARK_ROTATION = "go to bookmark rotation";
static final String[] BRIGHTNESS_SETTINGS_KEYS = new String[] { "S" };
static final String[] VISIBILITY_AND_GROUPING_KEYS = new String[] { "F6" };
static final String[] MANUAL_TRANSFORM_KEYS = new String[] { "T" };
static final String[] SHOW_HELP_KEYS = new String[] { "F1", "H" };
static final String[] RECORD_MAX_PROJECTION_MOVIE_KEYS = new String[] { "F8" };
static final String[] CROP_KEYS = new String[] { "F9" };
static final String[] RECORD_MOVIE_KEYS = new String[] { "F10" };
static final String[] RECORD_PATH_MOVIE_KEYS = new String[] { "shift F10" };
static final String[] SAVE_SETTINGS_KEYS = new String[] { "F11" };
static final String[] LOAD_SETTINGS_KEYS = new String[] { "F12" };
static final String[] GO_TO_BOOKMARK_KEYS = new String[] { "B" };
static final String[] GO_TO_BOOKMARK_ROTATION_KEYS = new String[] { "O" };
static final String[] SET_BOOKMARK_KEYS = new String[] { "shift B" };
/**
* Create BigDataViewer actions and install them in the specified
* {@link InputActionBindings}.
*
* @param inputActionBindings
* {@link InputMap} and {@link ActionMap} are installed here.
* @param bdv
* Actions are targeted at this {@link BigDataViewer}.
* @param keyProperties
* user-defined key-bindings.
*/
public static void installActionBindings(
final InputActionBindings inputActionBindings,
final BigDataViewer bdv,
final KeyStrokeAdder.Factory keyProperties )
{
final BigDataViewerActions actions = new BigDataViewerActions( keyProperties );
actions.dialog( bdv.brightnessDialog );
actions.dialog( bdv.activeSourcesDialog );
actions.dialog( bdv.helpDialog );
actions.dialog( bdv.cropDialog );
actions.dialog( bdv.movieDialog );
actions.dialog( bdv.pathMovieDialog );
actions.dialog( bdv.movieMaxProjectDialog );
actions.bookmarks( bdv.bookmarkEditor );
actions.manualTransform( bdv.manualTransformationEditor );
actions.runnableAction( bdv::loadSettings, LOAD_SETTINGS, LOAD_SETTINGS_KEYS );
actions.runnableAction( bdv::saveSettings, SAVE_SETTINGS, SAVE_SETTINGS_KEYS );
actions.install( inputActionBindings, "bdv" );
}
public BigDataViewerActions( final KeyStrokeAdder.Factory keyConfig )
{
super( keyConfig, new String[] { "bdv" } );
}
public void toggleDialogAction( final Dialog dialog, final String name, final String... defaultKeyStrokes )
{
keyStrokeAdder.put( name, defaultKeyStrokes );
new ToggleDialogAction( name, dialog ).put( getActionMap() );
}
public void dialog( final BrightnessDialog brightnessDialog )
{
toggleDialogAction( brightnessDialog, BRIGHTNESS_SETTINGS, BRIGHTNESS_SETTINGS_KEYS );
}
public void dialog( final VisibilityAndGroupingDialog visibilityAndGroupingDialog )
{
toggleDialogAction( visibilityAndGroupingDialog, VISIBILITY_AND_GROUPING, VISIBILITY_AND_GROUPING_KEYS );
}
public void dialog( final CropDialog cropDialog )
{
toggleDialogAction( cropDialog, CROP, CROP_KEYS );
}
public void dialog( final HelpDialog helpDialog )
{
toggleDialogAction( helpDialog, SHOW_HELP, SHOW_HELP_KEYS );
}
public void dialog( final RecordMovieDialog recordMovieDialog )
{
toggleDialogAction( recordMovieDialog, RECORD_MOVIE, RECORD_MOVIE_KEYS );
}
public void dialog( final RecordPathMovieDialog recordMovieDialog )
{
toggleDialogAction( recordMovieDialog, RECORD_PATH_MOVIE, RECORD_PATH_MOVIE_KEYS );
}
public void dialog( final RecordMaxProjectionDialog recordMaxProjectionDialog )
{
toggleDialogAction( recordMaxProjectionDialog, RECORD_MAX_PROJECTION_MOVIE, RECORD_MAX_PROJECTION_MOVIE_KEYS );
}
public void bookmarks( final BookmarksEditor bookmarksEditor )
{
runnableAction( bookmarksEditor::initGoToBookmark, GO_TO_BOOKMARK, GO_TO_BOOKMARK_KEYS );
runnableAction( bookmarksEditor::initGoToBookmarkRotation, GO_TO_BOOKMARK_ROTATION, GO_TO_BOOKMARK_ROTATION_KEYS );
runnableAction( bookmarksEditor::initSetBookmark, SET_BOOKMARK, SET_BOOKMARK_KEYS );
}
public void manualTransform( final ManualTransformationEditor manualTransformationEditor )
{
runnableAction( manualTransformationEditor::toggle, MANUAL_TRANSFORM, MANUAL_TRANSFORM_KEYS );
}
}