Logo Search packages:      
Sourcecode: pixelmed version File versions  Download package

void com::pixelmed::display::DicomImageViewer::doCommonConstructorStuff ( String  title,
String  dicomFileName 
) [inline, private]

Parameters:
title 
dicomFileName 

Definition at line 2273 of file DicomImageViewer.java.

References com::pixelmed::network::NetworkApplicationProperties::getCalledAETitle(), com::pixelmed::database::DatabaseApplicationProperties::getDatabaseFileName(), com::pixelmed::database::DatabaseApplicationProperties::getDatabaseServerName(), com::pixelmed::network::NetworkApplicationProperties::getListeningPort(), com::pixelmed::display::ApplicationFrame::getProperties(), com::pixelmed::network::NetworkApplicationProperties::getQueryDebugLevel(), com::pixelmed::database::DatabaseInformationModel::getQueryResponseGeneratorFactory(), com::pixelmed::database::DatabaseInformationModel::getRetrieveResponseGeneratorFactory(), com::pixelmed::database::DatabaseApplicationProperties::getSavedImagesFolderCreatingItIfNecessary(), com::pixelmed::display::ApplicationFrame::getStatusBar(), com::pixelmed::network::NetworkApplicationProperties::getStorageSCPDebugLevel(), loadDicomFileOrDirectoryCallingChooserIfRequired(), com::pixelmed::display::ApplicationFrame::makePathToFileInUsersHomeDirectory(), setCurrentFilePathSelection(), setCurrentRemoteQueryInformationModel(), and com::pixelmed::network::NetworkApplicationInformationFederated::startupAllKnownSourcesAndRegister().

