rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } | fileMenu.addSeparator(); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
fileMenu.addSeparator(); | exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); | fileMenu.addSeparator(); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } | JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); | ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); | JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); | public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
String[] methodStrings = {"95% of informative pairwise comparisons show strong LD via confidence intervals (SFS)", "Four Gamete Rule", "Solid block of strong LD via D prime (MJD)"}; JComboBox methodList = new JComboBox(methodStrings); JOptionPane.showMessageDialog(this, methodList, "Select a block-finding algorithm", JOptionPane.QUESTION_MESSAGE); theData.blocks = theData.guessBlocks(theData.dPrimeTable, methodList.getSelectedIndex()); hapDisplay.getHaps(); if (tabs.getSelectedIndex() == 0) dPrimeDisplay.repaint(); | String[] methodStrings = {"95% of informative pairwise comparisons show strong LD via confidence intervals (SFS)", "Four Gamete Rule", "Solid block of strong LD via D prime (MJD)"}; JComboBox methodList = new JComboBox(methodStrings); JOptionPane.showMessageDialog(this, methodList, "Select a block-finding algorithm", JOptionPane.QUESTION_MESSAGE); theData.blocks = theData.guessBlocks(theData.dPrimeTable, methodList.getSelectedIndex()); hapDisplay.getHaps(); dPrimeDisplay.alreadyPainted = false; if (tabs.getSelectedIndex() == 0) dPrimeDisplay.repaint(); | void defineBlocks(){ String[] methodStrings = {"95% of informative pairwise comparisons show strong LD via confidence intervals (SFS)", "Four Gamete Rule", "Solid block of strong LD via D prime (MJD)"}; JComboBox methodList = new JComboBox(methodStrings); JOptionPane.showMessageDialog(this, methodList, "Select a block-finding algorithm", JOptionPane.QUESTION_MESSAGE); theData.blocks = theData.guessBlocks(theData.dPrimeTable, methodList.getSelectedIndex()); hapDisplay.getHaps(); if (tabs.getSelectedIndex() == 0) dPrimeDisplay.repaint(); } |
} catch (Exception e) { } HaploView window = new HaploView(); window.setTitle("HaploView beta"); window.setSize(800,600); | } catch (Exception e) { } | public static void main(String[] args) {//throws IOException{ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //setup view object HaploView window = new HaploView(); window.setTitle("HaploView beta"); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } |
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); | HaploView window = new HaploView(); window.setTitle("HaploView beta"); window.setSize(800,600); | public static void main(String[] args) {//throws IOException{ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //setup view object HaploView window = new HaploView(); window.setTitle("HaploView beta"); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } |
window.setVisible(true); ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); | Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); | public static void main(String[] args) {//throws IOException{ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //setup view object HaploView window = new HaploView(); window.setTitle("HaploView beta"); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } |
try { int good = theData.prepareMarkerInput(inputFile); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } | try { int good = theData.prepareMarkerInput(inputFile); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; dPrimeDisplay.loadMarkers(theData.markerInfo); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } | void readMarkers(File inputFile){ try { int good = theData.prepareMarkerInput(inputFile); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } |
try{ theData = new HaploData(new File(filenames[0])); progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } drawPicture(theData); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); } } }); worker.start(); timer.start(); | try{ theData = new HaploData(new File(filenames[0])); | void readPhasedGenotypes(String[] f){ //input is a 2 element array with //filenames[0] = haps file //filenames[1] = info file (null if none) filenames = f; try{ theData = new HaploData(new File(filenames[0])); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } drawPicture(theData); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } |
}catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } | progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } drawPicture(theData); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } | void readPhasedGenotypes(String[] f){ //input is a 2 element array with //filenames[0] = haps file //filenames[1] = info file (null if none) filenames = f; try{ theData = new HaploData(new File(filenames[0])); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } drawPicture(theData); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } |
hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); minDisplayField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e){ setDisplayThresh(Integer.parseInt(minDisplayField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); | hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); | public HaplotypeDisplayController(HaplotypeDisplay parent){ this.parent = parent; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel hapPercentPanel = new JPanel(); hapPercentPanel.add(new JLabel("Examine haplotypes above ")); hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); minDisplayField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e){ setDisplayThresh(Integer.parseInt(minDisplayField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); hapPercentPanel.add(new JLabel("%")); add(hapPercentPanel); JPanel thinPanel = new JPanel(); thinPanel.add(new JLabel("Connect with thin lines if > ")); thinPanel.add(minThinField = new NumberTextField(String.valueOf(parent.thinThresh), 3)); minThinField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThinThresh(Integer.parseInt(minThinField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thinPanel.add(new JLabel("%")); add(thinPanel); JPanel thickPanel = new JPanel(); thickPanel.add(new JLabel("Connect with thick lines if > ")); thickPanel.add(minThickField = new NumberTextField(String.valueOf(parent.thickThresh), 3)); minThickField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThickThresh(Integer.parseInt(minThickField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thickPanel.add(new JLabel("%")); add(thickPanel); fieldSize = minDisplayField.getPreferredSize(); } |
minThinField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThinThresh(Integer.parseInt(minThinField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); | public HaplotypeDisplayController(HaplotypeDisplay parent){ this.parent = parent; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel hapPercentPanel = new JPanel(); hapPercentPanel.add(new JLabel("Examine haplotypes above ")); hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); minDisplayField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e){ setDisplayThresh(Integer.parseInt(minDisplayField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); hapPercentPanel.add(new JLabel("%")); add(hapPercentPanel); JPanel thinPanel = new JPanel(); thinPanel.add(new JLabel("Connect with thin lines if > ")); thinPanel.add(minThinField = new NumberTextField(String.valueOf(parent.thinThresh), 3)); minThinField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThinThresh(Integer.parseInt(minThinField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thinPanel.add(new JLabel("%")); add(thinPanel); JPanel thickPanel = new JPanel(); thickPanel.add(new JLabel("Connect with thick lines if > ")); thickPanel.add(minThickField = new NumberTextField(String.valueOf(parent.thickThresh), 3)); minThickField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThickThresh(Integer.parseInt(minThickField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thickPanel.add(new JLabel("%")); add(thickPanel); fieldSize = minDisplayField.getPreferredSize(); } |
|
minThickField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThickThresh(Integer.parseInt(minThickField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); | public HaplotypeDisplayController(HaplotypeDisplay parent){ this.parent = parent; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel hapPercentPanel = new JPanel(); hapPercentPanel.add(new JLabel("Examine haplotypes above ")); hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); minDisplayField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e){ setDisplayThresh(Integer.parseInt(minDisplayField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); hapPercentPanel.add(new JLabel("%")); add(hapPercentPanel); JPanel thinPanel = new JPanel(); thinPanel.add(new JLabel("Connect with thin lines if > ")); thinPanel.add(minThinField = new NumberTextField(String.valueOf(parent.thinThresh), 3)); minThinField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThinThresh(Integer.parseInt(minThinField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thinPanel.add(new JLabel("%")); add(thinPanel); JPanel thickPanel = new JPanel(); thickPanel.add(new JLabel("Connect with thick lines if > ")); thickPanel.add(minThickField = new NumberTextField(String.valueOf(parent.thickThresh), 3)); minThickField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThickThresh(Integer.parseInt(minThickField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thickPanel.add(new JLabel("%")); add(thickPanel); fieldSize = minDisplayField.getPreferredSize(); } |
|
goButton = new JButton("Go"); goButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { setDisplayThresh(Integer.parseInt(minDisplayField.getText())); setThinThresh(Integer.parseInt(minThinField.getText())); setThickThresh(Integer.parseInt(minThickField.getText())); } }); add(goButton); | public HaplotypeDisplayController(HaplotypeDisplay parent){ this.parent = parent; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel hapPercentPanel = new JPanel(); hapPercentPanel.add(new JLabel("Examine haplotypes above ")); hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3)); minDisplayField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e){ setDisplayThresh(Integer.parseInt(minDisplayField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); hapPercentPanel.add(new JLabel("%")); add(hapPercentPanel); JPanel thinPanel = new JPanel(); thinPanel.add(new JLabel("Connect with thin lines if > ")); thinPanel.add(minThinField = new NumberTextField(String.valueOf(parent.thinThresh), 3)); minThinField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThinThresh(Integer.parseInt(minThinField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thinPanel.add(new JLabel("%")); add(thinPanel); JPanel thickPanel = new JPanel(); thickPanel.add(new JLabel("Connect with thick lines if > ")); thickPanel.add(minThickField = new NumberTextField(String.valueOf(parent.thickThresh), 3)); minThickField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setThickThresh(Integer.parseInt(minThickField.getText())); } public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { } }); thickPanel.add(new JLabel("%")); add(thickPanel); fieldSize = minDisplayField.getPreferredSize(); } |
|
return null; | return super.createExpression(factory, tagName, attributeName, attributeValue); | public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("select")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(xpath); } catch (JaxenException e) { throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e ); } } // will use the default expression instead return null; } |
public XPathExpression(XPath xpath) { this.xpath = xpath; | public XPathExpression() { | public XPathExpression(XPath xpath) { this.xpath = xpath; } |
public JellyException(String message, Throwable cause) { super(message); this.cause = cause; | public JellyException() { | public JellyException(String message, Throwable cause) { super(message); this.cause = cause; } |
paintThumbnail( g2, photo, col*columnWidth, row*rowHeight, selection.contains( photo ) ); | if ( photo != null ) { paintThumbnail( g2, photo, col*columnWidth, row*rowHeight, selection.contains( photo ) ); } | public void paint( Graphics g ) { super.paint( g ); Graphics2D g2 = (Graphics2D) g; Rectangle clipRect = g.getClipBounds(); Dimension compSize = getSize(); // columnCount = (int)(compSize.getWidth()/columnWidth); int photoCount = 0; if ( photoCollection != null ) { photoCount = photoCollection.getPhotoCount(); } // Determine the grid size based on couln & row count columnsToPaint = columnCount; // if columnCount is not specified determine it based on row count if ( columnCount < 0 ) { if ( rowCount > 0 ) { columnsToPaint = photoCount / rowCount; if ( columnsToPaint * rowCount < photoCount ) { columnsToPaint++; } } else { columnsToPaint = (int) ( compSize.getWidth()/columnWidth ); } } int col = 0; int row = 0; Rectangle thumbRect = new Rectangle(); for ( int i = 0; i < photoCount; i++ ) { thumbRect.setBounds(col*columnWidth, row*rowHeight, columnWidth, rowHeight ); if ( thumbRect.intersects( clipRect ) ) { PhotoInfo photo = photoCollection.getPhoto( i ); paintThumbnail( g2, photo, col*columnWidth, row*rowHeight, selection.contains( photo ) ); } col++; if ( col >= columnsToPaint ) { row++; col = 0; } } // Paint the selection rectangle if needed if ( dragSelectionRect != null ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 1.0f) ); g2.setColor( Color.BLACK ); g2.draw( dragSelectionRect ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); lastDragSelectionRect = dragSelectionRect; } } |
if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); | Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); log.debug( "starting to draw" ); BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } thumbDrawnTime = System.currentTimeMillis(); ypos += ((int)img.getHeight())/2 + 4; Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } else { g2.setBackground( this.getBackground() ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); | private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); long startTime = System.currentTimeMillis(); long thumbReadyTime = 0; long thumbDrawnTime = 0; long endTime = 0; // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; // Create a transaction which will be used for persisten object operations // during painting (to avoid creating several short-livin transactions) ODMGXAWrapper txw = new ODMGXAWrapper(); if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } thumbDrawnTime = System.currentTimeMillis(); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } else { g2.setBackground( this.getBackground() ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } txw.commit(); endTime = System.currentTimeMillis(); log.debug( "paintThumbnail: exit " + photo.getUid() ); log.debug( "Thumb fetch " + (thumbReadyTime - startTime ) + " ms" ); log.debug( "Thumb draw " + ( thumbDrawnTime - thumbReadyTime ) + " ms" ); log.debug( "Deacoration draw " + (endTime - thumbDrawnTime ) + " ms" ); log.debug( "Total " + (endTime - startTime ) + " ms" ); } |
log.debug( "starting to draw" ); BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } | String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); | private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); long startTime = System.currentTimeMillis(); long thumbReadyTime = 0; long thumbDrawnTime = 0; long endTime = 0; // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; // Create a transaction which will be used for persisten object operations // during painting (to avoid creating several short-livin transactions) ODMGXAWrapper txw = new ODMGXAWrapper(); if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } thumbDrawnTime = System.currentTimeMillis(); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } else { g2.setBackground( this.getBackground() ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } txw.commit(); endTime = System.currentTimeMillis(); log.debug( "paintThumbnail: exit " + photo.getUid() ); log.debug( "Thumb fetch " + (thumbReadyTime - startTime ) + " ms" ); log.debug( "Thumb draw " + ( thumbDrawnTime - thumbReadyTime ) + " ms" ); log.debug( "Deacoration draw " + (endTime - thumbDrawnTime ) + " ms" ); log.debug( "Total " + (endTime - startTime ) + " ms" ); } |
thumbDrawnTime = System.currentTimeMillis(); ypos += ((int)img.getHeight())/2 + 4; Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } else { g2.setBackground( this.getBackground() ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } | g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); | private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); long startTime = System.currentTimeMillis(); long thumbReadyTime = 0; long thumbDrawnTime = 0; long endTime = 0; // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; // Create a transaction which will be used for persisten object operations // during painting (to avoid creating several short-livin transactions) ODMGXAWrapper txw = new ODMGXAWrapper(); if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } thumbDrawnTime = System.currentTimeMillis(); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } else { g2.setBackground( this.getBackground() ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } txw.commit(); endTime = System.currentTimeMillis(); log.debug( "paintThumbnail: exit " + photo.getUid() ); log.debug( "Thumb fetch " + (thumbReadyTime - startTime ) + " ms" ); log.debug( "Thumb draw " + ( thumbDrawnTime - thumbReadyTime ) + " ms" ); log.debug( "Deacoration draw " + (endTime - thumbDrawnTime ) + " ms" ); log.debug( "Total " + (endTime - startTime ) + " ms" ); } |
this.date = date; | this.date = (date != null) ? (Date) date.clone() : null; | public FuzzyDate( Date date, double accuracy ) { this.date = date; this.accuracy = accuracy; } |
public Script parse(InputStream input) throws IOException, SAXException { ensureConfigured(); this.fileName = null; getXMLReader().parse(new InputSource(input)); return script; | public Script parse(File file) throws IOException, SAXException { return parse(file.toURL()); | public Script parse(InputStream input) throws IOException, SAXException { ensureConfigured(); this.fileName = null; getXMLReader().parse(new InputSource(input)); return script; } |
public void run(Context context, XMLOutput output) throws Exception; | public void run(JellyContext context, XMLOutput output) throws Exception; | public void run(Context context, XMLOutput output) throws Exception; |
public Filter<S> and(Filter<S> filter) { if (filter instanceof OpenFilter) { return this; } if (filter instanceof ClosedFilter) { return filter; } return AndFilter.getCanonical(this, filter); | public final Filter<S> and(String expression) { return and(new FilterParser<S>(mType, expression).parseRoot()); | public Filter<S> and(Filter<S> filter) { if (filter instanceof OpenFilter) { return this; } if (filter instanceof ClosedFilter) { return filter; } return AndFilter.getCanonical(this, filter); } |
public abstract void appendTo(Appendable app, FilterValues<S> values) throws IOException; | public void appendTo(Appendable app) throws IOException { appendTo(app, null); } | public abstract void appendTo(Appendable app, FilterValues<S> values) throws IOException; |
public Filter<S> or(Filter<S> filter) { if (filter instanceof OpenFilter) { return filter; } if (filter instanceof ClosedFilter) { return this; } return OrFilter.getCanonical(this, filter); | public final Filter<S> or(String expression) { return or(new FilterParser<S>(mType, expression).parseRoot()); | public Filter<S> or(Filter<S> filter) { if (filter instanceof OpenFilter) { return filter; } if (filter instanceof ClosedFilter) { return this; } return OrFilter.getCanonical(this, filter); } |
user.setStatus(null); | user.setStatus(User.STATUS_ACTIVE); | public void login(ServiceContext context, String username, String password) throws ServiceException{ LoginCallbackHandler callbackHandler = new LoginCallbackHandler(username, password); User user = null; UserManager userManager = UserManager.getInstance(); UserActivityLogger logger = UserActivityLogger.getInstance(); try{ final LoginContext loginContext = new LoginContext(AuthConstants.AUTH_CONFIG_INDEX, callbackHandler); loginContext.login(); /* Need this for external login modules, user is really authenticated after this step */ Set principals = loginContext.getSubject().getPrincipals(); Object obj = null; for(Iterator principalIt = principals.iterator(); principalIt.hasNext();){ if((obj = principalIt.next()) instanceof User){ user = (User)obj; break; } } /* Successful login: - Add new users authenticated through external LoginModules. - Update the lock count and status of existing users */ if(user == null){ user = new User(); user.setUsername(username); user.setExternalUser(true); List roles = new ArrayList(); roles.add(new Role(org.jmanage.core.auth.ExternalUserRolesConfig.getInstance().getUserRole(username))); user.setRoles(roles); }else{ user = userManager.getUser(user.getName()); user.setLockCount(0); user.setStatus(null); userManager.updateUser(user); } /* set Subject in session */ context._setUser(user); logger.logActivity(user.getName(), "logged in successfully"); }catch(LoginException lex){ user = userManager.getUser(username); String errorCode = ErrorCodes.UNKNOWN_ERROR; Object[] values = null; /* Conditionalize the error message */ if(user == null){ errorCode = ErrorCodes.INVALID_CREDENTIALS; }else if(User.STATUS_LOCKED.equals(user.getStatus())){ errorCode = ErrorCodes.ACCOUNT_LOCKED; }else if(user.getLockCount() < MAX_LOGIN_ATTEMPTS_ALLOWED){ int thisAttempt = user.getLockCount()+1; user.setLockCount(thisAttempt); if(thisAttempt == MAX_LOGIN_ATTEMPTS_ALLOWED){ user.setStatus(User.STATUS_LOCKED); userManager.updateUser(user); errorCode = ErrorCodes.ACCOUNT_LOCKED; }else{ userManager.updateUser(user); errorCode = ErrorCodes.INVALID_LOGIN_ATTEMPTS; values = new Object[]{ String.valueOf(MAX_LOGIN_ATTEMPTS_ALLOWED - thisAttempt)}; } } if(user != null) logger.logActivity(username, user.getName()+" failed to login"); throw new ServiceException(errorCode, values); } } |
public User getUser(String username){ return users.containsKey(username) ? (User)users.get(username) : null; | public User getUser(String username, char[] password){ User user = (User)users.get(username); if(user != null){ final String hashedPassword = Crypto.hash(password); user = hashedPassword.equals(user.getPassword()) && "A".equals(user.getStatus()) ? user : null; } return user; | public User getUser(String username){ return users.containsKey(username) ? (User)users.get(username) : null; } |
public JellyContext newJellyContext() { return createChildContext(); | public JellyContext newJellyContext(Map newVariables) { newVariables.put("parentScope", variables); JellyContext answer = createChildContext(); answer.setVariables(newVariables); return answer; | public JellyContext newJellyContext() { return createChildContext(); } |
public DataTypeTag(String name, DataType dataType) { this.name = name; this.dataType = dataType; setDynaBean( new ConvertingWrapDynaBean(dataType) ); | public DataTypeTag() { | public DataTypeTag(String name, DataType dataType) { this.name = name; this.dataType = dataType; setDynaBean( new ConvertingWrapDynaBean(dataType) ); } |
public TaskPropertyTag(String name) { setName(name); | public TaskPropertyTag() { | public TaskPropertyTag(String name) { setName(name); } |
*/ | public Expression createExpression(ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { ExpressionFactory myFactory = getExpressionFactory(); if ( myFactory == null ) { myFactory = factory; } if ( myFactory != null ) { if (attributeName.equals( "value" ) || attributeName.equals( "items" ) || attributeName.equals( "test" ) ) { return myFactory.createExpression( attributeValue ); } } // will use the default expression instead return null; } |
|
dataType = ih.createElement( getAntProject(), object, name ); | dataType = ih.createElement( getAntProject(), object, name.toLowerCase() ); | public Object createNestedObject(Object object, String name) throws Exception { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null ) { try { dataType = ih.createElement( getAntProject(), object, name ); } catch (Exception e) { log.error(e); } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; } |
public BeanTag(Class defaultClass, String tagName) { this(defaultClass, tagName, null); | public BeanTag() { this(null, "bean", null); | public BeanTag(Class defaultClass, String tagName) { this(defaultClass, tagName, null); } |
public JellyTagException(String message, Throwable cause) { super(message,cause); | public JellyTagException() { | public JellyTagException(String message, Throwable cause) { super(message,cause); } |
if (t == null ) throw new NullPointerException(); | private void sqlScriptGenerator(Map<DiffType, AttributeSet> styles, List<DiffChunk<SQLObject>> diff, DDLGenerator gen) throws ArchitectDiffException, SQLException, ArchitectException, BadLocationException, InstantiationException, IllegalAccessException { for (DiffChunk<SQLObject> chunk : diff) { if (chunk.getType() == DiffType.KEY_CHANGED) { if(chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); if (hasKey(t)) { gen.addPrimaryKey(t); } else { gen.dropPrimaryKey(t); } } }else if (chunk.getType() == DiffType.LEFTONLY) { if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); gen.dropTable(t); }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.dropColumn(c); } else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.dropRelationship(r); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.RIGHTONLY){ if (chunk.getData() instanceof SQLTable) { SQLTable t = (SQLTable) chunk.getData(); if(t.getObjectType().equals("TABLE")) { gen.writeTable(t); } if (hasKey(t)) { gen.addPrimaryKey(t); } }else if (chunk.getData() instanceof SQLColumn){ SQLColumn c = (SQLColumn) chunk.getData(); gen.addColumn(c); }else if (chunk.getData() instanceof SQLRelationship){ SQLRelationship r = (SQLRelationship)chunk.getData(); gen.addRelationship(r); }else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else if (chunk.getType() == DiffType.MODIFIED) { if (chunk.getData() instanceof SQLColumn) { SQLColumn c = (SQLColumn) chunk.getData(); gen.modifyColumn(c); } else { throw new IllegalStateException("DiffChunk is an unexpected type."); } } else { } } } |
|
dbcsPanel.setDbcs(new ArchitectDataSource()); | public DBCS_OkAction(DBCSPanel dbcsPanel, boolean isNew) { super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; dbcsPanel.setDbcs(new ArchitectDataSource()); } |
|
JButton okButton = new JButton(okAction); | JButton okButton = new JDefaultButton(okAction); | public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; } |
JButton cancelButton = new JButton(cancelAction); | JButton cancelButton = new JDefaultButton(cancelAction); | public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; } |
public static void showExceptionDialog(Component parent, String message, Throwable throwable) { try { ExceptionReport er = new ExceptionReport(throwable); er.setNumObjectsInPlayPen(ArchitectFrame.getMainInstance().playpen.getTablePanes().size() + ArchitectFrame.getMainInstance().playpen.getRelationships().size()); er.setNumSourceConnections(ArchitectFrame.getMainInstance().dbTree.getDatabaseList().size()); er.setUserActivityDescription(""); logger.debug(er.toString()); er.postReport(); } catch (Throwable seriousProblem) { logger.error("Couldn't generate and send exception report! Note that this is not the primary problem; it's a side effect of trying to report the real problem.", seriousProblem); JOptionPane.showMessageDialog(null, "Error reporting failed: "+seriousProblem.getMessage()+"\nAdditional information is available in the application log."); } finally { displayExceptionDialog(parent,message,throwable); } | public static void showExceptionDialog(String message, Throwable throwable) { showExceptionDialog(ArchitectFrame.getMainInstance(), message, throwable); | public static void showExceptionDialog(Component parent, String message, Throwable throwable) { try { ExceptionReport er = new ExceptionReport(throwable); er.setNumObjectsInPlayPen(ArchitectFrame.getMainInstance().playpen.getTablePanes().size() + ArchitectFrame.getMainInstance().playpen.getRelationships().size()); er.setNumSourceConnections(ArchitectFrame.getMainInstance().dbTree.getDatabaseList().size()); er.setUserActivityDescription(""); logger.debug(er.toString()); er.postReport(); } catch (Throwable seriousProblem) { logger.error("Couldn't generate and send exception report! Note that this is not the primary problem; it's a side effect of trying to report the real problem.", seriousProblem); JOptionPane.showMessageDialog(null, "Error reporting failed: "+seriousProblem.getMessage()+"\nAdditional information is available in the application log."); } finally { displayExceptionDialog(parent,message,throwable); } } |
while (comparator.compare(sourceTable, targetTable) < 0) { | if (comparator.compare(sourceTable, targetTable) < 0) { | public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; } |
break; | public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; } |
|
while (comparator.compare(sourceTable, targetTable) > 0) { | if (comparator.compare(sourceTable, targetTable) > 0) { | public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; } |
while (comparator.compare(sourceTable, targetTable) == 0) { | if (comparator.compare(sourceTable, targetTable) == 0) { | public List<DiffChunk<SQLObject>> generateTableDiffs() throws ArchitectException { try { Iterator sourceIter = sourceTableSet.iterator(); Iterator targetIter = targetTableSet.iterator(); SQLTable targetTable; SQLTable sourceTable; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; sourceTable = null; } if (targetIter.hasNext()) { targetContinue = true; targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; targetTable = null; } // Will loop until one or both the list reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceTable, targetTable) < 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceTable, targetTable) > 0) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); // now do the columns results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceTable, targetTable) == 0) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.SAME)); // now do the columns results.addAll(generateColumnDiffs(sourceTable, targetTable)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { results.add(new DiffChunk<SQLObject>(sourceTable, DiffType.LEFTONLY)); results.addAll(generateColumnDiffs(sourceTable, null)); if (sourceIter.hasNext()) { sourceTable = (SQLTable) sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { results.add(new DiffChunk<SQLObject>(targetTable, DiffType.RIGHTONLY)); results.addAll(generateColumnDiffs(null, targetTable)); if (targetIter.hasNext()) { targetTable = (SQLTable) targetIter.next(); } else { targetContinue = false; } } results.addAll(generateRelationshipDiffs(sourceTableSet, targetTableSet)); } finally { setFinished(true); } return results; } |
g.setColor(new Color(51,153,51)); | g.setColor(Color.black); | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } } |
g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); | g.drawLine(left + (2*theBlock[j]) * boxSize/2, top + boxRadius, left + (2*theBlock[j]) * boxSize/2 + boxRadius, top); g.drawLine (left + (2*theBlock[j]) * boxSize/2, top + boxRadius, left + (2*theBlock[j]-1) * boxSize/2, top-1); | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } } |
public JellyContext runScript(URL url, XMLOutput output) throws Exception { Script script = compileScript(url); URL newJellyContextURL = getJellyContextURL(url); JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); if (log.isDebugEnabled() ) { log.debug( "About to run script: " + url ); log.debug( "root context URL: " + newJellyContext.rootURL ); log.debug( "current context URL: " + newJellyContext.currentURL ); } script.run(newJellyContext, output); return newJellyContext; | public JellyContext runScript(File file, XMLOutput output) throws Exception { return runScript(file.toURL(), output); | public JellyContext runScript(URL url, XMLOutput output) throws Exception { Script script = compileScript(url); URL newJellyContextURL = getJellyContextURL(url); JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); if (log.isDebugEnabled() ) { log.debug( "About to run script: " + url ); log.debug( "root context URL: " + newJellyContext.rootURL ); log.debug( "current context URL: " + newJellyContext.currentURL ); } script.run(newJellyContext, output); return newJellyContext; } |
Iterator kitr = fullProbMap.theMap.keySet().iterator(); | ArrayList keys = new ArrayList(fullProbMap.theMap.keySet()); Collections.sort(keys); Iterator kitr = keys.iterator(); | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; MapWrap probMap = new MapWrap(PSEUDOCOUNT); /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; } } probMap.normalize(total); // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p = (float)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(tempRec.h2))); total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob probMap = new MapWrap(1e-10); total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); } } probMap.normalize(total); iter++; } int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; if (probMap.get(new Long(j)) > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; hprob[block][m]=probMap.get(new Long(j)); hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ fullProbMap = new MapWrap(PSEUDOCOUNT); create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ total = poss_full * PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; } } fullProbMap.normalize(total); /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(superdata[i].superposs[k].h2))); total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); } } fullProbMap.normalize(total); iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); Iterator kitr = fullProbMap.theMap.keySet().iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
public UseBeanTag(Class defaultClass) { this.defaultClass = defaultClass; | public UseBeanTag() { | public UseBeanTag(Class defaultClass) { this.defaultClass = defaultClass; } |
if ( enum.hasMoreTokens() ) { | if ( items.hasMoreTokens() ) { | public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } if ( enum.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); } |
} | } return new Point( x, y ); } | public Point parse(String text) { StringTokenizer items = new StringTokenizer( text, "," ); int x = 0; int y = 0; if ( items.hasMoreTokens() ) { x = parseNumber( items.nextToken() ); } if ( enum.hasMoreTokens() ) { y = parseNumber( items.nextToken() ); } |
public String evaluateAsString(Context context); | public String evaluateAsString(JellyContext context); | public String evaluateAsString(Context context); |
org.apache.log4j.BasicConfigurator.configure(); | public static void main( String[] args ) { org.apache.log4j.BasicConfigurator.configure(); log.setLevel( org.apache.log4j.Level.DEBUG ); org.apache.log4j.Logger folderLog = org.apache.log4j.Logger.getLogger( PhotoFolder.class.getName() ); folderLog.setLevel( org.apache.log4j.Level.DEBUG ); junit.textui.TestRunner.run( suite() ); } |
|
tx = odmg.newTransaction(); tx.begin(); | public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; } tx = odmg.newTransaction(); tx.begin(); } |
|
Transaction tx = odmg.newTransaction(); log.debug( "Changing folder name for " + folder.getFolderId() ); tx.begin(); folder.setName( "testTop" ); tx.commit(); log.debug( "Folder name changed" ); | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
|
Transaction tx = odmg.newTransaction(); tx.begin(); | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
|
tx.abort(); | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
|
boolean found = false; | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
|
if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } | log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder name does not match", folder2.getName(), "testTop" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
tx.commit(); | public void testCreate() { PhotoFolder folder = PhotoFolder.create( "Top", null ); // Try to find the object from DB DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = " + folder.getFolderId() ); folders = (DList) query.execute(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder2 = (PhotoFolder) iter.next(); if ( folder2.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder2.getFolderId() ); assertEquals( "Folder not found in DB", folder2.getName(), "Top" ); log.debug( "Modifying desc" ); folder2.setDescription( "Test description" ); tx.lock( folder2, Transaction.WRITE ); } } tx.commit(); } |
|
Transaction tx = odmg.newTransaction(); tx.begin(); | public void testSubfolders() { DList folders = null; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"subfolderTest\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } PhotoFolder topFolder = (PhotoFolder) folders.get( 0 ); assertEquals( "Top folder name invalid", "subfolderTest",topFolder.getName() ); assertEquals( "topFolder should have 4 subfolders", 4, topFolder.getSubfolderCount() ); String[] subfolderNames = {"Subfolder1", "Subfolder2", "Subfolder3", "Subfolder4"}; // Check that all subfolder are found for ( int n = 0; n < topFolder.getSubfolderCount(); n++ ) { PhotoFolder subfolder = topFolder.getSubfolder( n ); assertEquals( "Subfolder name incorrect", subfolderNames[n], subfolder.getName() ); } // Check subfolder addition PhotoFolder newFolder = PhotoFolder.create( "Subfolder5", topFolder ); assertEquals( "New subfolder added", 5, topFolder.getSubfolderCount() ); newFolder.delete(); assertEquals( "Subfolder deleted", 4, topFolder.getSubfolderCount() ); } |
|
registerWidgetTag( "scrolledComposite", ScrolledComposite.class, SWT.H_SCROLL | SWT.V_SCROLL); | public SwtTagLibrary() { // widgets registerWidgetTag( "button", Button.class, SWT.BORDER | SWT.PUSH | SWT.CENTER ); registerWidgetTag( "canvas", Canvas.class ); registerWidgetTag( "caret", Caret.class ); registerWidgetTag( "combo", Combo.class, SWT.DROP_DOWN ); registerWidgetTag( "composite", Composite.class ); registerWidgetTag( "coolBar", CoolBar.class, SWT.VERTICAL ); registerWidgetTag( "coolItem", CoolItem.class ); registerWidgetTag( "decorations", Decorations.class ); registerWidgetTag( "group", Group.class ); registerWidgetTag( "label", Label.class, SWT.HORIZONTAL | SWT.SHADOW_IN ); registerWidgetTag( "list", List.class ); registerMenuTag( "menu", SWT.DEFAULT ); registerMenuTag( "menuBar", SWT.BAR ); registerWidgetTag( "menuSeparator", MenuItem.class, SWT.SEPARATOR ); registerWidgetTag( "menuItem", MenuItem.class ); registerWidgetTag( "messageBox", MessageBox.class ); registerWidgetTag( "progressBar", ProgressBar.class, SWT.HORIZONTAL ); registerWidgetTag( "sash", Sash.class ); registerWidgetTag( "scale", Scale.class ); registerWidgetTag( "shell", Shell.class, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.TITLE ); registerWidgetTag( "slider", Slider.class ); registerWidgetTag( "tabFolder", TabFolder.class ); registerWidgetTag( "tabItem", TabItem.class ); registerWidgetTag( "table", Table.class, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION ); registerWidgetTag( "tableColumn", TableColumn.class ); registerWidgetTag( "tableItem", TableItem.class ); registerWidgetTag( "text", Text.class ); registerWidgetTag( "toolBar", ToolBar.class, SWT.VERTICAL ); registerWidgetTag( "toolItem", ToolItem.class ); registerWidgetTag( "tracker", Tracker.class ); registerWidgetTag( "tree", Tree.class, SWT.MULTI ); registerWidgetTag( "treeItem", TreeItem.class ); // custom widgets registerWidgetTag( "tableTree", TableTree.class ); registerWidgetTag( "tableTreeItem", TableTreeItem.class ); // layouts registerLayoutTag("fillLayout", FillLayout.class); registerLayoutTag("gridLayout", GridLayout.class); registerLayoutTag("rowLayout", RowLayout.class); // layout data objects registerLayoutDataTag( "gridData", GridData.class ); registerLayoutDataTag( "rowData", RowData.class ); // dialogs //registerWidgetTag( "colorDialog", ColorDialog.class ); //registerWidgetTag( "directoryDialog", DirectoryDialog.class ); //registerWidgetTag( "fileDialog", FileDialog.class ); //registerWidgetTag( "fontDialog", FontDialog.class ); // events registerTag("onEvent", OnEventTag.class); // other tags registerTag("image", ImageTag.class); } |
|
public WidgetTag(Class widgetClass, int style) { super(widgetClass); this.style = style; } | public WidgetTag(Class widgetClass) { super(widgetClass); } | public WidgetTag(Class widgetClass, int style) { super(widgetClass); this.style = style; } |
request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Edit Application"); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception{ AccessController.canAccess(context.getUser(), ACL_EDIT_APPLICATIONS); ApplicationConfig config = context.getApplicationConfig(); ApplicationForm appForm = (ApplicationForm)actionForm; ModuleConfig moduleConfig = ModuleRegistry.getModule(config.getType()); MetaApplicationConfig metaAppConfig = moduleConfig.getMetaApplicationConfig(); /* populate the form */ appForm.setApplicationId(config.getApplicationId()); appForm.setName(config.getName()); appForm.setType(config.getType()); if(metaAppConfig.isDisplayHost()) appForm.setHost(config.getHost()); if(metaAppConfig.isDisplayPort()) appForm.setPort(String.valueOf(config.getPort())); if(metaAppConfig.isDisplayURL()) appForm.setURL(config.getURL()); if(metaAppConfig.isDisplayUsername()) appForm.setUsername(config.getUsername()); if(metaAppConfig.isDisplayPassword() && config.getPassword() != null && config.getPassword().length()>0) appForm.setPassword(ApplicationForm.FORM_PASSWORD); request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig); return mapping.findForward(Forwards.SUCCESS); } |
|
public void registerBean(String name, Class type, Method method) { registerBean(name, type); if (method != null) { invokeMethods.put(name, method); } else { invokeMethods.remove(name); } | public void registerBean(String name, Class type) { beanTypes.put(name, type); | public void registerBean(String name, Class type, Method method) { registerBean(name, type); if (method != null) { invokeMethods.put(name, method); } else { invokeMethods.remove(name); } } |
tab.setColumnsPopulated(false); tab.setRelationshipsPopulated(false); tab.initFolders(); | tab.initFolders(false); | public Object createObject(Attributes attributes) { SQLTable tab = new SQLTable(); String id = attributes.getValue("id"); if (id != null) { objectIdMap.put(id, tab); } else { logger.warn("No ID found in table element while loading project!"); } String populated = attributes.getValue("populated"); if (populated != null && populated.equals("false")) { tab.setColumnsPopulated(false); tab.setRelationshipsPopulated(false); tab.initFolders(); } return tab; } |
propNames.put("type", new Integer(((SQLTable.Folder) o).getType())); | protected void saveSQLObject(SQLObject o) throws IOException, ArchitectException { String id = (String) objectIdMap.get(o); if (id != null) { println("<reference ref-id=\""+id+"\" />"); return; } String type; Map propNames = new TreeMap(); if (o instanceof SQLDatabase) { id = "DB"+objectIdMap.size(); type = "database"; propNames.put("dbcs-ref", dbcsIdMap.get(((SQLDatabase) o).getConnectionSpec())); } else if (o instanceof SQLCatalog) { id = "CAT"+objectIdMap.size(); type = "catalog"; propNames.put("catalogName", ((SQLCatalog) o).getCatalogName()); } else if (o instanceof SQLSchema) { id = "SCH"+objectIdMap.size(); type = "schema"; propNames.put("schemaName", ((SQLSchema) o).getSchemaName()); } else if (o instanceof SQLTable) { id = "TAB"+objectIdMap.size(); type = "table"; propNames.put("tableName", ((SQLTable) o).getTableName()); propNames.put("remarks", ((SQLTable) o).getRemarks()); propNames.put("objectType", ((SQLTable) o).getObjectType()); propNames.put("primaryKeyName", ((SQLTable) o).getPrimaryKeyName()); pm.setProgress(++progress); pm.setNote(o.getShortDisplayName()); } else if (o instanceof SQLTable.Folder) { id = "FOL"+objectIdMap.size(); type = "folder"; propNames.put("name", ((SQLTable.Folder) o).getName()); } else if (o instanceof SQLColumn) { id = "COL"+objectIdMap.size(); type = "column"; SQLColumn sourceCol = ((SQLColumn) o).getSourceColumn(); if (sourceCol != null) { propNames.put("source-column-ref", objectIdMap.get(sourceCol)); } propNames.put("columnName", ((SQLColumn) o).getColumnName()); propNames.put("type", new Integer(((SQLColumn) o).getType())); propNames.put("sourceDBTypeName", ((SQLColumn) o).getSourceDBTypeName()); propNames.put("scale", new Integer(((SQLColumn) o).getScale())); propNames.put("precision", new Integer(((SQLColumn) o).getPrecision())); propNames.put("nullable", new Integer(((SQLColumn) o).getNullable())); propNames.put("remarks", ((SQLColumn) o).getRemarks()); propNames.put("defaultValue", ((SQLColumn) o).getDefaultValue()); propNames.put("primaryKeySeq", ((SQLColumn) o).getPrimaryKeySeq()); propNames.put("autoIncrement", new Boolean(((SQLColumn) o).isAutoIncrement())); } else if (o instanceof SQLRelationship) { id = "REL"+objectIdMap.size(); type = "relationship"; propNames.put("pk-table-ref", objectIdMap.get(((SQLRelationship) o).getPkTable())); propNames.put("fk-table-ref", objectIdMap.get(((SQLRelationship) o).getFkTable())); propNames.put("updateRule", new Integer(((SQLRelationship) o).getUpdateRule())); propNames.put("deleteRule", new Integer(((SQLRelationship) o).getDeleteRule())); propNames.put("deferrability", new Integer(((SQLRelationship) o).getDeferrability())); propNames.put("pkCardinality", new Integer(((SQLRelationship) o).getPkCardinality())); propNames.put("fkCardinality", new Integer(((SQLRelationship) o).getFkCardinality())); propNames.put("identifying", new Boolean(((SQLRelationship) o).isIdentifying())); propNames.put("name", ((SQLRelationship) o).getName()); } else if (o instanceof SQLRelationship.ColumnMapping) { id = "CMP"+objectIdMap.size(); type = "column-mapping"; propNames.put("pk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getPkColumn())); propNames.put("fk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getFkColumn())); } else { throw new UnsupportedOperationException("Woops, the SQLObject type " +o.getClass().getName()+" is not supported!"); } objectIdMap.put(o, id); //print("<"+type+" hashCode=\""+o.hashCode()+"\" id=\""+id+"\" "); print("<"+type+" id=\""+id+"\" "); if ( (!savingEntireSource) && (!o.isPopulated()) ) { niprint("populated=\"false\" "); } Iterator props = propNames.keySet().iterator(); while (props.hasNext()) { Object key = props.next(); Object value = propNames.get(key); if (value != null) { niprint(key+"=\""+value+"\" "); } } if (o.allowsChildren() && (savingEntireSource || o.isPopulated()) ) { niprintln(">"); Iterator children = o.getChildren().iterator(); indent++; while (children.hasNext()) { SQLObject child = (SQLObject) children.next(); if ( ! (child instanceof SQLRelationship)) { saveSQLObject(child); } } if (o instanceof SQLDatabase) { saveRelationships((SQLDatabase) o); } indent--; println("</"+type+">"); } else { niprintln("/>"); } } |
|
d.addObjectCreate("*/folder", SQLTable.Folder.class); | SQLFolderFactory folderFactory = new SQLFolderFactory(); d.addFactoryCreate("*/folder", folderFactory); | protected Digester setupDigester() { Digester d = new Digester(); d.setValidating(false); d.push(this); // project name d.addCallMethod("architect-project/project-name", "setName", 0); // argument is element body text // source DB connection specs DBCSFactory dbcsFactory = new DBCSFactory(); d.addFactoryCreate("architect-project/project-connection-specs/dbcs", dbcsFactory); d.addSetProperties ("architect-project/project-connection-specs/dbcs", new String[] {"connection-name", "driver-class", "jdbc-url", "user-name", "user-pass", "sequence-number", "single-login"}, new String[] {"displayName", "driverClass", "url", "user", "pass", "seqNo", "singleLogin"}); d.addCallMethod("architect-project/project-connection-specs/dbcs", "setName", 0); // these instances get picked out of the dbcsIdMap by the SQLDatabase factory // source database hierarchy d.addObjectCreate("architect-project/source-databases", LinkedList.class); d.addSetNext("architect-project/source-databases", "setSourceDatabaseList"); SQLDatabaseFactory dbFactory = new SQLDatabaseFactory(); d.addFactoryCreate("architect-project/source-databases/database", dbFactory); d.addSetProperties("architect-project/source-databases/database"); d.addSetNext("architect-project/source-databases/database", "add"); d.addObjectCreate("architect-project/source-databases/database/catalog", SQLCatalog.class); d.addSetProperties("architect-project/source-databases/database/catalog"); d.addSetNext("architect-project/source-databases/database/catalog", "addChild"); d.addObjectCreate("*/schema", SQLSchema.class); d.addSetProperties("*/schema"); d.addSetNext("*/schema", "addChild"); SQLTableFactory tableFactory = new SQLTableFactory(); d.addFactoryCreate("*/table", tableFactory); d.addSetProperties("*/table"); d.addSetNext("*/table", "addChild"); d.addObjectCreate("*/folder", SQLTable.Folder.class); d.addSetProperties("*/folder"); d.addSetNext("*/folder", "addChild"); SQLColumnFactory columnFactory = new SQLColumnFactory(); d.addFactoryCreate("*/column", columnFactory); d.addSetProperties("*/column"); d.addSetNext("*/column", "addChild"); SQLRelationshipFactory relationshipFactory = new SQLRelationshipFactory(); d.addFactoryCreate("*/relationship", relationshipFactory); d.addSetProperties("*/relationship"); // the factory adds the relationships to the correct PK and FK tables ColumnMappingFactory columnMappingFactory = new ColumnMappingFactory(); d.addFactoryCreate("*/column-mapping", columnMappingFactory); d.addSetProperties("*/column-mapping"); d.addSetNext("*/column-mapping", "addChild"); // target database hierarchy d.addFactoryCreate("architect-project/target-database", dbFactory); d.addSetProperties("architect-project/target-database"); d.addSetNext("architect-project/target-database", "setTargetDatabase"); // the play pen TablePaneFactory tablePaneFactory = new TablePaneFactory(); d.addFactoryCreate("architect-project/play-pen/table-pane", tablePaneFactory); // factory will add the tablepanes to the playpen PPRelationshipFactory ppRelationshipFactory = new PPRelationshipFactory(); d.addFactoryCreate("architect-project/play-pen/table-link", ppRelationshipFactory); DDLGeneratorFactory ddlgFactory = new DDLGeneratorFactory(); d.addFactoryCreate("architect-project/ddl-generator", ddlgFactory); d.addSetProperties("architect-project/ddl-generator"); FileFactory fileFactory = new FileFactory(); d.addFactoryCreate("*/file", fileFactory); d.addSetNext("*/file", "setFile"); d.addSetNext("architect-project/ddl-generator", "setDDLGenerator"); return d; } |
public Relationship(PlayPen parentPP, SQLRelationship model) throws ArchitectException { super(parentPP.getPlayPenContentPane()); this.model = model; setPkTable(getPlayPen().findTablePane(model.getPkTable())); setFkTable(getPlayPen().findTablePane(model.getFkTable())); setup(); | public Relationship(Relationship r, PlayPenContentPane contentPane, TablePane pkTable, TablePane fkTable) { super(contentPane); this.model = r.model; this.pkTable = r.pkTable; this.fkTable = r.fkTable; this.popup =r.popup; this.selected = false; this.ppcListener = new PlayPenComponentListener(); this.columnHighlightColour = r.columnHighlightColour; this.selectionListeners = new ArrayList<SelectionListener>(); try { RelationshipUI ui = (RelationshipUI) r.getUI().getClass().newInstance(); ui.installUI(this); setUI(ui); } catch (InstantiationException e) { throw new RuntimeException("Woops, couldn't invoke no-args constructor of "+r.getUI().getClass().getName()); } catch (IllegalAccessException e) { throw new RuntimeException("Woops, couldn't access no-args constructor of "+r.getUI().getClass().getName()); } | public Relationship(PlayPen parentPP, SQLRelationship model) throws ArchitectException { super(parentPP.getPlayPenContentPane()); this.model = model; setPkTable(getPlayPen().findTablePane(model.getPkTable())); setFkTable(getPlayPen().findTablePane(model.getFkTable())); setup(); } |
public SQLTable() { children = new ArrayList(); | public SQLTable(SQLObject parent, String name, String remarks, String objectType) { logger.debug("NEW TABLE "+name+"@"+hashCode()); this.parent = parent; this.tableName = name; this.remarks = remarks; this.objectType = objectType; this.children = new ArrayList(); initFolders(false); importedKeysFolder.addSQLObjectListener(this); | public SQLTable() { //columnsPopulated = true; //relationshipsPopulated = true; children = new ArrayList(); } |
public PlayPen(SQLDatabase db) { this(); setDatabase(db); | public PlayPen() { zoom = 1.0; setBackground(java.awt.Color.white); contentPane = new PlayPenContentPane(this); setLayout(null); setName("Play Pen"); setMinimumSize(new Dimension(1,1)); dt = new DropTarget(this, new PlayPenDropListener()); bringToFrontAction = new BringToFrontAction(this); sendToBackAction = new SendToBackAction(this); setupTablePanePopup(); setupPlayPenPopup(); setupKeyboardActions(); ppMouseListener = new PPMouseListener(); addMouseListener(ppMouseListener); addMouseMotionListener(ppMouseListener); dgl = new TablePaneDragGestureListener(); ds = new DragSource(); ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, dgl); logger.debug("DragGestureRecognizer motion threshold: " + getToolkit().getDesktopProperty("DnD.gestureMotionThreshold")); | public PlayPen(SQLDatabase db) { this(); setDatabase(db); } |
public DBTree(List initialDatabases) throws ArchitectException { this(); setDatabaseList(initialDatabases); | public DBTree() { setRootVisible(false); setShowsRootHandles(true); ds = new DragSource(); DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer (this, DnDConstants.ACTION_COPY, new DBTreeDragGestureListener()); newDBCSAction = new NewDBCSAction(); setupPropDialog(); popup = setupPopupMenu(); addMouseListener(new PopupListener()); setCellRenderer(new SQLObjectRenderer()); | public DBTree(List initialDatabases) throws ArchitectException { this(); setDatabaseList(initialDatabases); } |
public DBTreeModel(Collection initialDatabases) throws ArchitectException { this.root = new DBTreeRoot(); if (initialDatabases != null) { Iterator it = initialDatabases.iterator(); while (it.hasNext()) { root.addChild((SQLDatabase) it.next()); } } this.treeModelListeners = new LinkedList(); ArchitectUtils.listenToHierarchy(this, root); | public DBTreeModel() throws ArchitectException { this(null); | public DBTreeModel(Collection initialDatabases) throws ArchitectException { this.root = new DBTreeRoot(); if (initialDatabases != null) { Iterator it = initialDatabases.iterator(); while (it.hasNext()) { root.addChild((SQLDatabase) it.next()); } } this.treeModelListeners = new LinkedList(); ArchitectUtils.listenToHierarchy(this, root); } |
public XMLOutput( ContentHandler contentHandler, LexicalHandler lexicalHandler) { this.contentHandler = contentHandler; this.lexicalHandler = lexicalHandler; | public XMLOutput() { | public XMLOutput( ContentHandler contentHandler, LexicalHandler lexicalHandler) { this.contentHandler = contentHandler; this.lexicalHandler = lexicalHandler; } |
namespaceStack.popNamespace(prefix); | public void endPrefixMapping(String prefix) throws SAXException { namespaceStack.popNamespace(prefix); // End prefix mapping was already called after endElement // contentHandler.endPrefixMapping(prefix); } |
|
public void setContext(JellyContext context); | public void setContext(JellyContext context) throws Exception; | public void setContext(JellyContext context); |
public Object evaluate(Context context); | public Object evaluate(JellyContext context); | public Object evaluate(Context context); |
public StartupException(String message, Throwable cause) { super(message, cause); | public StartupException() { super(); | public StartupException(String message, Throwable cause) { super(message, cause); } |
public SamplingException(String message, Throwable cause) { super(message, cause); | public SamplingException() { super(); | public SamplingException(String message, Throwable cause) { super(message, cause); } |
this.defaultEncountered = false; this.someCaseMatched = false; this.fallingThru = false; | public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if(null == on) { throw new MissingAttributeException("on"); } else { value = on.evaluate(context); invokeBody(output); } } |
|
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ | public CheckDataPanel(HaploData hd) throws IOException, PedFileException{ STATUS_COL = 8; | public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); } |
pedfile = pf; | pedfile = hd.getPedFile(); theData = hd; | public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); } |
tableColumnNames.add("Name"); | if (theData.infoKnown){ tableColumnNames.add("Name"); tableColumnNames.add("Position"); STATUS_COL += 2; } | public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); } |
tempVect.add(currentResult.getName()); | if (theData.infoKnown){ tempVect.add(Chromosome.getMarker(i).getName()); tempVect.add(new Long(Chromosome.getMarker(i).getPosition())); } | public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); } |
table.getColumnModel().getColumn(1).setPreferredWidth(100); | if (theData.infoKnown){ table.getColumnModel().getColumn(1).setPreferredWidth(100); } | public CheckDataPanel(PedFile pf) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = pf; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); } |
protected void attachWidgets(Widget parent, Widget widget) { if (parent instanceof ScrolledComposite && widget instanceof Control) { ScrolledComposite scrolledComposite = (ScrolledComposite) parent; scrolledComposite.setContent((Control) widget); } } | protected void attachWidgets(Object parent, Widget widget) throws JellyTagException { if (parent instanceof ScrolledComposite && widget instanceof Control) { ScrolledComposite scrolledComposite = (ScrolledComposite) parent; scrolledComposite.setContent((Control) widget); } } | protected void attachWidgets(Widget parent, Widget widget) { // set the content that will be scrolled if the parent is a ScrolledComposite if (parent instanceof ScrolledComposite && widget instanceof Control) { ScrolledComposite scrolledComposite = (ScrolledComposite) parent; scrolledComposite.setContent((Control) widget); } } |
if (parent == null) { WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); if (tag != null) { parent = tag.getWidget(); } } return parent; } | if (parent == null) { WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); if (tag != null) { return tag.getWidget(); } } return parent; } | public Widget getParentWidget() { if (parent == null) { WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); if (tag != null) { parent = tag.getWidget(); } } return parent; } |
registerTag( "classLoader", ClassLoaderTag.class ); | public DefineTagLibrary() { registerTag( "taglib", TaglibTag.class ); registerTag( "tag", TagTag.class ); registerTag( "bean", BeanTag.class ); registerTag( "jellybean", JellyBeanTag.class ); registerTag( "attribute", AttributeTag.class ); registerTag( "invokeBody", InvokeBodyTag.class ); registerTag( "script", ScriptTag.class ); registerTag( "invoke", InvokeTag.class ); } |
|
if(!(chromosomeArg.equalsIgnoreCase("x"))){ | if(!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } } |
die("-chromosome requires a chromsome name of 1-22 or X"); | die("-chromosome requires a chromsome name of 1-22, X, or Y"); | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } } |
if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); | if (!(chromosomeArg.equalsIgnoreCase("X")) && !(chromosomeArg.equalsIgnoreCase("Y"))){ die("chromsome specification must be betweeen 1 and 22, X, or Y"); | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpdata")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpdataFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap data file listed will be used"); } phasedhmpdataFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmpsample")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmpsampleFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap sample file listed will be used"); } phasedhmpsampleFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhmplegend")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(phasedhmplegendFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last phased hapmap legend file listed will be used"); } phasedhmplegendFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-phasedhapmapdl")){ phasedhapmapDownload = true; } else if (args[i].equalsIgnoreCase("-plink")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last PLINK file listed will be used"); } plinkFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-map")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(plinkFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last map file listed will be used"); } mapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if (args[i].equalsIgnoreCase("-malehets")){ malehets = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-captureAlleles")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { captureAllelesFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-designScores")){ i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { designScoresFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-mintagdistance")){ i++; minTagDistance = args[i]; } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } if(!(chromosomeArg.equalsIgnoreCase("x"))){ try{ if (Integer.parseInt(chromosomeArg) > 22){ die("-chromosome requires a chromsome name of 1-22 or X"); } }catch(NumberFormatException nfe){ die("-chromosome requires a chromsome name of 1-22 or X"); } } } else if(args[i].equalsIgnoreCase("-population")){ i++; if(!(i>=args.length) && !(args[i].charAt(0)== '-')) { populationArg = args[i]; }else { die(args[i-1] + "requires a population name"); } } else if(args[i].equalsIgnoreCase("-startpos")){ i++; startPos = args[i]; } else if(args[i].equalsIgnoreCase("-endPos")){ i++; endPos = args[i]; } else if(args[i].equalsIgnoreCase("-phase")){ i++; phase = args[i]; } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else if(args[i].equalsIgnoreCase("-gzip")){ Options.setGzip(true); } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(phasedhmpdataFileName != null) { countOptions++; if(phasedhmpsampleFileName == null){ die("You must specify a sample file for phased hapmap input."); }else if(phasedhmplegendFileName == null){ die("You must specify a legend file for phased hapmap input."); } } if(phasedhapmapDownload) { countOptions++; } if(plinkFileName != null){ countOptions++; if(mapFileName == null){ die("You must specify a map file for plink format input."); } } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance + "kb"); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null && batchFileName == null && phasedhmpdataFileName == null && !phasedhapmapDownload) { die("A marker info file must be specified when tagging."); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } if (captureAllelesFileName != null) { File captureFile = new File(captureAllelesFileName); captureAlleleTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(captureFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ line = line.trim(); captureAlleleTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (designScoresFileName != null) { File designFile = new File(designScoresFileName); designScores = new Hashtable(1,1); try { BufferedReader br = new BufferedReader(new FileReader(designFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ StringTokenizer st = new StringTokenizer(line); String marker = st.nextToken(); Double score = new Double(st.nextToken()); designScores.put(marker,score); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -captureAlleles."); } } if (minTagDistance != null) { try{ if (Integer.parseInt(minTagDistance) < 0){ die("minimum tag distance cannot be negative"); } }catch(NumberFormatException nfe){ die("minimum tag distance must be a positive integer"); } Options.setTaggerMinDistance(Integer.parseInt(minTagDistance)); } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } if (phasedhapmapDownload){ if (chromosomeArg == null){ die("-phasedhapmapdl requires a chromosome specification"); }else if (!(populationArg.equalsIgnoreCase("CEU") || populationArg.equalsIgnoreCase("YRI") || populationArg.equalsIgnoreCase("CHB+JPT"))){ die("-phasedhapmapdl requires a population specification of CEU, YRI, or CHB+JPT"); } if (Integer.parseInt(chromosomeArg) < 1 && Integer.parseInt(chromosomeArg) > 22){ if (!(chromosomeArg.equalsIgnoreCase("x"))){ die("chromsome specification must be betweeen 1 and 22 or X"); } } try{ if (Integer.parseInt(startPos) > Integer.parseInt(endPos)){ die("end position must be greater then start position"); } }catch(NumberFormatException nfe){ die("start and end positions must be integer values"); } if (phase == null){ phase = "2"; } try{ if (Integer.parseInt(phase) != 1 && Integer.parseInt(phase) != 2){ die("phase must be either 1 or 2"); } }catch(NumberFormatException nfe){ die("phase must be an integer value"); } } } |
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); | public AssociationTestSet(){ results = new Vector(); | public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.