Back to index

wims  3.65+svn20090927
Public Member Functions | Package Functions | Package Attributes | Static Package Attributes
WIMSchem.DialogEdit Class Reference
Inheritance diagram for WIMSchem.DialogEdit:
Inheritance graph
[legend]
Collaboration diagram for WIMSchem.DialogEdit:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DialogEdit (Frame Parent, Molecule Mol, ArrayList< Integer > SelIdx)
Molecule exec ()
void actionPerformed (ActionEvent e)

Package Functions

Object[][] CompileAtomData ()
Object[][] CompileBondData ()
boolean ReadData ()

Package Attributes

Molecule mol
Molecule retMol = null
ArrayList< Integer > aselidx
ArrayList< Integer > bselidx
JTabbedPane tabs
JButton accept
JButton reject
JTable atoms
JTable bonds

Static Package Attributes

static final String BOND_TYPES [] = {"Normal","Inclined","Declined","Unknown"}

Detailed Description

Definition at line 25 of file DialogEdit.java.


Constructor & Destructor Documentation

WIMSchem.DialogEdit.DialogEdit ( Frame  Parent,
Molecule  Mol,
ArrayList< Integer >  SelIdx 
) [inline]

Definition at line 36 of file DialogEdit.java.

    {
       super(Parent,"Edit Molecule",true);
       mol=Mol.Clone();
       aselidx=SelIdx;
       bselidx=new ArrayList<Integer>();
       for (int n=1;n<=mol.NumBonds();n++) if (aselidx.indexOf(mol.BondFrom(n))>=0 && aselidx.indexOf(mol.BondTo(n))>=0) bselidx.add(n);
       
       setLayout(new BorderLayout());
       
       atoms=new JTable(CompileAtomData(),new String[]{"#","El","X","Y","Charge","Unpaired","HExplicit","MapNum"})
           {public boolean isCellEditable(int row,int column) {return column>0;}};
       bonds=new JTable(CompileBondData(),new String[]{"#","From","To","Order","Type"})
           {public boolean isCellEditable(int row,int column) {return column>2;}};

       atoms.getColumnModel().getColumn(0).setCellEditor(null);
       JComboBox bondTypes=new JComboBox();
       for (int n=0;n<BOND_TYPES.length;n++) bondTypes.addItem(BOND_TYPES[n]);
       bonds.getColumnModel().getColumn(4).setCellEditor(new DefaultCellEditor(bondTypes));

       JPanel tabAtoms=new JPanel(),tabBonds=new JPanel();
       tabAtoms.setLayout(new BorderLayout());
       tabBonds.setLayout(new BorderLayout());

       atoms.setPreferredScrollableViewportSize(new Dimension(350,200));
       bonds.setPreferredScrollableViewportSize(new Dimension(350,200));

       tabAtoms.add(new JScrollPane(atoms));
       tabBonds.add(new JScrollPane(bonds));

       tabs=new JTabbedPane();
       tabs.addTab("Atoms",tabAtoms);
       tabs.addTab("Bonds",tabBonds);
       add(tabs,BorderLayout.CENTER);
       
       JPanel buttons=new JPanel();
       buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
       accept=new JButton("Accept"); accept.addActionListener(this); accept.setMnemonic(KeyEvent.VK_A);
       reject=new JButton("Reject"); reject.addActionListener(this); reject.setMnemonic(KeyEvent.VK_R);
       buttons.add(accept);
       buttons.add(reject);
       add(buttons,BorderLayout.SOUTH);
       
       pack();
    }

Here is the call graph for this function:


Member Function Documentation

void WIMSchem.DialogEdit.actionPerformed ( ActionEvent  e) [inline]

Definition at line 88 of file DialogEdit.java.

    {
       if (e.getSource()==accept) 
       {
           if (!ReadData()) return;
           retMol=mol; 
           setVisible(false);
       }
       if (e.getSource()==reject) setVisible(false);
    }

Here is the call graph for this function:

Object [][] WIMSchem.DialogEdit.CompileAtomData ( ) [inline, package]