Referenced by DicomImageViewer().

                                                                               {
//Font defaultFont=new JLabel().getFont();
//System.err.println("defaultFont="+defaultFont);
//{
//Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
//for (int i=0; i<fonts.length; ++i) System.err.println("font "+fonts[i]);
//}

            mainPanelFrameSortOrderChangeListener = new OurFrameSortOrderChangeListener(WellKnownContext.MAINPANEL);
            mainPanelFrameSelectionChangeListener = new OurFrameSelectionChangeListener(WellKnownContext.MAINPANEL);
            ourBrowserPaneChangeListener = new OurBrowserPaneChangeListener(WellKnownContext.MAINPANEL);

            // No frame selection or sort order listener required for reference panel
            
            addKeyListener(this);         // for screen snapshot
            addMouseListener(this);       // for screen snapshot (allows us to grab keyboard focus by moving mouse out and back into app)

            {
                  spectroscopyLocalizerManager = new SpectroscopyLocalizerManager();
                  spectroscopyLocalizerManager.setReferenceSourceImageSelectionContext(WellKnownContext.REFERENCEPANEL);
                  spectroscopyLocalizerManager.setReferenceImageFrameSelectionContext(WellKnownContext.REFERENCEPANEL);
                  spectroscopyLocalizerManager.setReferenceImageFrameSortOrderContext(WellKnownContext.REFERENCEPANEL);
                  spectroscopyLocalizerManager.setSourceSpectrumSelectionContext(WellKnownContext.MAINPANEL);
                  spectroscopyLocalizerManager.setSpectrumFrameSelectionContext(WellKnownContext.MAINPANEL);
                  spectroscopyLocalizerManager.setSpectrumFrameSortOrderContext(WellKnownContext.MAINPANEL);
                  
                  imageLocalizerManager = new ImageLocalizerManager();
                  imageLocalizerManager.setReferenceSourceImageSelectionContext(WellKnownContext.REFERENCEPANEL);
                  imageLocalizerManager.setReferenceImageFrameSelectionContext(WellKnownContext.REFERENCEPANEL);
                  imageLocalizerManager.setReferenceImageFrameSortOrderContext(WellKnownContext.REFERENCEPANEL);
                  imageLocalizerManager.setMainSourceImageSelectionContext(WellKnownContext.MAINPANEL);
                  imageLocalizerManager.setMainImageFrameSelectionContext(WellKnownContext.MAINPANEL);
                  imageLocalizerManager.setMainImageFrameSortOrderContext(WellKnownContext.MAINPANEL);
            }
            
            Properties properties = getProperties();
//System.err.println("properties="+properties);

            databaseApplicationProperties = new DatabaseApplicationProperties(properties);
            
            File savedImagesFolder = null;
            
            if (databaseApplicationProperties != null) {
            
                  // Make sure there is a folder to store received and imported images ...
            
                  try {
                        savedImagesFolder = databaseApplicationProperties.getSavedImagesFolderCreatingItIfNecessary();
                  } catch (Exception e) {
                        e.printStackTrace(System.err);
                  }

                  // Start up database ...
            
//System.err.println("Starting up database ...");
                  databaseInformationModel=null;
                  try {
                        databaseInformationModel = new PatientStudySeriesConcatenationInstanceModel(makePathToFileInUsersHomeDirectory(databaseApplicationProperties.getDatabaseFileName()),databaseApplicationProperties.getDatabaseServerName());
                        //databaseInformationModel = new StudySeriesInstanceModel(makePathToFileInUsersHomeDirectory(dataBaseFileName));
                  } catch (Exception e) {
                        e.printStackTrace(System.err);
                  }
            }
            
//System.err.println("Starting up network configuration information sources ...");
            try {
                  networkApplicationProperties = new NetworkApplicationProperties(properties);
            }
            catch (Exception e) {
                  networkApplicationProperties = null;
            }
            {
                  NetworkApplicationInformationFederated federatedNetworkApplicationInformation = new NetworkApplicationInformationFederated();
                  federatedNetworkApplicationInformation.startupAllKnownSourcesAndRegister(networkApplicationProperties);
                  networkApplicationInformation = federatedNetworkApplicationInformation;
System.err.println("networkApplicationInformation ...\n"+networkApplicationInformation);
            }
            
            // Start up DICOM association listener in background for receiving images and responding to echoes ...
System.err.println("Starting up DICOM association listener ...");
            if (networkApplicationProperties != null) { 
                  try {
                        int port = networkApplicationProperties.getListeningPort();
                        String calledAETitle = networkApplicationProperties.getCalledAETitle();
                        int storageSCPDebugLevel = networkApplicationProperties.getStorageSCPDebugLevel();
                        int queryDebugLevel = networkApplicationProperties.getQueryDebugLevel();
                        new Thread(new StorageSOPClassSCPDispatcher(port,calledAETitle,savedImagesFolder,storedFilePathStrategy,new OurReceivedObjectHandler(),
                              databaseInformationModel == null ? null : databaseInformationModel.getQueryResponseGeneratorFactory(queryDebugLevel),
                              databaseInformationModel == null ? null : databaseInformationModel.getRetrieveResponseGeneratorFactory(queryDebugLevel),
                              networkApplicationInformation,
                              false/*secureTransport*/,
                              storageSCPDebugLevel)).start();
                  }
                  catch (IOException e) {
                        e.printStackTrace(System.err);
                  }
            }

            setCurrentFilePathSelection(null);
            
System.err.println("Building GUI ...");

            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            applicationWidth  = (int)(screenSize.getWidth())  - 20;
            applicationHeight = (int)(screenSize.getHeight()) - 70;
            imagesPerRow=1;
            imagesPerCol=1;
            
            Container content = getContentPane();
            EmptyBorder emptyBorder = (EmptyBorder)BorderFactory.createEmptyBorder();
            
            final JPanel multiPanel = new JPanel();
            multiPanel.setLayout(new GridLayout(imagesPerCol,imagesPerRow));
            multiPanel.setBackground(Color.black);
            multiPanel.setOpaque(true);                     // normally the default, but not for Quaqua - if not set, grey rather than black background will show through
            //multiPanel.setBorder(emptyBorder);

            referenceImagePanelForImages = new JPanel();
            referenceImagePanelForImages.setLayout(new GridLayout(1,1));
            referenceImagePanelForImages.setBackground(Color.black);
            //multiPanel.setBorder(emptyBorder);
            //referenceImagePanelForImages.setSize(new Dimension(128,128));
            referenceImagePanelForImages.setPreferredSize(new Dimension(128,128));
            //referenceImagePanelForImages.setMinimumSize(new Dimension(128,128));
            //referenceImagePanelForImages.setMaximumSize(new Dimension(128,128));

            referenceImagePanelForSpectra = new JPanel();
            referenceImagePanelForSpectra.setLayout(new GridLayout(1,1));
            referenceImagePanelForSpectra.setBackground(Color.black);
            //multiPanel.setBorder(emptyBorder);
            //referenceImagePanelForSpectra.setSize(new Dimension(128,128));
            referenceImagePanelForSpectra.setPreferredSize(new Dimension(128,128));
            //referenceImagePanelForSpectra.setMinimumSize(new Dimension(128,128));
            //referenceImagePanelForSpectra.setMaximumSize(new Dimension(128,128));

            final JScrollPane scrollPaneOfCurrentAttributes = new JScrollPane();    // declared final because accessed from inner class (tab change action database refresh)
            //scrollPaneOfCurrentAttributes.setBorder(emptyBorder);
            createTableOfCurrentAttributesForCurrentFrameBrowser();
            scrollPaneOfCurrentAttributes.setViewportView(getTableOfCurrentAttributesForCurrentFrameBrowser());

            final JScrollPane attributeFrameTableScrollPane=new JScrollPane();
            //attributeTreeScrollPane.setBorder(emptyBorder);
            createTableOfCurrentAttributesForAllFramesBrowser();
            attributeFrameTableScrollPane.setViewportView(getTableOfCurrentAttributesForAllFramesBrowser());

            displayControlsPanel = new JPanel();
            //displayControlsPanel.setLayout(new GridLayout(3,1));
            displayControlsPanel.setLayout(new BorderLayout());
            JPanel displayButtonsPanel = new JPanel();
            //displayControlsPanel.add(displayButtonsPanel);
            displayControlsPanel.add(displayButtonsPanel,BorderLayout.NORTH);
            displayButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
            //displayControlsPanel.setBorder(emptyBorder);
            JButton displayFileButton = new JButton("File...");
            displayFileButton.setToolTipText("Choose a DICOM image or spectroscopy file to display or DICOMDIR file to browse");
            displayButtonsPanel.add(displayFileButton);
            JButton displayImportButton = new JButton("Import");
            displayImportButton.setToolTipText("Import a copy of displayed image into the local database");
            displayButtonsPanel.add(displayImportButton);
            JButton displaySendButton = new JButton("Send...");
            displaySendButton.setToolTipText("Send displayed image via DICOM network");
            displayButtonsPanel.add(displaySendButton);
            JButton displayXMLButton = new JButton("XML...");
            displayXMLButton.setToolTipText("Save displayed image attributes to XML file");
            displayButtonsPanel.add(displayXMLButton);
            JButton displayValidateButton = new JButton("Validate...");
            displayValidateButton.setToolTipText("Validate displayed image against standard IOD");
            displayButtonsPanel.add(displayValidateButton);
            
            {
                  JPanel displayControlsSubPanel = new JPanel();
                  displayControlsPanel.add(displayControlsSubPanel,BorderLayout.CENTER);
                  displayControlsSubPanel.setLayout(new BorderLayout());

                  SourceImageSortOrderPanel displaySortPanel = new SourceImageSortOrderPanel(WellKnownContext.MAINPANEL);
                  displayControlsSubPanel.add(displaySortPanel,BorderLayout.NORTH);

                  {
                        JPanel displayControlsSubSubPanel = new JPanel();
                        displayControlsSubSubPanel.setLayout(new GridLayout(2,1));
                        displayControlsSubPanel.add(displayControlsSubSubPanel,BorderLayout.SOUTH);

                        sourceImageVOILUTSelectorPanel = new SourceImageVOILUTSelectorPanel(null/* Apply to all contexts, not just WellKnownContext.MAINPANEL*/);
                        displayControlsSubSubPanel.add(sourceImageVOILUTSelectorPanel);
            
                        sourceImageGraphicDisplaySelectorPanel = new SourceImageGraphicDisplaySelectorPanel(null/* Apply to all contexts, not just WellKnownContext.MAINPANEL*/);
                        displayControlsSubSubPanel.add(sourceImageGraphicDisplaySelectorPanel);
                  }
            }
            
            final JList displayListOfPossibleReferenceImagesForImages;
            {
                  JPanel referenceSubPanel = new JPanel(new BorderLayout());
                  displayControlsPanel.add(referenceSubPanel,BorderLayout.SOUTH);
                  
                  JPanel referenceImageSubPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));            // nest these to make image centered and not fill width with black
                  referenceSubPanel.add(referenceImageSubPanel,BorderLayout.CENTER);
                  referenceImageSubPanel.add(referenceImagePanelForImages);

                  displayListOfPossibleReferenceImagesForImages = new JList();
                  displayListOfPossibleReferenceImagesForImages.setVisibleRowCount(4);    // need enough height for vertical scroll bar to show, including if horizontal scroll activates
                  JScrollPane scrollingDisplayListOfPossibleReferenceImages = new JScrollPane(displayListOfPossibleReferenceImagesForImages);
                  
                  referenceSubPanel.add(scrollingDisplayListOfPossibleReferenceImages,BorderLayout.NORTH);
                  
                  displayListOfPossibleReferenceImagesForImages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                  displayListOfPossibleReferenceImagesForImages.addListSelectionListener(new OurReferenceListSelectionListener(referenceImagePanelForImages,false));
            }

            spectroscopyControlsPanel = new JPanel();
            spectroscopyControlsPanel.setLayout(new BorderLayout());
            JPanel spectroscopyButtonsPanel = new JPanel();
            spectroscopyControlsPanel.add(spectroscopyButtonsPanel,BorderLayout.NORTH);
            spectroscopyButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
            //spectroscopyControlsPanel.setBorder(emptyBorder);
            JButton spectroscopyFileButton = new JButton("File...");
            spectroscopyFileButton.setToolTipText("Choose a DICOM image or spectroscopy file to display or DICOMDIR file to browse");
            spectroscopyButtonsPanel.add(spectroscopyFileButton);
            JButton spectroscopyImportButton = new JButton("Import");
            spectroscopyImportButton.setToolTipText("Import a copy of displayed specra into the local database");
            spectroscopyButtonsPanel.add(spectroscopyImportButton);
            JButton spectroscopySendButton = new JButton("Send...");
            spectroscopySendButton.setToolTipText("Send display spectra via DICOM network");
            spectroscopyButtonsPanel.add(spectroscopySendButton);
            JButton spectroscopyXMLButton = new JButton("XML...");
            spectroscopyXMLButton.setToolTipText("Save displayed spectra attributes to XML file");
            spectroscopyButtonsPanel.add(spectroscopyXMLButton);
            JButton spectroscopyValidateButton = new JButton("Validate...");
            spectroscopyValidateButton.setToolTipText("Validate displayed spectra against standard IOD");
            spectroscopyButtonsPanel.add(spectroscopyValidateButton);
            
            SourceSpectrumSortOrderPanel spectroscopySortPanel = new SourceSpectrumSortOrderPanel(WellKnownContext.MAINPANEL);
            spectroscopyControlsPanel.add(spectroscopySortPanel,BorderLayout.CENTER);
            
            final JList displayListOfPossibleBackgroundImagesForSpectra;
            final JList displayListOfPossibleReferenceImagesForSpectra;
            {
                  JPanel spectroscopyBackgroundAndReferenceGroupPanel = new JPanel(new BorderLayout());
                  spectroscopyControlsPanel.add(spectroscopyBackgroundAndReferenceGroupPanel,BorderLayout.SOUTH);
                  {
                        JPanel backgroundSubPanel = new JPanel(new BorderLayout());
                        spectroscopyBackgroundAndReferenceGroupPanel.add(backgroundSubPanel,BorderLayout.NORTH);
                  
                        displayListOfPossibleBackgroundImagesForSpectra = new JList();
                        displayListOfPossibleBackgroundImagesForSpectra.setVisibleRowCount(4);  // need enough height for vertical scroll bar to show, including if horizontal scroll activates
                        JScrollPane scrollingDisplayListOfPossibleBackgroundImages = new JScrollPane(displayListOfPossibleBackgroundImagesForSpectra);
                  
                        backgroundSubPanel.add(scrollingDisplayListOfPossibleBackgroundImages,BorderLayout.NORTH);
                  
                        displayListOfPossibleBackgroundImagesForSpectra.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                        displayListOfPossibleBackgroundImagesForSpectra.addListSelectionListener(new OurBackgroundListSelectionListener());
                  }
                  {
                        JPanel referenceSubPanel = new JPanel(new BorderLayout());
                        spectroscopyBackgroundAndReferenceGroupPanel.add(referenceSubPanel,BorderLayout.SOUTH);
                  
                        JPanel referenceImageSubPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));            // nest these to make image centered and not fill width with black
                        referenceSubPanel.add(referenceImageSubPanel,BorderLayout.CENTER);
                        referenceImageSubPanel.add(referenceImagePanelForSpectra);

                        displayListOfPossibleReferenceImagesForSpectra = new JList();
                        displayListOfPossibleReferenceImagesForSpectra.setVisibleRowCount(4);   // need enough height for vertical scroll bar to show, including if horizontal scroll activates
                        JScrollPane scrollingDisplayListOfPossibleReferenceImages = new JScrollPane(displayListOfPossibleReferenceImagesForSpectra);
                  
                        referenceSubPanel.add(scrollingDisplayListOfPossibleReferenceImages,BorderLayout.NORTH);
                  
                        displayListOfPossibleReferenceImagesForSpectra.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                        displayListOfPossibleReferenceImagesForSpectra.addListSelectionListener(new OurReferenceListSelectionListener(referenceImagePanelForSpectra,true));
                  }
            }

            dicomdirControlsPanel = new JPanel();
            //dicomdirControlsPanel.setBorder(emptyBorder);
            dicomdirControlsPanel.setLayout(new BorderLayout());
            JPanel dicomdirButtonsPanel = new JPanel();
            dicomdirControlsPanel.add(dicomdirButtonsPanel,BorderLayout.NORTH);
            dicomdirButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
            JButton dicomdirFileButton = new JButton("File...");
            dicomdirFileButton.setToolTipText("Choose a DICOM image file to display or DICOMDIR file to browse");
            dicomdirButtonsPanel.add(dicomdirFileButton);
            JButton dicomdirImportButton = new JButton("Import");
            dicomdirImportButton.setToolTipText("Import all the images selected into the local database");
            dicomdirButtonsPanel.add(dicomdirImportButton);
            JButton dicomdirViewSelectionButton = new JButton("View");
            dicomdirViewSelectionButton.setToolTipText("Display the image selected (or first image of the selection)");
            dicomdirButtonsPanel.add(dicomdirViewSelectionButton);
            JButton dicomdirSendButton = new JButton("Send...");
            dicomdirSendButton.setToolTipText("Send all the images selected via DICOM network");
            dicomdirButtonsPanel.add(dicomdirSendButton);
            JScrollPane dicomdirTreeScrollPane=new JScrollPane();
            //dicomdirTreeScrollPane.setBorder(emptyBorder);
            dicomdirControlsPanel.add(dicomdirTreeScrollPane,BorderLayout.CENTER);

            databaseControlsPanel = new JPanel();
            //databaseControlsPanel.setBorder(emptyBorder);
            databaseControlsPanel.setLayout(new BorderLayout());
            JPanel databaseButtonsPanel = new JPanel();
            databaseButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));      // The use of FlowLayout means the buttons will disappear if browserPane gets too narrow
            databaseControlsPanel.add(databaseButtonsPanel,BorderLayout.NORTH);
            JButton databaseRefreshButton = new JButton("Refresh");
            databaseRefreshButton.setToolTipText("Query the database to update the browser");
            databaseButtonsPanel.add(databaseRefreshButton);
            JButton databaseFileButton = new JButton("File...");
            databaseFileButton.setToolTipText("Import DICOM files from a DICOMDIR or recursive directory search");
            databaseButtonsPanel.add(databaseFileButton);
            JButton databaseViewSelectionButton = new JButton("View");
            databaseViewSelectionButton.setToolTipText("Display the image selected");
            databaseButtonsPanel.add(databaseViewSelectionButton);
            JButton databaseSendButton = new JButton("Send...");
            databaseSendButton.setToolTipText("Send all the images selected via DICOM network");
            databaseButtonsPanel.add(databaseSendButton);
            final JScrollPane databaseTreeScrollPane=new JScrollPane();       // declared final because accessed from inner class (tab change action database refresh)
            //databaseTreeScrollPane.setBorder(emptyBorder);
            databaseControlsPanel.add(databaseTreeScrollPane,BorderLayout.CENTER);

            queryControlsPanel = new JPanel();
            //queryControlsPanel.setBorder(emptyBorder);
            queryControlsPanel.setLayout(new BorderLayout());
            JPanel queryButtonsPanel = new JPanel();
            queryButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));   // The use of FlowLayout means the buttons will disappear if browserPane gets too narrow
            queryControlsPanel.add(queryButtonsPanel,BorderLayout.NORTH);
            JButton querySelectButton = new JButton("Select");
            querySelectButton.setToolTipText("Select the remote system to use for subsequent queries");
            queryButtonsPanel.add(querySelectButton);
            JButton queryFilterButton = new JButton("Filter");
            queryFilterButton.setToolTipText("Configure the filter to use for subsequent queries");
            queryButtonsPanel.add(queryFilterButton);
            JButton queryRefreshButton = new JButton("Query");
            queryRefreshButton.setToolTipText("Query the currently selected remote system to update the browser");
            queryButtonsPanel.add(queryRefreshButton);
            JButton queryRetrieveButton = new JButton("Retrieve");
            queryRetrieveButton.setToolTipText("Retrieve the selection to the local database");
            queryButtonsPanel.add(queryRetrieveButton);
            JScrollPane queryTreeScrollPane=new JScrollPane();
            //queryTreeScrollPane.setBorder(emptyBorder);
            queryControlsPanel.add(queryTreeScrollPane,BorderLayout.CENTER);

            final JPanel attributeTreeControlsPanel = new JPanel();
            //attributeTreeControlsPanel.setBorder(emptyBorder);
            attributeTreeControlsPanel.setLayout(new BorderLayout());
            final JPanel attributeTreeButtonsPanel = new JPanel();
            attributeTreeControlsPanel.add(attributeTreeButtonsPanel,BorderLayout.NORTH);
            attributeTreeButtonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
            final JScrollPane attributeTreeScrollPane=new JScrollPane();
            
            attributeTreeButtonsPanel.add(new JLabel("Sort attributes:"));

            attributeTreeSortOrderButtons = new ButtonGroup();
            SortAttributesActionListener sortAttributesActionListener = new SortAttributesActionListener(attributeTreeScrollPane);

            JRadioButton sortAttributesByNameButton = new JRadioButton("by name",true);
            sortAttributesByNameButton.setActionCommand(SortAttributesActionListener.ByName);
            sortAttributesByNameButton.setToolTipText("Sort attributes in tree alphabetically by name");
            sortAttributesByNameButton.addActionListener(sortAttributesActionListener);
            attributeTreeSortOrderButtons.add(sortAttributesByNameButton);
            attributeTreeButtonsPanel.add(sortAttributesByNameButton);

            JRadioButton sortAttributesByTagNumberButton = new JRadioButton("by number",false);
            sortAttributesByTagNumberButton.setActionCommand(SortAttributesActionListener.ByNumber);
            sortAttributesByTagNumberButton.setToolTipText("Sort attributes in tree numerically by group and element number");
            sortAttributesByTagNumberButton.addActionListener(sortAttributesActionListener);
            attributeTreeSortOrderButtons.add(sortAttributesByTagNumberButton);
            attributeTreeButtonsPanel.add(sortAttributesByTagNumberButton);

            //attributeTreeScrollPane.setBorder(emptyBorder);
            attributeTreeControlsPanel.add(attributeTreeScrollPane,BorderLayout.CENTER);

            browserPane = new JTabbedPane();
            //browserPane.setBorder(emptyBorder);
            //browserPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);  // this is (effectively) what recent Mac JREs do, though they also select new tabs (unlike Windows and Metal)
            browserPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);            // this is the default anyway; it is also ignored on recent Mac JREs :(
            browserPane.addTab("Local",databaseControlsPanel);
            browserPane.setToolTipTextAt(0,"Browse the contents of the local database");
            browserPane.addTab("Remote",queryControlsPanel);
            browserPane.setToolTipTextAt(1,"Browse the contents of the local database");
            int tabNumberOfRemoteInBrowserPane=1;
            browserPane.addTab("DICOMDIR",dicomdirControlsPanel);
            browserPane.setToolTipTextAt(2,"Browse the contents of the currently loaded DICOMDIR");
            browserPane.addTab("Image", displayControlsPanel);
            browserPane.setToolTipTextAt(3,"Controls for the currently displayed image");
            browserPane.addTab("Spectra", spectroscopyControlsPanel);
            browserPane.setToolTipTextAt(4,"Controls for the currently displayed spectra");
            browserPane.addTab("Attributes",attributeTreeControlsPanel);
            browserPane.setToolTipTextAt(5,"Tree of attributes and values for currently displayed image");
            browserPane.addTab("Frames", attributeFrameTableScrollPane);
            browserPane.setToolTipTextAt(6,"Table of all per-frame varying attributes for this object");

            browserPane.setEnabledAt(browserPane.indexOfComponent(displayControlsPanel),false);
            browserPane.setEnabledAt(browserPane.indexOfComponent(spectroscopyControlsPanel),false);

            final DicomImageViewer ourselves = this;
            browserPane.addChangeListener(new ChangeListener() {
                        // This method is called whenever the selected tab changes
                        public void stateChanged(ChangeEvent evt) {
                        JTabbedPane pane = (JTabbedPane)evt.getSource();
                        // Get current tab
                        int sel = pane.getSelectedIndex();
//System.err.println("browserPane.ChangeListener(): selection "+sel);
                        if (sel == browserPane.indexOfComponent(databaseControlsPanel)) {
                              try {
                                    new OurDatabaseTreeBrowser(databaseInformationModel,
                                          ourselves,multiPanel,
                                          referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                                          referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                                          databaseTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane);
                              }
                              catch (Exception e) {
                                    e.printStackTrace(System.err);
                              }
                        }
                  }
            });

            // Set up query model based on properties ... (have to wait till now to know browserPane etc.)
            
            setCurrentRemoteQueryInformationModel(properties.getProperty(propertyName_DicomCurrentlySelectedQueryTargetAE),browserPane,tabNumberOfRemoteInBrowserPane);
            initializeCurrentRemoteQueryFilter();
            
            JLabel statusBar = getStatusBar();

//System.err.println("Loading DICOM file or chooser ...");
            String lastDirectoryPath = dicomFileName == null ? null : new File(dicomFileName).getParent();
            lastDirectoryPath = loadDicomFileOrDirectoryCallingChooserIfRequired(dicomFileName,this,multiPanel,
                  referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                  referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                  dicomdirTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane,lastDirectoryPath);
                  
                                                // selecting the local database here explicitly forces tree browser to load the first time
            if (lastDirectoryPath == null) {          // not a very robust flag for no DICOMDIR or input file, but it will do
                  browserPane.setSelectedIndex(-1);   // since the default is 0 already, deselection first is necessary to force explicit change event
                  browserPane.setSelectedIndex(browserPane.indexOfComponent(databaseControlsPanel));  
            }

            // Add action listeners for various buttons now that all the various display components are available for them to remember ..
//System.err.println("Building action listeners ...");
            DicomFileOrDirectoryLoadActionListener dicomFileOrDirectoryLoadActionListener = 
                  new DicomFileOrDirectoryLoadActionListener(this,multiPanel,
                        referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                        referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                        dicomdirTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane,lastDirectoryPath);

            dicomdirFileButton.addActionListener(dicomFileOrDirectoryLoadActionListener);
            displayFileButton.addActionListener(dicomFileOrDirectoryLoadActionListener);
            spectroscopyFileButton.addActionListener(dicomFileOrDirectoryLoadActionListener);
            
            ImportCurrentlyDisplayedInstanceToDatabaseActionListener importCurrentlyDisplayedInstanceToDatabaseActionListener =
                  new ImportCurrentlyDisplayedInstanceToDatabaseActionListener(this,databaseInformationModel,savedImagesFolder);
                  
            displayImportButton.addActionListener(importCurrentlyDisplayedInstanceToDatabaseActionListener);
            spectroscopyImportButton.addActionListener(importCurrentlyDisplayedInstanceToDatabaseActionListener);

            dicomdirImportButton.addActionListener(
                  new ImportFromSelectionToDatabaseActionListener(this,databaseInformationModel,savedImagesFolder));

            dicomdirViewSelectionButton.addActionListener(
                  new DicomFileLoadFromSelectionActionListener(this,multiPanel,
                        referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                        referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                        dicomdirTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane));
                  
            databaseViewSelectionButton.addActionListener(
                  new DicomFileLoadFromSelectionActionListener(this,multiPanel,
                        referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                        referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                        dicomdirTreeScrollPane /* should this be databaseTreeScrollPane or doesn't it matter ? :( */,
                        scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane));
                  
            databaseRefreshButton.addActionListener(
                  new DatabaseRefreshActionListener(this,databaseInformationModel,multiPanel,
                        referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                        referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                        databaseTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane));

            databaseFileButton.addActionListener(
                  new DatabaseImportFromFilesActionListener(this,savedImagesFolder,databaseInformationModel,multiPanel,
                        referenceImagePanelForImages,displayListOfPossibleReferenceImagesForImages,
                        referenceImagePanelForSpectra,displayListOfPossibleReferenceImagesForSpectra,displayListOfPossibleBackgroundImagesForSpectra,
                        databaseTreeScrollPane,scrollPaneOfCurrentAttributes,attributeTreeScrollPane,attributeFrameTableScrollPane));

            querySelectButton.addActionListener(new QuerySelectActionListener(this,queryTreeScrollPane,scrollPaneOfCurrentAttributes,browserPane,tabNumberOfRemoteInBrowserPane));
            queryFilterButton.addActionListener(new QueryFilterActionListener(this,queryTreeScrollPane,scrollPaneOfCurrentAttributes,browserPane,tabNumberOfRemoteInBrowserPane));
            queryRefreshButton.addActionListener(new QueryRefreshActionListener(this,queryTreeScrollPane,scrollPaneOfCurrentAttributes));
            queryRetrieveButton.addActionListener(new QueryRetrieveActionListener(this));

            NetworkSendCurrentSelectionActionListener dicomFileOrDirectoryOrDatabaseSendActionListener = 
                  new NetworkSendCurrentSelectionActionListener(this);
            dicomdirSendButton.addActionListener(dicomFileOrDirectoryOrDatabaseSendActionListener);
            displaySendButton.addActionListener(dicomFileOrDirectoryOrDatabaseSendActionListener);
            spectroscopySendButton.addActionListener(dicomFileOrDirectoryOrDatabaseSendActionListener);
            databaseSendButton.addActionListener(dicomFileOrDirectoryOrDatabaseSendActionListener);

            SaveCurrentlyDisplayedImageToXMLActionListener saveCurrentlyDisplayedImageToXMLActionListener = 
                  new SaveCurrentlyDisplayedImageToXMLActionListener(this);
            displayXMLButton.addActionListener(saveCurrentlyDisplayedImageToXMLActionListener);
            spectroscopyXMLButton.addActionListener(saveCurrentlyDisplayedImageToXMLActionListener);
            
