File: DICOMscope.java

package info (click to toggle)
dicomscope 3.6.0-28
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,256 kB
  • sloc: java: 22,911; cpp: 5,957; sh: 270; makefile: 45
file content (359 lines) | stat: -rw-r--r-- 9,928 bytes parent folder | download | duplicates (9)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/*
 *
 *  Copyright (C) 1999, Institute for MicroTherapy
 *
 *  This software and supporting documentation were developed by
 *
 *    University of Witten/Herdecke
 *    Department of Radiology and MicroTherapy
 *    Institute for MicroTherapy
 *    Medical computer science
 *    
 *    Universitaetsstrasse 142
 *    44799 Bochum, Germany
 *    
 *    http://www.microtherapy.de/go/cs
 *    mailto:computer.science@microtherapy.de
 *
 *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND THE INSTITUTE MAKES  NO 
 *  WARRANTY REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY
 *  OR FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES 
 *  OR ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY 
 *  AND PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
 *
 *
 *  Author :      $Author: kleber $
 *  Last update : $Date: 2001/06/06 10:32:29 $
 *  Revision :    $Revision: 1.1.1.1 $
 *  State:        $State: Exp $
*/

package DICOMscope;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

// Import all packages of the project:
import J2Ci.*;
import browser.*;
import main.MainContext;
import viewer.main.*;
import viewer.presentation.*;
import jToolkit.gui.*;
import jToolkit.io.*;
import about.*;
import main.*;
import viewer.gui.*;
import javax.swing.event.*;
import dicomPrint.*;
import processCommunication.*;

/**
 * This is the main class. This class initializes the study
 * browser, the viewer, the print panel  and the about box.
 * @author Andreas Schroeter
 * @since 30.03.
 */
public class DICOMscope extends JFrame implements MainListener
{

	
    /**
     * The interface to the Dicom Toolkit
     */
    private jDVInterface dvi = null;

    /**
     * Contains the current PrintPanel 
     */
    private PrintPanel printPanel;
	
    /**
    * Contains the main TabbedPane
    */
    private JTabbedPane	tabpane ;		
	
    
    

    /**
     * Main Method. Initializes this class.
     * @param args Will be ignored
     */
    
    public static  void main (String[] args)
    {
        System.out.println ("starting DICOMscope");
        System.out.println ("please wait...");
        System.out.flush(); // force output right now!
        
        MainContext mc = MainContext.instance(); // create context
        
        DICOMscope sup = new DICOMscope();
        sup.setVisible(true);
    }

    /**
	* Constructor. 
	*/
    public DICOMscope()
    {
	Controller.instance().addMainListener(this);
	dvi = new jDVInterface ("DICOMscope.cfg"); // change with configfile
		
	tabpane = new JTabbedPane(JTabbedPane.TOP);			
		
	MainContext.instance().initConfiguration(dvi); // create context
		
	Hashtable config = MainContext.instance().getConfiguration();
		
	setConfiguration(config, true);
		
		
		
	getContentPane().setLayout(new BorderLayout(0,0));
	//getRoontPane().setFont
	java.awt.Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            
        setSize (screen.width, screen.height);
		//setSize(300,300);
	SymWindow aSymWindow = new SymWindow();
	this.addWindowListener(aSymWindow);
	addComponentListener(new CmpAdapter());
		
		
        //Init toolbar
	DicomScopeToolBar toolbar;
         boolean print = false;
         if (dvi.getNumberOfTargets(jDVPSPeerType.DVPSE_printAny)>0 ) print = true;      
        toolbar = new DicomScopeToolBar(config, print);
        getContentPane().add(toolbar,BorderLayout.NORTH);
        boolean signWarning=true;
        if (config.containsKey("SignWarning"))signWarning=((Boolean)config.get("SignWarning")).booleanValue();
	
	StatusLine sl = new StatusLine(DSComponentType.BROWSER,dvi,signWarning);
	getContentPane().add ( sl, BorderLayout.SOUTH);
		

	StudyMan studyMan = new StudyMan (dvi, this,config);
	MainImageViewerPanel mImage = new MainImageViewerPanel(new PresentationStateGraphicsHandler(dvi),config,this);
	AboutBox about =  new AboutBox (config);
	tabpane.add (DSComponentType.BROWSER, studyMan);
	tabpane.add (DSComponentType.VIEWER, mImage);

        if (print)
        {
                    
	    printPanel = new  PrintPanel(dvi,config);
	    tabpane.add (DSComponentType.PRINT,printPanel );
	}
	tabpane.add (DSComponentType.PROCESS,new ProcessComponent(this, MainContext.instance().logFont));
	
	tabpane.add (DSComponentType.ABOUT,about);
		
	getContentPane().add (tabpane, BorderLayout.CENTER);
		
	tabpane.addChangeListener(new ChangeToComponentListener() );
		
		
	Controller.instance().fireStatus(new StatusLineEvent(this,StatusLineEvent.SET_DES,DSComponentType.BROWSER,"Ready"));
	Controller.instance().fireEvent(new TabbedChangeEvent(DICOMscope.this,DSComponentType.BROWSER));
	    
	ProcessCommunicationService pcs= new ProcessCommunicationService(dvi.getMessagePort(), true);
	
	dvi.startReceiver (); 
	dvi.startPrintSpooler();
	dvi.startPrintServer();
	dvi.startQueryRetrieveServer();
	System.setOut(new NullPrintStream());
		
        
		
    }

