001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019
020package icy.gui.main;
021
022import java.util.ArrayList;
023import java.util.List;
024
025import javax.swing.JFrame;
026import javax.swing.JInternalFrame;
027import javax.swing.undo.UndoManager;
028
029import icy.common.listener.AcceptListener;
030import icy.gui.inspector.InspectorPanel;
031import icy.gui.inspector.LayersPanel;
032import icy.gui.inspector.RoisPanel;
033import icy.gui.menu.ApplicationMenu;
034import icy.gui.menu.ROITask;
035import icy.gui.menu.ToolRibbonTask;
036import icy.gui.viewer.Viewer;
037import icy.image.IcyBufferedImage;
038import icy.image.lut.LUT;
039import icy.imagej.ImageJWrapper;
040import icy.painter.Overlay;
041import icy.painter.Painter;
042import icy.plugin.abstract_.Plugin;
043import icy.preferences.XMLPreferences;
044import icy.roi.ROI;
045import icy.search.SearchEngine;
046import icy.sequence.Sequence;
047import icy.swimmingPool.SwimmingPool;
048import icy.undo.IcyUndoManager;
049
050/**
051 * MainInterface
052 * 
053 * @see icy.gui.main.MainInterfaceGui
054 * @author Fabrice de Chaumont & Stephane
055 */
056public interface MainInterface
057{
058    /**
059     * Creates the windows in the Icy.getMainInterface()
060     */
061    public abstract void init();
062
063    /**
064     * Check if exit is allowed from registered listeners
065     */
066    public abstract boolean canExitExternal();
067
068    /**
069     * Return true is the application is running in headless mode (no screen device).
070     */
071    public abstract boolean isHeadLess();
072
073    /**
074     * Return true is the <i>virtual mode</i> is enabled.<br>
075     * When virtual mode is enabled all Sequence are made virtual (same as volatile) so data is streamed from hard drive on demand. This is useful when you
076     * manipulate large Sequence which don't fit in memory but this can make process much slower. Also some plugins won't work correctly on virtual Sequence
077     * (modified data can be lost) so use it carefully.
078     * 
079     * @see IcyBufferedImage#setVolatile(boolean)
080     */
081    public abstract boolean isVirtualMode();
082
083    /**
084     * Sets the <i>virtual mode</i>.<br>
085     * When virtual mode is enabled all Sequence are made virtual (same as volatile) so data is streamed from hard drive on demand. This is useful when you
086     * manipulate large Sequence which don't fit in memory but this can make process much slower. Also some plugins won't work correctly on virtual Sequence
087     * (modified data can be lost) so use it carefully.
088     * 
089     * @see IcyBufferedImage#setVolatile(boolean)
090     */
091    public abstract void setVirtualMode(boolean value);
092
093    /**
094     * Open a viewer for the specified sequence.
095     */
096    public abstract void addSequence(Sequence sequence);
097
098    /**
099     * Returns all internal frames
100     */
101    public abstract ArrayList<JInternalFrame> getInternalFrames();
102
103    /**
104     * Returns all external frames
105     */
106    public abstract ArrayList<JFrame> getExternalFrames();
107
108    public abstract XMLPreferences getPreferences();
109
110    /**
111     * Returns the inspector object (right informations panel)
112     */
113    public abstract InspectorPanel getInspector();
114
115    /**
116     * Returns the ROI manager panel
117     */
118    public abstract RoisPanel getRoisPanel();
119
120    /**
121     * Returns the Layer manager panel
122     */
123    public abstract LayersPanel getLayersPanel();
124
125    /**
126     * Returns the currently active plugins
127     */
128    public abstract ArrayList<Plugin> getActivePlugins();
129
130    /**
131     * Returns the active viewer window.
132     * Returns <code>null</code> if there is no sequence opened.
133     */
134    public abstract Viewer getActiveViewer();
135
136    /**
137     * Returns the LUT from the active viewer window.
138     * Returns <code>null</code> if there is no sequence opened.
139     */
140    public abstract LUT getActiveLUT();
141
142    /**
143     * Returns the current active sequence.<br>
144     * Returns <code>null</code> if there is no sequence opened.
145     */
146    public abstract Sequence getActiveSequence();
147
148    /**
149     * Returns the current active image.<br>
150     * It can return <code>null</code> if the active viewer is <code>null</code> or
151     * if it uses 3D display so prefer {@link #getActiveSequence()} instead.
152     */
153    public abstract IcyBufferedImage getActiveImage();
154
155    /**
156     * @deprecated Use {@link #getActiveViewer()} instead.
157     */
158    @Deprecated
159    public abstract Viewer getFocusedViewer();
160
161    /**
162     * @deprecated Use {@link #getActiveSequence()} instead.
163     */
164    @Deprecated
165    public abstract Sequence getFocusedSequence();
166
167    /**
168     * @deprecated Use {@link #getActiveImage()} instead.
169     */
170    @Deprecated
171    public abstract IcyBufferedImage getFocusedImage();
172
173    /**
174     * Returns the current active {@link UndoManager} (UndoManager from active sequence).
175     * It returns <code>null</code> if the active sequence is <code>null</code>.
176     * 
177     * @see Sequence#getUndoManager()
178     */
179    public abstract IcyUndoManager getUndoManager();
180
181    /**
182     * Undo to the last <i>Undoable</i> change set in the active Sequence {@link UndoManager}
183     * 
184     * @return <code>true</code> if the operation succeed
185     * @see Sequence#undo()
186     */
187    public abstract boolean undo();
188
189    /**
190     * Redo the next <i>Undoable</i> change set in the active Sequence {@link UndoManager}
191     * 
192     * @return <code>true</code> if the operation succeed
193     * @see Sequence#redo()
194     */
195    public abstract boolean redo();
196
197    /**
198     * Returns all active viewers
199     */
200    public abstract ArrayList<Viewer> getViewers();
201
202    /**
203     * Set the current active viewer.
204     * 
205     * @param viewer
206     *        viewer which received activation
207     */
208    public abstract void setActiveViewer(Viewer viewer);
209
210    /**
211     * @deprecated Use {@link #setActiveViewer(Viewer)} instead.
212     */
213    @Deprecated
214    public abstract void setFocusedViewer(Viewer viewer);
215
216    /**
217     * Set all active viewers to specified synchronization group id (0 means unsynchronized).
218     */
219    public abstract void setGlobalViewSyncId(int id);
220
221    /**
222     * Add the frame to the Desktop pane and change its layer value to make it over the other
223     * internal frames.
224     * 
225     * @param internalFrame
226     */
227    public abstract void addToDesktopPane(JInternalFrame internalFrame);
228
229    public abstract IcyDesktopPane getDesktopPane();
230
231    public abstract ApplicationMenu getApplicationMenu();
232
233    public abstract TaskFrameManager getTaskWindowManager();
234
235    @Deprecated
236    public abstract void registerExternalFrame(JFrame frame);
237
238    @Deprecated
239    public abstract void unRegisterExternalFrame(JFrame frame);
240
241    public abstract void registerPlugin(Plugin plugin);
242
243    public abstract void unRegisterPlugin(Plugin plugin);
244
245    public abstract void registerViewer(Viewer viewer);
246
247    public abstract void unRegisterViewer(Viewer viewer);
248
249    // public abstract void registerStreamPlugin(PluginStreamGenerator pluginStreamGenerator);
250
251    /**
252     * @deprecated Use {@link #getMainFrame()} instead
253     */
254    @Deprecated
255    public abstract MainFrame getFrame();
256
257    /**
258     * Get Icy main frame
259     */
260    public abstract MainFrame getMainFrame();
261
262    /**
263     * Get Icy main searh engine.
264     */
265    public abstract SearchEngine getSearchEngine();
266
267    /**
268     * Close all viewers displaying the specified sequence.
269     */
270    public abstract void closeSequence(Sequence sequence);
271
272    /**
273     * @deprecated Use {@link #closeSequence(Sequence)} instead.
274     */
275    @Deprecated
276    public abstract void closeViewersOfSequence(Sequence sequence);
277
278    /**
279     * Close all viewers
280     */
281    public abstract void closeAllViewers();
282
283    /**
284     * Returns first viewer for the sequence containing specified ROI
285     */
286    public abstract Viewer getFirstViewerContaining(ROI roi);
287
288    /**
289     * Returns first viewer for the sequence containing specified Painter.
290     * 
291     * @deprecated use {@link #getFirstViewerContaining(Overlay)} instead.
292     */
293    @Deprecated
294    public abstract Viewer getFirstViewerContaining(Painter painter);
295
296    /**
297     * Returns first viewer for the sequence containing specified Overlay
298     */
299    public abstract Viewer getFirstViewerContaining(Overlay overlay);
300
301    /**
302     * Returns first viewer attached to specified sequence
303     */
304    public abstract Viewer getFirstViewer(Sequence sequence);
305
306    /**
307     * Returns viewers attached to specified sequence
308     */
309    public abstract ArrayList<Viewer> getViewers(Sequence sequence);
310
311    /**
312     * Returns true if specified viewer is the unique viewer for its attached sequence
313     */
314    public abstract boolean isUniqueViewer(Viewer viewer);
315
316    /**
317     * Returns the list of opened sequence (sequence actually displayed in a viewer)
318     */
319    public abstract ArrayList<Sequence> getSequences();
320
321    /**
322     * Returns the list of opened sequence (sequence actually displayed in a viewer) matching the specified name.
323     */
324    public abstract ArrayList<Sequence> getSequences(String name);
325
326    /**
327     * Returns true if specified sequence is currently opened (displayed in a viewer)
328     */
329    public abstract boolean isOpened(Sequence sequence);
330
331    /**
332     * Use {@link #getFirstSequenceContaining(ROI)} instead
333     * 
334     * @deprecated
335     */
336    @Deprecated
337    public abstract Sequence getFirstSequencesContaining(ROI roi);
338
339    /**
340     * Use {@link #getFirstSequenceContaining(Overlay)} instead
341     * 
342     * @deprecated
343     */
344    @Deprecated
345    public abstract Sequence getFirstSequencesContaining(Painter painter);
346
347    /**
348     * Returns the first active sequence containing the specified ROI
349     */
350    public abstract Sequence getFirstSequenceContaining(ROI roi);
351
352    /**
353     * Returns the first active sequence containing the specified Painter
354     * 
355     * @deprecated Use {@link #getFirstSequenceContaining(Overlay)} instead.
356     */
357    @Deprecated
358    public abstract Sequence getFirstSequenceContaining(Painter painter);
359
360    /**
361     * Returns the first active sequence containing the specified Overlay
362     */
363    public abstract Sequence getFirstSequenceContaining(Overlay overlay);
364
365    /**
366     * Returns all active sequence containing the specified ROI
367     */
368    public abstract ArrayList<Sequence> getSequencesContaining(ROI roi);
369
370    /**
371     * Returns all active sequence containing the specified Painter
372     * 
373     * @deprecated Use {@link #getSequencesContaining(Overlay)} instead.
374     */
375    @Deprecated
376    public abstract ArrayList<Sequence> getSequencesContaining(Painter painter);
377
378    /**
379     * Returns all active sequence containing the specified Overlay
380     */
381    public abstract List<Sequence> getSequencesContaining(Overlay overlay);
382
383    /**
384     * Returns all active ROI
385     */
386    public abstract ArrayList<ROI> getROIs();
387
388    /**
389     * Returns the ROI containing the specified painter (if any).
390     * 
391     * @deprecated Use {@link #getROI(Overlay)} instead.
392     */
393    @Deprecated
394    public abstract ROI getROI(Painter painter);
395
396    /**
397     * Returns the ROI containing the specified overlay (if any)
398     */
399    public abstract ROI getROI(Overlay overlay);
400
401    /**
402     * Returns all active Painter.
403     * 
404     * @deprecated Use {@link #getOverlays()} instead.
405     */
406    @Deprecated
407    public abstract ArrayList<Painter> getPainters();
408
409    /**
410     * Returns all active Overlay.
411     */
412    public abstract List<Overlay> getOverlays();
413
414    /**
415     * Returns the SwimmingPool object
416     */
417    public abstract SwimmingPool getSwimmingPool();
418
419    /**
420     * Returns the ImageJ object instance
421     */
422    public abstract ImageJWrapper getImageJ();
423
424    /**
425     * Returns current selected tool (ROI / Selection)
426     */
427    public abstract String getSelectedTool();
428
429    /**
430     * Set current selected tool (ROI / Selection).
431     */
432    public abstract void setSelectedTool(String command);
433
434    /**
435     * Returns the ROI task of the Ribbon menu.
436     */
437    public abstract ROITask getROIRibbonTask();
438
439    /**
440     * @deprecated Use {@link #getROIRibbonTask()} instead
441     */
442    @Deprecated
443    public abstract ToolRibbonTask getToolRibbon();
444
445    /**
446     * Returns true if the main frame is set as "always on top"
447     */
448    public abstract boolean isAlwaysOnTop();
449
450    /**
451     * Set the main frame as "always on top"
452     */
453    public abstract void setAlwaysOnTop(boolean value);
454
455    /**
456     * Returns true if the application is in "detached" mode
457     */
458    public abstract boolean isDetachedMode();
459
460    /**
461     * Set the the application is in "detached" mode
462     */
463    public abstract void setDetachedMode(boolean value);
464
465    /**
466     * @deprecated Use addGlobalXXXListener instead.
467     */
468    @Deprecated
469    public abstract void addListener(MainListener listener);
470
471    /**
472     * @deprecated Use removeGlobalXXXListener instead.
473     */
474    @Deprecated
475    public abstract void removeListener(MainListener listener);
476
477    /**
478     * Add global Viewer listener
479     */
480    public abstract void addGlobalViewerListener(GlobalViewerListener listener);
481
482    /**
483     * Remove global Viewer listener
484     */
485    public abstract void removeGlobalViewerListener(GlobalViewerListener listener);
486
487    /**
488     * Add global Sequence listener
489     */
490    public abstract void addGlobalSequenceListener(GlobalSequenceListener listener);
491
492    /**
493     * Remove global Sequence listener
494     */
495    public abstract void removeGlobalSequenceListener(GlobalSequenceListener listener);
496
497    /**
498     * Add global ROI listener
499     */
500    public abstract void addGlobalROIListener(GlobalROIListener listener);
501
502    /**
503     * Remove global ROI listener
504     */
505    public abstract void removeGlobalROIListener(GlobalROIListener listener);
506
507    /**
508     * Add global Overlay listener
509     */
510    public abstract void addGlobalOverlayListener(GlobalOverlayListener listener);
511
512    /**
513     * Remove global Overlay listener
514     */
515    public abstract void removeGlobalOverlayListener(GlobalOverlayListener listener);
516
517    /**
518     * Add global Plugin listener
519     */
520    public abstract void addGlobalPluginListener(GlobalPluginListener listener);
521
522    /**
523     * Remove global Plugin listener
524     */
525    public abstract void removeGlobalPluginListener(GlobalPluginListener listener);
526
527    /**
528     * @deprecated Use {@link #addActiveViewerListener(ActiveViewerListener)} instead.
529     */
530    @Deprecated
531    public abstract void addFocusedViewerListener(FocusedViewerListener listener);
532
533    /**
534     * @deprecated Use {@link #removeActiveViewerListener(ActiveViewerListener)} instead.
535     */
536    @Deprecated
537    public abstract void removeFocusedViewerListener(FocusedViewerListener listener);
538
539    /**
540     * Add active viewer listener.<br>
541     * This permit to receive events of activated viewer only.<br>
542     * It can also be used to detect viewer activation change.
543     */
544    public abstract void addActiveViewerListener(ActiveViewerListener listener);
545
546    /**
547     * Remove active viewer listener.
548     */
549    public abstract void removeActiveViewerListener(ActiveViewerListener listener);
550
551    /**
552     * @deprecated Use {@link #addActiveSequenceListener(ActiveSequenceListener)} instead.
553     */
554    @Deprecated
555    public abstract void addFocusedSequenceListener(FocusedSequenceListener listener);
556
557    /**
558     * @deprecated Use {@link #removeActiveSequenceListener(ActiveSequenceListener)} instead.
559     */
560    @Deprecated
561    public abstract void removeFocusedSequenceListener(FocusedSequenceListener listener);
562
563    /**
564     * Add active sequence listener.<br>
565     * This permit to receive events of activated sequence only.<br>
566     * It can also be used to detect sequence activation change.
567     */
568    public abstract void addActiveSequenceListener(ActiveSequenceListener listener);
569
570    /**
571     * Remove focused sequence listener.
572     */
573    public abstract void removeActiveSequenceListener(ActiveSequenceListener listener);
574
575    /**
576     * Add "can exit" listener.<br>
577     * <br>
578     * CAUTION : A weak reference is used to reference the listener for easier release<br>
579     * so you should have a hard reference to your listener to keep it alive.
580     */
581    public abstract void addCanExitListener(AcceptListener listener);
582
583    /**
584     * Remove "can exit" listener
585     */
586    public abstract void removeCanExitListener(AcceptListener listener);
587
588    /**
589     * @deprecated
590     */
591    @Deprecated
592    public abstract void beginUpdate();
593
594    /**
595     * @deprecated
596     */
597    @Deprecated
598    public abstract void endUpdate();
599
600    /**
601     * @deprecated
602     */
603    @Deprecated
604    public abstract boolean isUpdating();
605}