//System.err.println("Building ValidateCurrentlyDisplayedImageActionListener ...");
            ValidateCurrentlyDisplayedImageActionListener validateCurrentlyDisplayedImageActionListener = 
                  new ValidateCurrentlyDisplayedImageActionListener(this);
            displayValidateButton.addActionListener(validateCurrentlyDisplayedImageActionListener);
            spectroscopyValidateButton.addActionListener(validateCurrentlyDisplayedImageActionListener);

            // Layout the rest of the GUI components ...
            
            JSplitPane browserAndMultiPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,browserPane,multiPanel);
            browserAndMultiPane.setOneTouchExpandable(true);
            browserAndMultiPane.setBorder(emptyBorder);

            JSplitPane browserAndMultiPaneAndCurrentAttributes = new JSplitPane(JSplitPane.VERTICAL_SPLIT,browserAndMultiPane,scrollPaneOfCurrentAttributes);
            browserAndMultiPaneAndCurrentAttributes.setOneTouchExpandable(true);
            browserAndMultiPaneAndCurrentAttributes.setResizeWeight(browserAndMultiPaneAndCurrentAttributesResizeWeight);
            
            //content.add(browserAndMultiPaneAndCurrentAttributes);

            Box mainPanel = new Box(BoxLayout.Y_AXIS);
            mainPanel.add(browserAndMultiPaneAndCurrentAttributes);
            // make label really wide, else doesn't completely repaint on status update
            mainPanel.add(statusBar);
            content.add(mainPanel);

            Dimension multiPanelDimension = defaultMultiPanelDimension;
            multiPanel.setSize(multiPanelDimension);
            multiPanel.setPreferredSize(multiPanelDimension);
            browserPane.setPreferredSize(new Dimension(widthWantedForBrowser,(int)multiPanel.getPreferredSize().getHeight()));
            {
                  Dimension d = getTableOfCurrentAttributesForCurrentFrameBrowser().getPreferredSize();
                  int w = (int)d.getWidth();
                  int h = (int)d.getHeight();
                  int wWanted = widthWantedForBrowser + (int)multiPanel.getPreferredSize().getWidth();
                  if (w > wWanted) w = wWanted;
                  if (h < heightWantedForAttributeTable) h=heightWantedForAttributeTable;
                  scrollPaneOfCurrentAttributes.setPreferredSize(new Dimension(w,h));
            }
            
            // See "http://java.sun.com/docs/books/tutorial/extra/fullscreen/example-1dot4/DisplayModeTest.java"
            
            boolean allowFullScreen = false;
            {
                  String fullScreen=properties.getProperty(propertyName_FullScreen);
                  if (fullScreen != null && fullScreen.equals("true")) {
                        allowFullScreen=true;
                  }
            }
            GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
            boolean isFullScreen = allowFullScreen && devices.length == 1 && devices[0].isFullScreenSupported();
            setUndecorated(isFullScreen);
            setResizable(!isFullScreen);
            if (isFullScreen) {
//System.err.println("Full screen ...");
                  devices[0].setFullScreenWindow(this);
                  validate();
            }
            else {
                  // Windowed mode
                  pack();
                  setVisible(true);
            }
      }


Generated by  Doxygen 1.6.0   Back to index