    /**
    * Closes the application and terminates the network receiver.
    */
    class SymWindow extends java.awt.event.WindowAdapter
    {
	public void windowClosing(java.awt.event.WindowEvent event)
	{
	    Object object = event.getSource();
	    if (object == DICOMscope.this)closing(event);
	    {
	    }
			
	}
    }

    /**
    * Closes the application and terminates the network receiver.
    * @param event The calling event. ignored.
    */
    public void closing(java.awt.event.WindowEvent event)
    {
	dvi.terminateReceiver();	  
	dvi.terminatePrintSpooler();
	dvi.terminatePrintServer();
	dvi.terminateQueryRetrieveServer();
	dvi.finalize();
	    //setVisible(false);		 // hide the Frame
        System.exit (0);
    }
    
    /**
    * Handles the ChangeEvents. 
    */
    private class ChangeToComponentListener implements ChangeListener
    {
	public void stateChanged(ChangeEvent e)
	{
	    JTabbedPane tb = (JTabbedPane)e.getSource();
	    int index = tb.getSelectedIndex();
	    String s = tb.getTitleAt(index);
	    Controller.instance().fireEvent(new TabbedChangeEvent(DICOMscope.this,s));
	}
	    
    }
	
    /**
    * Handles the ComponentEvents.
    */
    private class CmpAdapter extends ComponentAdapter 
    {
        public void componentResized(ComponentEvent evt) 
        {            
            MainContext mc = MainContext.instance(); // create context
        		    
            Dimension d = getSize();
                                
            if (mc.highQualitySystem) // doppelte Gre als Minimum
            {
                if (d.width < 1500) d.width = 1500;
                if (d.height < 1500) d.height = 1500;
            }
            else
            {
                if (d.width < 700) d.width =700;
                if (d.height < 600) d.height = 600;
            }
                    
            setSize (d);
        }
    }

    /**
    * Toggles  tabpane to the viewer.
    * 
    * @since 30.03
    */
    public void switchToViewer ()
    {
	    
	tabpane.setSelectedIndex(1);
	tabpane.repaint();
    }

    /**
	* Toggles the tabpane to the PrintPanel.
	* 
	* @since 30.03
	*/
	
	
    public void switchToPrinter ()
    {
	if (printPanel != null)
	{
	    tabpane.setSelectedComponent(printPanel);
	    tabpane.repaint();
	}
    }

   
   
   
    /**
    * Handels the DSEvent fired by any Object of DICOMScope
    */
    public boolean processEvent (DSEvent e)
    {
	if (e instanceof ChangeOptionsEvent)
	{
           
            setConfiguration(((ChangeOptionsEvent)e).getConfig(), false);
	}
	    
	return false;
    }
    
    /**
    * Sets the configuration of DICOMscope.
    * @param config Contains the configuration.
    * @param init should be true if this function is called the first time.
    */
    private void setConfiguration(Hashtable config, boolean init)
    {
        if (config.containsKey("Title"))setTitle((String)(config.get("Title")));
            
        if (config.containsKey("TabbedPlacement"))tabpane.setTabPlacement((new Integer((String)(config.get("TabbedPlacement"))).intValue()));
        if (config.containsKey("UI")) 
        {
	    try 
	    {
		UIManager.setLookAndFeel((String) config.get("UI") );
		// update the complete application's look & feel
		SwingUtilities.updateComponentTreeUI( DICOMscope.this);
	    }
	    catch( Exception f ) 
	    {
		System.err.println( " unable to set UI " + f.getMessage() );
	    }
                
        }
        if (!init)tabpane.updateUI();
        if (init)
        {
	    Font f = (Font) config.get("GUIFont");
	    Font titledBorderFont = new Font(f.getName(), f.getStyle(),f.getSize()-f.getSize()/4);
	    UIDefaults uiDefaults = UIManager.getDefaults();
            uiDefaults.put("MenuItem.font",f);
            uiDefaults.put("Label.font", f);
            uiDefaults.put("ComboBox.font",f);
            uiDefaults.put("Button.font", f);
            uiDefaults.put("CheckBox.font", f);
            uiDefaults.put("CheckBoxMenuItem.font", f);
            uiDefaults.put("RadioButtonMenuItem.font", f);
            uiDefaults.put("RadioButton.font", f);
            uiDefaults.put("TitledBorder.font", titledBorderFont);
            uiDefaults.put("TextField.font", f);
            uiDefaults.put("Dialog.font", f);
            uiDefaults.put("TabbedPane.font",f);
            uiDefaults.put("Frame.font", f);
            uiDefaults.put("Scrollbar.font", f);
            uiDefaults.put("Tree.font", f);
            uiDefaults.put("EditorPane.font", f);
            uiDefaults.put("TextArea.font", f);
            uiDefaults.put("List.font", f);
            uiDefaults.put("AbstractButton.font", f);
            uiDefaults.put("ToolTip.font", f);
            uiDefaults.put("Button", f);
            tabpane.updateUI();
        }
	    
    }
	
}


/*
 *  CVS Log
 *  $Log: DICOMscope.java,v $
 *  Revision 1.1.1.1  2001/06/06 10:32:29  kleber
 *  Init commit for DICOMscope 3.5
 *  Create new CVS
 *
*/