Package clips.dicom.test

Source Code of clips.dicom.test.TestFrame

/*
* TestFrame.java
*
* Created on July 19, 2008, 9:52 AM
*/

package clips.dicom.test;

import clips.dicom.model.Agregator;
import clips.dicom.model.AgregatorListener;
import clips.dicom.model.ItemEvent;
import clips.dicom.dicombaseclass.DICOMException;
import clips.dicom.model.AgregatorItem;
import clips.dicom.panels.DicomBasePanel;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractListModel;


/**
*
* @author  finder
*/
public class TestFrame extends javax.swing.JFrame implements AgregatorListener {
  DicomBasePanel      basePanel;
 
    /** Creates new form TestFrame */
    public TestFrame() {
        initComponents();
    DicomjList.setModel(new AbstractListModel() {
      public int getSize() {
        return Agregator.getItems().size();
      }

      public Object getElementAt(int index) {
        return Agregator.getItems().get(index).getName();
      }
    });
   
    //basePanel = new DicomBasePanel(MainWindow.mainWindow);
    TestPanel.add(basePanel);
    Agregator.addListener(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        DicomjList = new javax.swing.JList();
        TestPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Dicom Test Form");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        jSplitPane1.setDividerLocation(200);

        DicomjList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        DicomjList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                DicomjListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(DicomjList);

        jSplitPane1.setLeftComponent(jScrollPane1);

        TestPanel.setLayout(new javax.swing.BoxLayout(TestPanel, javax.swing.BoxLayout.LINE_AXIS));
        jSplitPane1.setRightComponent(TestPanel);

        getContentPane().add(jSplitPane1);

        setSize(new java.awt.Dimension(735, 539));
    }// </editor-fold>//GEN-END:initComponents

private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
    try {
      if (Agregator.getListenerCount() <= 1)
      Agregator.stop();//GEN-LAST:event_formWindowClosed
      Agregator.removeListener(this);
    } catch (DICOMException ex) {
      Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
    basePanel.dispose();
}

private void DicomjListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_DicomjListValueChanged
  int              id = DicomjList.getSelectedIndex();
  ArrayList<AgregatorItem>  itms = Agregator.getItems();
  if (id >= 0 && id < itms.size()) {
      basePanel.setAgregator(itms.get(id));
    }
  else {
      DicomjList.setSelectedIndex(id >= 0 ? itms.size() - 1 : 0);
    }
}//GEN-LAST:event_DicomjListValueChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TestFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList DicomjList;
    private javax.swing.JPanel TestPanel;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSplitPane jSplitPane1;
    // End of variables declaration//GEN-END:variables

  public void agregatorItemsChanged(ItemEvent e) {
    DicomjList.setModel(new AbstractListModel() {
      public int getSize() {
        return Agregator.getItems().size();
      }

      public Object getElementAt(int index) {
        return Agregator.getItems().get(index).getName();
      }
    });
  }
 
 
 
}
TOP

Related Classes of clips.dicom.test.TestFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.