Definition at line 99 of file DialogEdit.java.

    {
       Object[][] data=new Object[aselidx.size()][];
       
       DecimalFormat fmt=new DecimalFormat("0.0000");

       for (int n=0;n<aselidx.size();n++)
       {
           int i=aselidx.get(n).intValue();
           Object[] da=new Object[8];
           da[0]=new Integer(i);
           da[1]=new String(mol.AtomElement(i));
           da[2]=fmt.format(mol.AtomX(i));
           da[3]=fmt.format(mol.AtomY(i));
           da[4]=String.valueOf(mol.AtomCharge(i));
           da[5]=String.valueOf(mol.AtomUnpaired(i));
           da[6]=mol.AtomHExplicit(i)==Molecule.HEXPLICIT_UNKNOWN ? "?" : String.valueOf(mol.AtomHExplicit(i));
           da[7]=String.valueOf(mol.AtomMapNum(i));
           data[n]=da;
       }
       
       return data;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Object [][] WIMSchem.DialogEdit.CompileBondData ( ) [inline, package]

Definition at line 123 of file DialogEdit.java.

    {
       Object[][] data=new Object[bselidx.size()][];
       
       for (int n=0;n<bselidx.size();n++)
       {
           int i=bselidx.get(n).intValue();
           Object[] db=new Object[5];
           db[0]=new Integer(i);
           db[1]=new Integer(mol.BondFrom(i));
           db[2]=new Integer(mol.BondTo(i));
           db[3]=String.valueOf(mol.BondOrder(i));
           db[4]=new String(BOND_TYPES[mol.BondType(i)]);
           data[n]=db;
       }
       
       return data;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file DialogEdit.java.

    {
       setVisible(true);
       return retMol;
    }
boolean WIMSchem.DialogEdit.ReadData ( ) [inline, package]

Definition at line 142 of file DialogEdit.java.

    {
       for (int n=0;n<atoms.getRowCount();n++)
       {
           int i=(Integer)atoms.getValueAt(n,0);
           mol.SetAtomElement(i,(String)atoms.getValueAt(n,1));
           mol.SetAtomPos(i,Utils.safeDouble((String)atoms.getValueAt(n,2)),Utils.safeDouble((String)atoms.getValueAt(n,3)));
           
           mol.SetAtomCharge(i,Utils.safeInt((String)atoms.getValueAt(n,4)));
           mol.SetAtomUnpaired(i,Utils.safeInt((String)atoms.getValueAt(n,5)));
           String hyStr=(String)atoms.getValueAt(n,6);
           int hy=Utils.safeInt(hyStr);
           mol.SetAtomHExplicit(i,hyStr.compareTo("0")==0 ? 0 : hy>0 ? hy : Molecule.HEXPLICIT_UNKNOWN);
           mol.SetAtomMapNum(i,Utils.safeInt((String)atoms.getValueAt(n,7)));
       }
       for (int n=0;n<bonds.getRowCount();n++)
       {
           int i=(Integer)bonds.getValueAt(n,0);
           mol.SetBondOrder(i,new Integer((String)bonds.getValueAt(n,3)).intValue());
           int type;
           for (int j=BOND_TYPES.length-1;j>=0;j--) if (BOND_TYPES[j].compareTo((String)bonds.getValueAt(n,4))==0) 
              {mol.SetBondType(i,j); break;}
       }
       return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

JButton WIMSchem.DialogEdit.accept [package]

Definition at line 31 of file DialogEdit.java.

ArrayList<Integer> WIMSchem.DialogEdit.aselidx [package]

Definition at line 28 of file DialogEdit.java.

JTable WIMSchem.DialogEdit.atoms [package]

Definition at line 32 of file DialogEdit.java.

final String WIMSchem.DialogEdit.BOND_TYPES[] = {"Normal","Inclined","Declined","Unknown"} [static, package]

Definition at line 34 of file DialogEdit.java.

JTable WIMSchem.DialogEdit.bonds [package]

Definition at line 32 of file DialogEdit.java.

ArrayList<Integer> WIMSchem.DialogEdit.bselidx [package]

Definition at line 28 of file DialogEdit.java.

Definition at line 27 of file DialogEdit.java.

JButton WIMSchem.DialogEdit.reject [package]

Definition at line 31 of file DialogEdit.java.

Definition at line 27 of file DialogEdit.java.

JTabbedPane WIMSchem.DialogEdit.tabs [package]

Definition at line 30 of file DialogEdit.java.


The documentation for this class was generated from the following file: