<commit_before>/*
 * <p>Title: SpecimenArrayApplet.java</p>
 * <p>Description:	This class initializes the fields of SpecimenArrayApplet.java</p>
 * Copyright: Copyright (c) year 2006
 * Company: Washington University, School of Medicine, St. Louis.
 * @version 1.1
 * Created on Sep 18, 2006
 */
/**
 * 
 */
package edu.wustl.catissuecore.applet.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableModel;

import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.applet.AppletServerCommunicator;
import edu.wustl.catissuecore.applet.component.SpecimenArrayTable;
import edu.wustl.catissuecore.applet.listener.ApplyButtonActionHandler;
import edu.wustl.catissuecore.applet.listener.ArrayCopyOptionActionHandler;
import edu.wustl.catissuecore.applet.model.AppletModelInterface;
import edu.wustl.catissuecore.applet.model.BaseAppletModel;
import edu.wustl.catissuecore.applet.model.SpecimenArrayTableModel;

/**
 * <p>This class specifies the methods used to render specimen array applet.It is extending
 * BaseApplet class.
 * </p>
 * @author <NAME>
 * @version 1.1
 */

public class SpecimenArrayApplet extends BaseApplet {
	/**
	 * Default Serial Version ID
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Specify the quantityTextField field 
	 */
	private JTextField quantityTextField = null;
	
	/**
	 * Specify the concentrationTextField field 
	 */
	private JTextField concentrationTextField = null;
	
	/**
	 * Specify the applyButton field 
	 */
	private JButton applyButton = null;
	
	private SpecimenArrayTable arrayTable = null;
	
	/**
	 * Specify the session_id field 
	 */
	String session_id = null;
	
	/**
	 * @see edu.wustl.catissuecore.appletui.applet.BaseApplet#doInit()
	 */
	protected void doInit() 
	{
		super.doInit();
		session_id = getParameter("session_id");
		String enterSpecimenBy = "Label";
		int rowCount = new Integer(getParameter("rowCount")).intValue();
		int columnCount = new Integer(getParameter("columnCount")).intValue();
		String specimenClass = getParameter("specimenClass");
		Map tableModelMap = getTableModelData();

		JLabel concLabel = new JLabel("Concentration");
		concLabel.setOpaque(false);
		JLabel quantityLabel = new JLabel("Quantity");
		quantityLabel.setOpaque(false);
		concentrationTextField = new JTextField();
		concentrationTextField.setName("concentrationTextField");
		concentrationTextField.setEnabled(false);
		Dimension concDimension = new Dimension(100,concentrationTextField.getPreferredSize().height);
		concentrationTextField.setPreferredSize(concDimension);
		JPanel concPanel = new JPanel();
		concPanel.setOpaque(false);
		concPanel.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		concPanel.add(concLabel);
		concPanel.add(concentrationTextField);
		
		quantityTextField = new JTextField();
		quantityTextField.setName("quantityTextField");
		quantityTextField.setEnabled(false);
		Dimension quantityDimension = new Dimension(100,quantityTextField.getPreferredSize().height);
		quantityTextField.setPreferredSize(quantityDimension);
		//System.out.println(quantityTextField.getPreferredSize());
		JPanel quantityPanel = new JPanel();
		quantityPanel.setOpaque(false);
		quantityPanel.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		quantityPanel.add(quantityLabel);
		quantityPanel.add(quantityTextField);
		
		applyButton = new JButton("Apply");
		applyButton.setEnabled(false);
		
		JPanel applyPanel = new JPanel();
		applyPanel.setBackground(Color.WHITE);
		//applyPanel.setOpaque(false);
		applyPanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
		applyPanel.add(concPanel);
		applyPanel.add(quantityPanel);
		applyPanel.add(applyButton);
		
		TableModel tableModel = new SpecimenArrayTableModel(tableModelMap,rowCount,columnCount,enterSpecimenBy,specimenClass);
		arrayTable = new SpecimenArrayTable(tableModel);
		arrayTable.setOpaque(false);
		arrayTable.getColumnModel().setColumnSelectionAllowed(true);
		arrayTable.setCellSelectionEnabled(true);
		arrayTable.setRowSelectionAllowed(true);
		arrayTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane scrollPane = new JScrollPane(arrayTable);
        scrollPane.setPreferredSize(new Dimension(100,100));
        scrollPane.setOpaque(false);
        //scrollPane.setBackground(Color.WHITE);
        scrollPane.getViewport().setBackground(Color.WHITE);
        
        applyButton.addActionListener(new ApplyButtonActionHandler(arrayTable));
        JPopupMenu popupMenu = new JPopupMenu();
        ArrayCopyOptionActionHandler actionHandler = new ArrayCopyOptionActionHandler(arrayTable);
        
        JMenuItem labelMenuItem = new JMenuItem("Label/Barcode");
        labelMenuItem.addActionListener(actionHandler);
        JMenuItem concMenuItem = new JMenuItem("Concentration");
        concMenuItem.addActionListener(actionHandler);
        JMenuItem quantityMenuItem = new JMenuItem("Quantity");
        quantityMenuItem.addActionListener(actionHandler);
        JMenuItem allMenuItem = new JMenuItem("All");
        allMenuItem.addActionListener(actionHandler);
        
        popupMenu.add(labelMenuItem);
        popupMenu.add(concMenuItem);
        popupMenu.add(quantityMenuItem);
        popupMenu.add(allMenuItem);
      
        JButton copyButton = new JButton("Copy");
        //copyButton.addActionListener(new SpecimenArrayCopyActionHandler(popupMenu));
        //applyPanel.add(copyButton);
        //System.out.println(" decrease gap :: 10");
        this.getContentPane().setLayout(new VerticalLayout(0,10));
        this.getContentPane().add(applyPanel);
        this.getContentPane().add(scrollPane);
        this.getContentPane().setBackground(Color.WHITE);
	}
	
	/**
	 * Gets table model data
	 * @return table data map 
	 */<commit_msg>color updated as per jdk1.3<commit_after>/*
 * <p>Title: SpecimenArrayApplet.java</p>
 * <p>Description:	This class initializes the fields of SpecimenArrayApplet.java</p>
 * Copyright: Copyright (c) year 2006
 * Company: Washington University, School of Medicine, St. Louis.
 * @version 1.1
 * Created on Sep 18, 2006
 */
/**
 * 
 */
package edu.wustl.catissuecore.applet.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableModel;

import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.applet.AppletServerCommunicator;
import edu.wustl.catissuecore.applet.component.SpecimenArrayTable;
import edu.wustl.catissuecore.applet.listener.ApplyButtonActionHandler;
import edu.wustl.catissuecore.applet.listener.ArrayCopyOptionActionHandler;
import edu.wustl.catissuecore.applet.model.AppletModelInterface;
import edu.wustl.catissuecore.applet.model.BaseAppletModel;
import edu.wustl.catissuecore.applet.model.SpecimenArrayTableModel;

/**
 * <p>This class specifies the methods used to render specimen array applet.It is extending
 * BaseApplet class.
 * </p>
 * @author <NAME>
 * @version 1.1
 */

public class SpecimenArrayApplet extends BaseApplet {
	/**
	 * Default Serial Version ID
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Specify the quantityTextField field 
	 */
	private JTextField quantityTextField = null;
	
	/**
	 * Specify the concentrationTextField field 
	 */
	private JTextField concentrationTextField = null;
	
	/**
	 * Specify the applyButton field 
	 */
	private JButton applyButton = null;
	
	private SpecimenArrayTable arrayTable = null;
	
	/**
	 * Specify the session_id field 
	 */
	String session_id = null;
	
	/**
	 * @see edu.wustl.catissuecore.appletui.applet.BaseApplet#doInit()
	 */
	protected void doInit() 
	{
		super.doInit();
		session_id = getParameter("session_id");
		String enterSpecimenBy = "Label";
		int rowCount = new Integer(getParameter("rowCount")).intValue();
		int columnCount = new Integer(getParameter("columnCount")).intValue();
		String specimenClass = getParameter("specimenClass");
		Map tableModelMap = getTableModelData();

		JLabel concLabel = new JLabel("Concentration");
		concLabel.setOpaque(false);
		JLabel quantityLabel = new JLabel("Quantity");
		quantityLabel.setOpaque(false);
		concentrationTextField = new JTextField();
		concentrationTextField.setName("concentrationTextField");
		concentrationTextField.setEnabled(false);
		Dimension concDimension = new Dimension(100,concentrationTextField.getPreferredSize().height);
		concentrationTextField.setPreferredSize(concDimension);
		JPanel concPanel = new JPanel();
		concPanel.setOpaque(false);
		concPanel.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		concPanel.add(concLabel);
		concPanel.add(concentrationTextField);
		
		quantityTextField = new JTextField();
		quantityTextField.setName("quantityTextField");
		quantityTextField.setEnabled(false);
		Dimension quantityDimension = new Dimension(100,quantityTextField.getPreferredSize().height);
		quantityTextField.setPreferredSize(quantityDimension);
		//System.out.println(quantityTextField.getPreferredSize());
		JPanel quantityPanel = new JPanel();
		quantityPanel.setOpaque(false);
		quantityPanel.setLayout(new FlowLayout(FlowLayout.LEFT,5,0));
		quantityPanel.add(quantityLabel);
		quantityPanel.add(quantityTextField);
		
		applyButton = new JButton("Apply");
		applyButton.setEnabled(false);
		
		JPanel applyPanel = new JPanel();
		applyPanel.setBackground(Color.white);
		//applyPanel.setOpaque(false);
		applyPanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
		applyPanel.add(concPanel);
		applyPanel.add(quantityPanel);
		applyPanel.add(applyButton);
		
		TableModel tableModel = new SpecimenArrayTableModel(tableModelMap,rowCount,columnCount,enterSpecimenBy,specimenClass);
		arrayTable = new SpecimenArrayTable(tableModel);
		arrayTable.setOpaque(false);
		arrayTable.getColumnModel().setColumnSelectionAllowed(true);
		arrayTable.setCellSelectionEnabled(true);
		arrayTable.setRowSelectionAllowed(true);
		arrayTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane scrollPane = new JScrollPane(arrayTable);
        scrollPane.setPreferredSize(new Dimension(100,100));
        scrollPane.setOpaque(false);
        //scrollPane.setBackground(Color.WHITE);
        scrollPane.getViewport().setBackground(Color.white);
        
        applyButton.addActionListener(new ApplyButtonActionHandler(arrayTable));
        JPopupMenu popupMenu = new JPopupMenu();
        ArrayCopyOptionActionHandler actionHandler = new ArrayCopyOptionActionHandler(arrayTable);
        
        JMenuItem labelMenuItem = new JMenuItem("Label/Barcode");
        labelMenuItem.addActionListener(actionHandler);
        JMenuItem concMenuItem = new JMenuItem("Concentration");
        concMenuItem.addActionListener(actionHandler);
        JMenuItem quantityMenuItem = new JMenuItem("Quantity");
        quantityMenuItem.addActionListener(actionHandler);
        JMenuItem allMenuItem = new JMenuItem("All");
        allMenuItem.addActionListener(actionHandler);
        
        popupMenu.add(labelMenuItem);
        popupMenu.add(concMenuItem);
        popupMenu.add(quantityMenuItem);
        popupMenu.add(allMenuItem);
      
        JButton copyButton = new JButton("Copy");
        //copyButton.addActionListener(new SpecimenArrayCopyActionHandler(popupMenu));
        //applyPanel.add(copyButton);
        //System.out.println(" decrease gap :: 10");
        this.getContentPane().setLayout(new VerticalLayout(0,10));
        this.getContentPane().add(applyPanel);
        this.getContentPane().add(scrollPane);
        this.getContentPane().setBackground(Color.white);
	}
	
	/**
	 * Gets table model data
	 * @return table data map 
	 */
{'fraction_non_alphanumeric': 0.10716586151368761, 'fraction_numerical': 0.00644122383252818, 'mean_word_length': 4.943062200956938, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3835955', 'n_tokens_mistral': 3872, 'n_tokens_neox': 3559, 'n_words': 638}