rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
return null; | MockJDBCResultSet rs = new MockJDBCResultSet(null, 1); rs.setColumnName(1, "TABLE_TYPE"); rs.updateObject(1, "TABLE"); rs.beforeFirst(); return rs; | public ResultSet getTableTypes() throws SQLException { // TODO Auto-generated method stub return null; } |
String catalogList = connection.getProperties().getProperty("catalogs"); String schemaList = connection.getProperties().getProperty("schemas"); String tableList = connection.getProperties().getProperty("tables"); | if (logger.isDebugEnabled()) { logger.debug("getTables: Searching for:"); logger.debug(" catalog '"+catalogNamePattern+"' (pattern "+catalogPattern+")"); logger.debug(" schema '"+schemaNamePattern+"' (pattern "+schemaPattern+")"); logger.debug(" table '"+tableNamePattern+"' (pattern "+tablePattern+")"); } List<String> catalogs = new ArrayList<String>(); if (getCatalogTerm() != null) { String catalogList = connection.getProperties().getProperty("catalogs"); for (String cat : Arrays.asList(catalogList.split(","))) { if (catalogPattern.matcher(cat).matches()) { catalogs.add(cat); logger.debug(" Adding catalog "+cat); } else { logger.debug("Skipping catalog "+cat+" (doesn't match pattern)"); } } } else { catalogs.add(NO_CATALOG); } | public ResultSet getTables(String catalogNamePattern, String schemaNamePattern, String tableNamePattern, String[] types) throws SQLException { MockJDBCResultSet rs = new MockJDBCResultSet(null, 10); rs.setColumnName(1, "TABLE_CAT"); rs.setColumnName(2, "TABLE_SCHEM"); rs.setColumnName(3, "TABLE_NAME"); rs.setColumnName(4, "TABLE_TYPE"); rs.setColumnName(5, "REMARKS"); rs.setColumnName(6, "TYPE_CAT"); rs.setColumnName(7, "TYPE_SCHEM"); rs.setColumnName(8, "TYPE_NAME"); rs.setColumnName(9, "SELF_REFERENCING_COL_NAME"); rs.setColumnName(10, "REF_GENERATION"); Pattern catalogPattern = createPatternFromSQLWildcard(catalogNamePattern); Pattern schemaPattern = createPatternFromSQLWildcard(schemaNamePattern); Pattern tablePattern = createPatternFromSQLWildcard(tableNamePattern); String catalogList = connection.getProperties().getProperty("catalogs"); String schemaList = connection.getProperties().getProperty("schemas"); String tableList = connection.getProperties().getProperty("tables"); // TODO: create the result set rows here rs.beforeFirst(); return rs; } |
Map<String,List<String>> schemas = new TreeMap<String,List<String>>(); if (getSchemaTerm() != null) { for (String cat : catalogs) { String schemaList; if (cat == NO_CATALOG) { schemaList = connection.getProperties().getProperty("schemas"); } else { schemaList = connection.getProperties().getProperty("schemas."+cat); } List<String> schemasOfCat = new ArrayList<String>(); if (schemaList != null) { for (String sch : Arrays.asList(schemaList.split(","))) { if (schemaPattern.matcher(sch).matches()) { schemasOfCat.add(sch); logger.debug(" Adding schema "+sch); } else { logger.debug("Skipping schema "+sch+" (doesn't match pattern)"); } } } if (logger.isDebugEnabled()) logger.debug("Putting schemas "+schemasOfCat+" under map key '"+cat+"'"); schemas.put(cat, schemasOfCat); } } else { } if (logger.isDebugEnabled()) { logger.debug("Found Catalogs: "+catalogs); logger.debug("Found Schemas: "+schemas); } for (String cat : catalogs) { if (cat == NO_CATALOG) { if (schemas.get(cat) == null) { String tableList = connection.getProperties().getProperty("tables"); if (tableList == null) throw new SQLException("Missing property: 'tables'"); for (String table : Arrays.asList(tableList.split(","))) { if (tablePattern.matcher(table).matches()) { rs.addRow(); rs.updateObject(3, table); rs.updateObject(4, "TABLE"); } else { logger.debug("Skipping table "+table+" (doesn't match pattern)"); } } } else { List<String> schemasOfCat = schemas.get(cat); for (String sch : schemasOfCat) { String tableList = connection.getProperties().getProperty("tables."+sch); if (tableList == null) throw new SQLException("Missing property: 'tables."+sch+"'"); for (String table : Arrays.asList(tableList.split(","))) { if (tablePattern.matcher(table).matches()) { rs.addRow(); rs.updateObject(2, sch); rs.updateObject(3, table); rs.updateObject(4, "TABLE"); } else { logger.debug("Skipping table "+table+" (doesn't match pattern)"); } } } } } else { if (getSchemaTerm() == null) { String tableList = connection.getProperties().getProperty("tables."+cat); if (tableList == null) throw new SQLException("Missing property: 'tables."+cat+"'"); for (String table : Arrays.asList(tableList.split(","))) { if (tablePattern.matcher(table).matches()) { rs.addRow(); rs.updateObject(1, cat); rs.updateObject(3, table); rs.updateObject(4, "TABLE"); } else { logger.debug("Skipping table "+table+" (doesn't match pattern)"); } } } else { if (schemas.get(cat) != null) { for (String sch : schemas.get(cat)) { String tableList = connection.getProperties().getProperty("tables."+cat+"."+sch); if (tableList == null) throw new SQLException("Missing property: 'tables."+cat+"."+sch+"'"); for (String table : Arrays.asList(tableList.split(","))) { if (tablePattern.matcher(table).matches()) { rs.addRow(); rs.updateObject(1, cat); rs.updateObject(2, sch); rs.updateObject(3, table); rs.updateObject(4, "TABLE"); } else { logger.debug("Skipping table "+table+" (doesn't match pattern)"); } } } } } } } | public ResultSet getTables(String catalogNamePattern, String schemaNamePattern, String tableNamePattern, String[] types) throws SQLException { MockJDBCResultSet rs = new MockJDBCResultSet(null, 10); rs.setColumnName(1, "TABLE_CAT"); rs.setColumnName(2, "TABLE_SCHEM"); rs.setColumnName(3, "TABLE_NAME"); rs.setColumnName(4, "TABLE_TYPE"); rs.setColumnName(5, "REMARKS"); rs.setColumnName(6, "TYPE_CAT"); rs.setColumnName(7, "TYPE_SCHEM"); rs.setColumnName(8, "TYPE_NAME"); rs.setColumnName(9, "SELF_REFERENCING_COL_NAME"); rs.setColumnName(10, "REF_GENERATION"); Pattern catalogPattern = createPatternFromSQLWildcard(catalogNamePattern); Pattern schemaPattern = createPatternFromSQLWildcard(schemaNamePattern); Pattern tablePattern = createPatternFromSQLWildcard(tableNamePattern); String catalogList = connection.getProperties().getProperty("catalogs"); String schemaList = connection.getProperties().getProperty("schemas"); String tableList = connection.getProperties().getProperty("tables"); // TODO: create the result set rows here rs.beforeFirst(); return rs; } |
|
registerTag( "extend", ExtendTag.class ); registerTag( "super", SuperTag.class ); | public DefineTagLibrary() { registerTag( "taglib", TaglibTag.class ); registerTag( "tag", TagTag.class ); registerTag( "bean", BeanTag.class ); registerTag( "dynaBean", DynaBeanTag.class ); registerTag( "jellybean", JellyBeanTag.class ); registerTag( "attribute", AttributeTag.class ); registerTag( "invokeBody", InvokeBodyTag.class ); registerTag( "script", ScriptTag.class ); registerTag( "invoke", InvokeTag.class ); registerTag( "classLoader", ClassLoaderTag.class ); } |
|
theHV.blockMenuItems[BLOX_CUSTOM].setSelected(true); | theHV.changeBlocks(BLOX_CUSTOM); | public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) { int clickX = e.getX(); int clickY = e.getY(); if (showWM && wmInteriorRect.contains(clickX,clickY)){ //convert a click on the worldmap to a point on the big picture int bigClickX = (((clickX - getVisibleRect().x - (worldmap.getWidth()-wmInteriorRect.width)/2) * chartSize.width) / wmInteriorRect.width)-getVisibleRect().width/2; int bigClickY = (((clickY - getVisibleRect().y - (worldmap.getHeight() - wmInteriorRect.height)/2 - (getVisibleRect().height-worldmap.getHeight())) * chartSize.height) / wmInteriorRect.height) - getVisibleRect().height/2 + infoHeight; //System.out.println(chartSize.height); //if the clicks are near the edges, correct values if (bigClickX > chartSize.width - getVisibleRect().width){ bigClickX = chartSize.width - getVisibleRect().width; } if (bigClickX < 0){ bigClickX = 0; } if (bigClickY > chartSize.height - getVisibleRect().height + infoHeight){ bigClickY = chartSize.height - getVisibleRect().height + infoHeight; } if (bigClickY < 0){ bigClickY = 0; } ((JViewport)getParent()).setViewPosition(new Point(bigClickX,bigClickY)); }else{ theHV.blockMenuItems[BLOX_CUSTOM].setSelected(true); Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (Chromosome.getFilteredSize()*boxSize), boxSize); if(blockselector.contains(clickX,clickY)){ int whichMarker = (int)(0.5 + (double)((clickX - clickXShift))/boxSize); if (theData.isInBlock[whichMarker]){ theData.removeFromBlock(whichMarker); repaint(); } else if (whichMarker > 0 && whichMarker < Chromosome.realIndex.length){ theData.addMarkerIntoSurroundingBlock(whichMarker); } } } } } |
theHV.blockMenuItems[BLOX_CUSTOM].setSelected(true); | theHV.changeBlocks(BLOX_CUSTOM); | public void mouseReleased(MouseEvent e) { //remove popped up window if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ popupExists = false; repaint(); //resize window once user has ceased dragging } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ if (getCursor() == Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)){ resizeRectExists = false; noImage = true; if (resizeWMRect.width > 20){ wmMaxWidth = resizeWMRect.width; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); repaint(); } if (getCursor() == Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); blockRectExists = false; int firstMarker = (int)(0.5 + (double)((blockStartX - clickXShift))/boxSize); int lastMarker = (int)(0.5 + (double)((e.getX() - clickXShift))/boxSize); if (firstMarker > lastMarker){ int temp = firstMarker; firstMarker = lastMarker; lastMarker = temp; } theHV.blockMenuItems[BLOX_CUSTOM].setSelected(true); theData.addBlock(firstMarker, lastMarker); repaint(); } } } |
void makeDialog(SQLTable st, int colIdx) throws ArchitectException { | private void makeDialog(SQLTable st, int colIdx) throws ArchitectException { | void makeDialog(SQLTable st, int colIdx) throws ArchitectException { if (editDialog != null) { columnEditPanel.setModel(st); columnEditPanel.selectColumn(colIdx); editDialog.setTitle("Column Properties of "+st.getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(st, colIdx); panel.add(columnEditPanel, BorderLayout.CENTER); editDialog = ArchitectPanelBuilder.createArchitectPanelDialog( columnEditPanel, ArchitectFrame.getMainInstance(), "Column Properties of "+st.getName(), "OK"); panel.setOpaque(true); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } |
columnEditPanel.editColumn(colIdx); | void makeDialog(SQLTable st, int colIdx) throws ArchitectException { if (editDialog != null) { columnEditPanel.setModel(st); columnEditPanel.selectColumn(colIdx); editDialog.setTitle("Column Properties of "+st.getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(st, colIdx); panel.add(columnEditPanel, BorderLayout.CENTER); editDialog = ArchitectPanelBuilder.createArchitectPanelDialog( columnEditPanel, ArchitectFrame.getMainInstance(), "Column Properties of "+st.getName(), "OK"); panel.setOpaque(true); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } |
|
for (index = begin; iter.hasNext() && index < end; index += step) { | for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { | public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } for (index = begin; iter.hasNext() && index < end; index += step) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } getBody().run(context, output); } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } } } |
index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } | public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } for (index = begin; iter.hasNext() && index < end; index += step) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } getBody().run(context, output); } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } } } |
|
manager.redo(); | if (logger.isDebugEnabled()) { logger.debug(manager); int choice = JOptionPane.showConfirmDialog(null, "Undo manager state dumped to logger." + "\n\n" + "Proceed with redo?"); if (choice == JOptionPane.YES_OPTION) { manager.redo(); } } else { manager.redo(); } | public void actionPerformed(ActionEvent evt ) { manager.redo(); } |
return parent.findVariable(name); | answer = parent.findVariable(name); if ( answer == null ) { try { answer = System.getProperty(name); } catch (Throwable t) { } } | public Object findVariable(String name) { Object answer = variables.get(name); if ( answer == null && parent != null ) { return parent.findVariable(name); } return answer; } |
} if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); HaploTDTPanel htp = (HaploTDTPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ metaAssoc.remove(1); metaAssoc.add("Haplotypes", new HaploTDTPanel(theData.getHaplotypes())); } | public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(currentScheme); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } } |
|
Options.setAssocTest(0); | Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); | public HaploView(){ //set defaults Options.setMissingThreshold(1.0); Options.setSpacingThreshold(0.0); Options.setAssocTest(0); try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //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); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* 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(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); 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]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); JMenuItem spacingItem = new JMenuItem("LD Display Spacing"); spacingItem.setMnemonic(KeyEvent.VK_S); spacingItem.addActionListener(this); displayMenu.add(spacingItem); displayMenu.setEnabled(false); //analysis menu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); analysisMenu.setEnabled(false); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* Configuration.readConfigFile(); if(Configuration.isCheckForUpdate()) { Object[] options = {"Yes", "Not now", "Never ask again"}; int n = JOptionPane.showOptionDialog(this, "Would you like to check if a new version " + "of haploview is available?", "Check for update", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if(n == JOptionPane.YES_OPTION) { UpdateChecker uc = new UpdateChecker(); if(uc.checkForUpdate()) { JOptionPane.showMessageDialog(this, "A new version of Haploview is available!\n Visit http://www.broad.mit.edu/mpg/haploview/ to download the new version\n (current version: " + Constants.VERSION + " newest version: " + uc.getNewVersion() + ")" , "Update Available", JOptionPane.INFORMATION_MESSAGE); } } else if(n == JOptionPane.CANCEL_OPTION) { Configuration.setCheckForUpdate(false); Configuration.writeConfigFile(); } } */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
String[] inputArray = new String[3]; | String[] inputArray = new String[2]; | public static void main(String[] args) { boolean nogui = false; //HaploView window; for(int i = 0;i<args.length;i++) { if(args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) { nogui = true; } } if(nogui) { HaploText textOnly = new HaploText(args); } else { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); //setup view object window.setTitle(TITLE_STRING); 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); //parse command line stuff for input files or prompt data dialog HaploText argParser = new HaploText(args); String[] inputArray = new String[3]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
inputArray[2] = String.valueOf(Options.getMaxDistance()); | public static void main(String[] args) { boolean nogui = false; //HaploView window; for(int i = 0;i<args.length;i++) { if(args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) { nogui = true; } } if(nogui) { HaploText textOnly = new HaploText(args); } else { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); //setup view object window.setTitle(TITLE_STRING); 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); //parse command line stuff for input files or prompt data dialog HaploText argParser = new HaploText(args); String[] inputArray = new String[3]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; inputArray[2] = String.valueOf(Options.getMaxDistance()); window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
|
if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); Options.setAssocTest(0); } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
|
Options.setAssocTest(0); | Options.setAssocTest(ASSOC_NONE); | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); Options.setAssocTest(0); } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
if(Options.getAssocTest() > 0) { | if(Options.getAssocTest() != ASSOC_NONE) { | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); Options.setAssocTest(0); } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); | metaAssoc.add(viewItems[VIEW_TDT_NUM], tdtPanel); HaploTDTPanel htp = new HaploTDTPanel(theData.getHaplotypes()); metaAssoc.add("Haplotypes", htp); tabs.addTab("Association Results", metaAssoc); | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); Options.setAssocTest(0); } theData = new HaploData(); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData, true); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
if(Options.getAssocTest() > 0) { | if(Options.getAssocTest() != ASSOC_NONE) { | public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } |
tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); | metaAssoc.add(viewItems[VIEW_TDT_NUM], tdtPanel); HaploTDTPanel htp = new HaploTDTPanel(theData.getHaplotypes()); metaAssoc.add("Haplotypes", htp); tabs.addTab("Association Results", metaAssoc); | public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } |
ProgressMonitor pm = new ProgressMonitor(null, | ProgressMonitor pm = new ProgressMonitor(panel, | public boolean applyChanges() { wizard.addSourceDatabases(wizard.getSourceTables()); Map ddlGeneratorMap = ArchitectUtils.getDriverDDLGeneratorMap(); Class selectedGeneratorClass = (Class) ddlGeneratorMap.get( wizard.getPlExport().getTargetDataSource().getDriverClass()); if (selectedGeneratorClass == null) { JOptionPane.showMessageDialog(getPanel(), "Unable to create DDL Script for the target database.", "Database Error", JOptionPane.ERROR_MESSAGE); return false; } GenericDDLGenerator ddlg; try { ddlg = (GenericDDLGenerator) selectedGeneratorClass.newInstance(); ddlg.setTargetCatalog(wizard.getPlExport().getTargetCatalog()); ddlg.setTargetSchema(wizard.getPlExport().getTargetSchema()); ArchitectFrame.getMainInstance().getProject().setModified(false); ArchitectFrame.getMainInstance().newProjectAction.actionPerformed( new ActionEvent(this, 0, null)); PlayPen p = ArchitectFrame.getMainInstance().getProject().getPlayPen(); p.getDatabase().setDataSource(wizard.getPlExport().getTargetDataSource()); ExportDDLAction eda = (ExportDDLAction) ArchitectFrame.getMainInstance().exportDDLAction; ExportPLTransAction epta = (ExportPLTransAction) ArchitectFrame.getMainInstance().exportPLTransAction; List statements = new ArrayList(); // 1. copy SQL Tables ProgressMonitor pm = new ProgressMonitor(null, "Copying objects from DBTree", "...", 0, 100); AddObjectsTask aot = p.new AddObjectsTask( wizard.getSourceTables(), new Point(50, 50), pm, wizard.getParentDialog()); // 1a. generate a list of statements GenerateStatementsTask gst = new QuickStartWizard.GenerateStatementsTask(statements, ddlg, p.getDatabase(), wizard.getParentDialog()); // 2. get sql script worker SQLScriptDialog ssd = new SQLScriptDialog(wizard.getParentDialog(), "Preview SQL Script", "The Architect will create these tables:", false, ddlg, wizard.getPlExport().getTargetDataSource(), false); MonitorableWorker scriptWorker = ssd.getExecuteTask(); ssd.setStatementResultList(wizard.getPlExport().getExportResultList()); // 3. create conflict finder ans resolver ConflictFinderProcess cfp; cfp = eda.new ConflictFinderProcess( wizard.getParentDialog(), new SQLDatabase(wizard.getPlExport().getTargetDataSource()), ddlg, statements); ConflictResolverProcess crp; crp = eda.new ConflictResolverProcess( wizard.getParentDialog(), cfp); // 5. export PL Transactions (and run PL Transactions (if requested) // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = epta.new ExportTxProcess( wizard.getPlExport(), epta.getExportingTables(), wizard.getParentDialog(), ((WizardDialog)wizard.getParentDialog()).getProgressBar(), ((WizardDialog)wizard.getParentDialog()).getProgressLabel()); aot.setNextProcess(gst); gst.setNextProcess(cfp); cfp.setNextProcess(crp); crp.setNextProcess(scriptWorker); scriptWorker.setNextProcess(etp); ((WizardDialog)wizard.getParentDialog()).getNextButton().setEnabled(false); new Thread(aot, "Wizard-Objects-Adder").start(); } catch (InstantiationException e1) { logger.error("problem running Quick Start Wizard", e1); } catch (IllegalAccessException e1) { logger.error("problem running Quick Start Wizard", e1); } catch (ArchitectException e) { logger.error("problem running Quick Start Wizard", e); } catch (SQLException e) { logger.error("problem running Quick Start Wizard", e); } return true; } |
public void fakeStructureChanged(String string) { fireDbStructureChanged(string); | public void fakeStructureChanged() { fireDbStructureChanged(); | public void fakeStructureChanged(String string) { fireDbStructureChanged(string); } |
((SQLObjectImpl)target).fakeStructureChanged("george"); | ((SQLObjectImpl)target).fakeStructureChanged(); | public final void testSQLObjectListenerHandling() throws ArchitectException { SQLObjectListener t = new TestListener(); TestListener tt = (TestListener)t; target.addSQLObjectListener(t); allowsChildren = true; tt.setChildInserted(false); final SQLObjectImpl objectImpl = new SQLObjectImpl(); target.addChild(objectImpl); assertTrue(tt.isChildInserted()); tt.setObjectChanged(false); ((SQLObjectImpl)target).fakeObjectChanged("fred","old value","new value"); assertTrue(tt.isObjectChanged()); tt.setObjectChanged(false); ((SQLObjectImpl)target).fakeObjectChanged("fred","old value","old value"); assertFalse(tt.isObjectChanged()); tt.setStructureChanged(false); ((SQLObjectImpl)target).fakeStructureChanged("george"); assertTrue(tt.isStructureChanged()); // MUST BE LAST!! target.removeSQLObjectListener(t); assertEquals(Collections.EMPTY_LIST, target.getSQLObjectListeners()); } |
List<String> driverJarNameList = session.getDriverJarList(); | public UserSettings read(ArchitectSession session) throws IOException { Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = new UserSettings(); List<String> driverJarNameList = session.getDriverJarList(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); if (jarName == null) { break; } // System.out.println("Getting JarName: " + jarName); if (!driverJarNameList.contains(jarName)) { driverJarNameList.add(jarName); } } for (; i <= 99; i++) { // System.out.println("Pruning dead jar entry " + i); prefs.remove(jarFilePrefName(i)); } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", defaultHomeFile("pl.ini"))); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setPowerLoaderEnginePath( prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setETLLogPath( prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setDDLLogPath(prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
|
if (!driverJarNameList.contains(jarName)) { driverJarNameList.add(jarName); } | logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); | public UserSettings read(ArchitectSession session) throws IOException { Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = new UserSettings(); List<String> driverJarNameList = session.getDriverJarList(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); if (jarName == null) { break; } // System.out.println("Getting JarName: " + jarName); if (!driverJarNameList.contains(jarName)) { driverJarNameList.add(jarName); } } for (; i <= 99; i++) { // System.out.println("Pruning dead jar entry " + i); prefs.remove(jarFilePrefName(i)); } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", defaultHomeFile("pl.ini"))); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setPowerLoaderEnginePath( prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setETLLogPath( prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setDDLLogPath(prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
logger.debug("Pruning dead jar entry " + i); | public UserSettings read(ArchitectSession session) throws IOException { Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = new UserSettings(); List<String> driverJarNameList = session.getDriverJarList(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); if (jarName == null) { break; } // System.out.println("Getting JarName: " + jarName); if (!driverJarNameList.contains(jarName)) { driverJarNameList.add(jarName); } } for (; i <= 99; i++) { // System.out.println("Pruning dead jar entry " + i); prefs.remove(jarFilePrefName(i)); } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", defaultHomeFile("pl.ini"))); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setPowerLoaderEnginePath( prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setETLLogPath( prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setDDLLogPath(prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
|
for (int i = 0 ; i <= 99 && it.hasNext(); i++) { String name = it.next(); prefs.put(jarFilePrefName(i), name); | for (int i = 0 ; i <= 99; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } else { prefs.remove(jarFilePrefName(i)); } | public void write(ArchitectSession session) throws ArchitectException { Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = session.getUserSettings(); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99 && it.hasNext(); i++) { String name = it.next(); // System.out.println("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } prefs.put("PL.INI.PATH", userSettings.getPlDotIniPath()); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); prefs.putBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, swingUserSettings.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); prefs.put(ETLUserSettings.PROP_PL_ENGINE_PATH, etlUserSettings.getPowerLoaderEnginePath()); prefs.put(ETLUserSettings.PROP_ETL_LOG_PATH, etlUserSettings.getETLLogPath()); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); prefs.put(DDLUserSettings.PROP_DDL_LOG_PATH, ddlUserSettings.getDDLLogPath()); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); prefs.put(PrintUserSettings.DEFAULT_PRINTER_NAME, printUserSettings.getDefaultPrinterName()); } |
try { prefs.flush(); } catch (BackingStoreException e) { throw new ArchitectException("Unable to flush Java preferences", e); } | public void write(ArchitectSession session) throws ArchitectException { Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = session.getUserSettings(); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99 && it.hasNext(); i++) { String name = it.next(); // System.out.println("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } prefs.put("PL.INI.PATH", userSettings.getPlDotIniPath()); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); prefs.putBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, swingUserSettings.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); prefs.put(ETLUserSettings.PROP_PL_ENGINE_PATH, etlUserSettings.getPowerLoaderEnginePath()); prefs.put(ETLUserSettings.PROP_ETL_LOG_PATH, etlUserSettings.getETLLogPath()); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); prefs.put(DDLUserSettings.PROP_DDL_LOG_PATH, ddlUserSettings.getDDLLogPath()); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); prefs.put(PrintUserSettings.DEFAULT_PRINTER_NAME, printUserSettings.getDefaultPrinterName()); } |
|
m_reader = new BufferedReader(new InputStreamReader(m_telnetClient.getInputStream())); | m_reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(m_telnetClient.getInputStream(), 1024), "ASCII")); | public boolean login() { m_telnetClient = new TelnetClient(); try { m_telnetClient.connect(m_host, m_port); m_reader = new BufferedReader(new InputStreamReader(m_telnetClient.getInputStream())); m_writer = new OutputStreamWriter(m_telnetClient.getOutputStream()); } catch (IOException e) { e.printStackTrace(); return false; } try { sendCommand(m_username); sendCommand(m_password); } catch (IOException e) { e.printStackTrace(); } List answers = readAnswer(); if (answers == null || answers.size() == 0 || !((String)answers.get(answers.size() - 1)).startsWith("Welcome")) { disconnect(); return false; } return true; } |
delay(); | public boolean login() { m_telnetClient = new TelnetClient(); try { m_telnetClient.connect(m_host, m_port); m_reader = new BufferedReader(new InputStreamReader(m_telnetClient.getInputStream())); m_writer = new OutputStreamWriter(m_telnetClient.getOutputStream()); } catch (IOException e) { e.printStackTrace(); return false; } try { sendCommand(m_username); sendCommand(m_password); } catch (IOException e) { e.printStackTrace(); } List answers = readAnswer(); if (answers == null || answers.size() == 0 || !((String)answers.get(answers.size() - 1)).startsWith("Welcome")) { disconnect(); return false; } return true; } |
|
long startTime = System.currentTimeMillis(); try { while (!m_reader.ready() && startTime + 100 > System.currentTimeMillis()) { try { Thread.sleep(20); } catch (InterruptedException e) { break; } } if (!m_reader.ready()) return null; } catch (IOException e) { return null; } StringBuffer stringBuffer = new StringBuffer(); char[] charBuffer = new char[100]; List allAnswerLines = new ArrayList(); try { int readCount; while ((m_reader.ready() && (readCount = m_reader.read(charBuffer)) > 0)) { stringBuffer.append(charBuffer, 0, readCount); if (m_reader.ready()) continue; try { Thread.sleep(20); } catch (InterruptedException e) { break; } } } catch (IOException e) { e.printStackTrace(); } allAnswerLines.addAll(Arrays.asList(stringBuffer.toString().split("\n"))); return allAnswerLines; | return readAnswer(0); | public List readAnswer() { long startTime = System.currentTimeMillis(); try { while (!m_reader.ready() && startTime + 100 > System.currentTimeMillis()) { try { Thread.sleep(20); } catch (InterruptedException e) { break; } } if (!m_reader.ready()) return null; } catch (IOException e) { return null; } StringBuffer stringBuffer = new StringBuffer(); char[] charBuffer = new char[100]; List allAnswerLines = new ArrayList(); try { int readCount; while ((m_reader.ready() && (readCount = m_reader.read(charBuffer)) > 0)) { stringBuffer.append(charBuffer, 0, readCount); if (m_reader.ready()) continue; try { Thread.sleep(20); } catch (InterruptedException e) { break; } } } catch (IOException e) { e.printStackTrace(); } allAnswerLines.addAll(Arrays.asList(stringBuffer.toString().split("\n"))); return allAnswerLines; } |
logger.debug("starting width is: " + width); | public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { width = Math.max(width, metrics.stringWidth(columnIt.next().toString())); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); } |
|
width = Math.max(width, metrics.stringWidth(columnIt.next().toString())); | String theColumn = columnIt.next().toString(); width = Math.max(width, metrics.stringWidth(theColumn)); logger.debug("new width is: " + width); | public Dimension getPreferredSize(JComponent jc) { TablePane c = (TablePane) jc; SQLTable table = c.getModel(); if (table == null) return null; int height = 0; int width = 0; try { Insets insets = c.getInsets(); java.util.List columnList = table.getColumns(); int cols = columnList.size(); Font font = c.getFont(); if (font == null) { logger.error("getPreferredSize(): Null font in TablePane "+c); logger.error("getPreferredSize(): TablePane's parent is "+c.getParent()); return null; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); height = insets.top + fontHeight + gap + c.getMargin().top + cols*fontHeight + boxLineThickness*2 + c.getMargin().bottom + insets.bottom; width = minimumWidth; Iterator columnIt = table.getColumns().iterator(); while (columnIt.hasNext()) { width = Math.max(width, metrics.stringWidth(columnIt.next().toString())); } width += insets.left + c.getMargin().left + boxLineThickness*2 + c.getMargin().right + insets.right; } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.getPreferredSize failed due to", e); width = 100; height = 100; } return new Dimension(width, height); } |
if (path == null) { | if (containmentPath == null) { | public boolean contains(JComponent c, int x, int y) { if (path == null) { return false; } else { Point loc = relationship.getLocation(); return path.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); } } |
return path.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); | return containmentPath.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); | public boolean contains(JComponent c, int x, int y) { if (path == null) { return false; } else { Point loc = relationship.getLocation(); return path.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); } } |
return path.intersects(region.x, region.y, region.width, region.height); | return containmentPath.intersects(region.x, region.y, region.width, region.height); | public boolean intersects(Rectangle region) { return path.intersects(region.x, region.y, region.width, region.height); } |
if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } | containmentPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 10); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(start.x, start.y + getTerminationLength() * 2); containmentPath.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); containmentPath.lineTo(end.x - getTerminationLength() * 2, end.y); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); containmentPath.lineTo(end.x - getTerminationLength() * 2, end.y); containmentPath.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); containmentPath.lineTo(start.x, start.y + getTerminationLength() * 2); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(midx, start.y); containmentPath.lineTo(midx, end.y); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.lineTo(midx, end.y); path.lineTo(midx, start.y); | containmentPath.lineTo(midx, end.y); containmentPath.lineTo(midx, start.y); containmentPath.moveTo(start.x, start.y); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(start.x, midy); containmentPath.lineTo(end.x, midy); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.lineTo(end.x, midy); path.lineTo(start.x, midy); | containmentPath.lineTo(end.x, midy); containmentPath.lineTo(start.x, midy); containmentPath.moveTo(start.x, start.y); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(end.x, start.y); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.lineTo(end.x, start.y); | containmentPath.lineTo(end.x, start.y); containmentPath.moveTo(start.x, start.y); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(start.x, end.y); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.lineTo(start.x, end.y); | containmentPath.lineTo(start.x, end.y); containmentPath.moveTo(start.x, start.y); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); | containmentPath.moveTo(start.x, start.y); containmentPath.lineTo(end.x, end.y); path = new GeneralPath(containmentPath); | public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } } |
return (String)info[series].get(new Double(dataset.getXValue(series,item))); | return (String)info[seriesKeys[series]-1].get(new Double(dataset.getXValue(series,item))); | public String generateToolTip(XYDataset dataset, int series, int item){ return (String)info[series].get(new Double(dataset.getXValue(series,item))); } |
seriesKeys[seriesIndex] = i; seriesIndex++; | public XYSeriesCollection makeDataSet(int col){ int numRows = table.getRowCount(); long[] maxPositions = new long[25]; for (int i = 0; i < numRows; i++){ String chrom = (String)table.getValueAt(i,0); int chr = 0; if (chrom.equalsIgnoreCase("X")){ chr = 23; }else if (chrom.equalsIgnoreCase("Y")){ chr = 24; }else if (chrom.equalsIgnoreCase("XY")){ chr = 25; }else{ chr = Integer.parseInt(chrom); } if (chr < 1){ continue; } long position = ((Long)table.getValueAt(i,2)).longValue(); if (position > maxPositions[chr-1]){ maxPositions[chr-1] = position; } } long[] addValues = new long[25]; long addValue = 0; addValues[0] = 0; for (int i = 1; i < 25; i++){ addValue += maxPositions[i-1]; addValues[i] = addValue; } XYSeries[] xyArray = new XYSeries[26]; for(int i = 1; i < 23; i++){ xyArray[i] = new XYSeries("Chr" + i); } xyArray[23] = new XYSeries("ChrX"); xyArray[24] = new XYSeries("ChrY"); xyArray[25] = new XYSeries("ChrXY"); info = new Hashtable[25]; for (int i = 0; i < 24; i++){ info[i] = new Hashtable(); } for (int i = 0; i < numRows; i++){ String chrom = (String)table.getValueAt(i,0); int chr; if (chrom.equalsIgnoreCase("X")){ chr = 23; }else if (chrom.equalsIgnoreCase("Y")){ chr = 24; }else if (chrom.equalsIgnoreCase("XY")){ chr = 25; }else{ chr = Integer.parseInt(chrom); } if (chr < 1){ continue; } double c = Double.parseDouble(String.valueOf(table.getValueAt(i,2))); c += addValues[chr-1]; c = c/1000; double f = -1; try{ f = ((Double)table.getValueAt(i,col)).doubleValue(); }catch (ClassCastException cce){ JOptionPane.showMessageDialog(this, "The selected column is not formatted correctly \n" + "for a -log10 plot.", "Invalid column", JOptionPane.ERROR_MESSAGE); return null; }catch (NullPointerException npe){ //this can happen with blank table values from additional results continue; } if (f < 0 || f > 1){ JOptionPane.showMessageDialog(this, "The selected column is not formatted correctly \n" + "for a -log10 plot.", "Invalid column", JOptionPane.ERROR_MESSAGE); return null; } f = (Math.log(f)/Math.log(10))*-1; long kbPos = Long.parseLong(String.valueOf(table.getValueAt(i,2)))/1000; String infoString = table.getValueAt(i,1) + ", Chr" + chrom + ":" + kbPos + ", " + table.getValueAt(i,col); info[chr-1].put(new Double(c),infoString); xyArray[chr].add(c,f); } XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 1; i < 25; i++){ if (xyArray[i].getItemCount() > 0){ dataset.addSeries(xyArray[i]); } } return dataset; } |
|
protected void handleException(Exception e) throws Exception { | protected void handleException(JellyException e) throws Exception { | protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); } |
if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; | if (e.getLineNumber() == -1) { e.setColumnNumber(columnNumber); e.setLineNumber(lineNumber); | protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); } |
if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); | if ( e.getFileName() == null ) { e.setFileName( fileName ); | protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); } |
throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); | if ( e.getElementName() == null ) { e.setElementName( elementName ); } throw e; | protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); } |
if ((evt.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { | if ((evt.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 && !evt.isPopupTrigger()) { | public void mousePressed(MouseEvent evt) { requestFocus(); maybeShowPopup(evt); Point p = evt.getPoint(); unzoomPoint(p); PlayPenComponent c = contentPane.getComponentAt(p); if (c != null) p.translate(-c.getX(), -c.getY()); if (c instanceof Relationship) { if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // selection Relationship r = (Relationship) c; PlayPen pp = (PlayPen) r.getPlayPen(); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } r.setSelected(true); // moving pk/fk decoration boolean overPkDec = ((RelationshipUI) r.getUI()).isOverPkDecoration(p); if (overPkDec || ((RelationshipUI) r.getUI()).isOverFkDecoration(p)) { new RelationshipDecorationMover(r, overPkDec); } } } else if (c instanceof TablePane) { evt.getComponent().requestFocus(); TablePane tp = (TablePane) c; // make sure it was a left click? if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // dragging try { PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(p); logger.debug("MP: clickCol="+clickCol+",columnsSize="+tp.getModel().getColumns().size()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { // 1. unconditionally de-select everything if this table is unselected // 2. if the table was selected, de-select everything if the click was not on the // column header of the table if (!tp.isSelected() || (clickCol > TablePane.COLUMN_INDEX_TITLE && clickCol < tp.getModel().getColumns().size()) ) { pp.selectNone(); } } // re-select the table pane (fire new selection event when appropriate) tp.setSelected(true); // de-select columns if shift and ctrl were not pressed if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { tp.selectNone(); } // select current column unconditionally if (clickCol < tp.getModel().getColumns().size()) { tp.selectColumn(clickCol); } // handle drag (but not if createRelationshipAction is active!) logger.debug("(mouse pressed) click col is: " + clickCol + ", column index title is: " + TablePane.COLUMN_INDEX_TITLE); logger.debug("(mouse pressed) create relationship is active: " + ArchitectFrame.getMainInstance().createRelationshipIsActive()); if (clickCol == TablePane.COLUMN_INDEX_TITLE && !ArchitectFrame.getMainInstance().createRelationshipIsActive()) { Iterator it = pp.getSelectedTables().iterator(); logger.debug("event point: " + p); logger.debug("zoomed event point: " + pp.zoomPoint(new Point(p))); while (it.hasNext()) { // create FloatingTableListener for each selected item TablePane t3 = (TablePane)it.next(); logger.debug("(" + t3.getModel().getName() + ") zoomed selected table point: " + t3.getLocationOnScreen()); logger.debug("(" + t3.getModel().getName() + ") unzoomed selected table point: " + pp.unzoomPoint(t3.getLocationOnScreen())); /* the floating table listener expects zoomed handles which are relative to the location of the table column which was clicked on. */ Point clickedColumn = tp.getLocationOnScreen(); Point otherTable = t3.getLocationOnScreen(); Point handle = pp.zoomPoint(new Point(p)); logger.debug("(" + t3.getModel().getName() + ") translation x=" + (otherTable.getX() - clickedColumn.getX()) + ",y=" + (otherTable.getY() - clickedColumn.getY())); handle.translate((int)(clickedColumn.getX() - otherTable.getX()), (int) (clickedColumn.getY() - otherTable.getY())); new PlayPen.FloatingTableListener(pp, t3, handle,false); } } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } else { if ((evt.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { selectNone(); rubberBandOrigin = new Point(p); rubberBand = new Rectangle(rubberBandOrigin.x, rubberBandOrigin.y, 0, 0); } } } |
final LoginDlg dlg = this; | protected void createUI() { GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.insets = new Insets( 2, 20, 2, 2 ); labelConstraints.anchor = GridBagConstraints.EAST; labelConstraints.gridwidth = GridBagConstraints.RELATIVE; //next-to-last labelConstraints.fill = GridBagConstraints.NONE; //reset to default labelConstraints.weightx = 0.0; //reset to default GridBagConstraints fieldConstraints = new GridBagConstraints(); fieldConstraints.insets = new Insets( 2, 2, 2, 20 ); fieldConstraints.anchor = GridBagConstraints.WEST; fieldConstraints.gridwidth = GridBagConstraints.REMAINDER; //end row fieldConstraints.weightx = 1.0; JPanel loginPane = new JPanel(); GridBagLayout gb = new GridBagLayout(); loginPane.setLayout( gb ); JLabel idLabel = new JLabel( "Username" ); labelConstraints.insets = new Insets( 20, 20, 4, 4 ); gb.setConstraints( idLabel, labelConstraints ); loginPane.add( idLabel ); idField = new JTextField( 15 ); fieldConstraints.insets = new Insets( 20, 4, 4, 20 ); gb.setConstraints( idField, fieldConstraints ); loginPane.add( idField ); JLabel passLabel = new JLabel( "Password" ); labelConstraints.insets = new Insets( 4, 20, 4, 4 ); gb.setConstraints( passLabel, labelConstraints ); loginPane.add( passLabel ); passField = new JPasswordField( 15 ); fieldConstraints.insets = new Insets( 4, 4, 4, 20 ); gb.setConstraints( passField, fieldConstraints ); loginPane.add( passField ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); Collection databases = settings.getDatabases(); Vector dbNames = new Vector(); Iterator iter = databases.iterator(); while ( iter.hasNext() ) { PVDatabase db = (PVDatabase) iter.next(); dbNames.add( db.getName() ); } Object[] dbs = dbNames.toArray(); JLabel dbLabel = new JLabel( "Database" ); gb.setConstraints( dbLabel, labelConstraints ); loginPane.add( dbLabel ); dbField = new JComboBox( dbs ); gb.setConstraints( dbField, fieldConstraints ); loginPane.add( dbField ); getContentPane().add( loginPane, BorderLayout.NORTH ); JButton newDbBtn = new JButton( "New database..." ); newDbBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_NEWDB; setVisible( false ); } }); JButton okBtn = new JButton( "OK" ); final LoginDlg dlg = this; okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_APPROVE; setVisible( false ); } } ); JButton cancelBtn = new JButton( "Cancel" ); cancelBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_CANCEL; setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add( newDbBtn ); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(cancelBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( okBtn ); pack(); // setResizable( false ); // Center the dialog on screen int w = getSize().width; int h = getSize().height; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screenSize.width-w)/2; int y = (screenSize.height-h)/2; setLocation( x, y ); } |
|
task.init(); if ( "echo".equals( task.getTaskName() ) ) { Echo echoTask = (Echo) task; echoTask.addText( getBodyText() ); echoTask.perform(); echoTask.setMessage( "" ); } else { getBody().run(context, output); task.perform(); } | task.perform(); | public void doTag(XMLOutput output) throws Exception { task.init(); if ( "echo".equals( task.getTaskName() ) ) { Echo echoTask = (Echo) task; echoTask.addText( getBodyText() ); echoTask.perform(); echoTask.setMessage( "" ); } else { // run the body first to configure the task via nested getBody().run(context, output); task.perform(); } } |
public Task getTask() { | public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } | public Task getTask() { return task; } |
public Object getTaskObject() { return task; | public Object getTaskObject() throws Exception { return getTask(); | public Object getTaskObject() { return task; } |
public long getMorganDistance(){ | public double getMorganDistance(){ | public long getMorganDistance(){ return morganDistance; } |
Object[] arguments = { parent, new Integer(style)}; return constructor.newInstance(arguments); | if (types[0].isAssignableFrom(parent.getClass())) { Object[] arguments = { parent, new Integer(style)}; return constructor.newInstance(arguments); } | protected Object createWidget(Class theClass, Widget parent, int style) throws Exception { if (theClass == null) { throw new JellyException( "No Class available to create the new widget"); } if (parent == null) { // lets try call a constructor with a single style Class[] types = { int.class }; Constructor constructor = theClass.getConstructor(types); if (constructor != null) { Object[] arguments = { new Integer(style)}; return constructor.newInstance(arguments); } } else { // lets try to find the constructor with 2 arguments with the 2nd argument being an int Constructor[] constructors = theClass.getConstructors(); if (constructors != null) { for (int i = 0, size = constructors.length; i < size; i++ ) { Constructor constructor = constructors[i]; Class[] types = constructor.getParameterTypes(); if (types.length == 2 && types[1].isAssignableFrom(int.class)) { Object[] arguments = { parent, new Integer(style)}; return constructor.newInstance(arguments); } } } } return theClass.newInstance(); } |
DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; | public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } } |
|
Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } | Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); c.addObjects(paths, dropLoc); | public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } } |
setDynaBean( new WrapDynaBean(propertyBean) ); | setDynaBean( new ConvertingWrapDynaBean(propertyBean) ); | public void compile() throws Exception { TaskTag tag = (TaskTag) findAncestorWithClass( TaskTag.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Task task = tag.getTask(); Class taskClass = task.getClass(); String methodName = "create" + name.substring(0,1).toUpperCase() + name.substring(1); Method method = taskClass.getMethod( methodName, emptyParameterTypes ); if ( method == null ) { throw new JellyException( "Cannot create Task property: " + name + " of Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object propertyBean = method.invoke( task, emptyParameters ); if ( propertyBean == null ) { throw new JellyException( "No property: " + name + " of task: " + task + " was returned." ); } setDynaBean( new WrapDynaBean(propertyBean) ); } |
if (currentInd.getGender() == 2 || !Chromosome.getDataChrom().equals("chrx")){ | if (currentInd.getGender() == 2 || !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ | private void buildCCSet(PedFile pf, Vector affectedStatus, TreeSet snpsToBeTested){ ArrayList results = new ArrayList(); int numMarkers = Chromosome.getUnfilteredSize(); Vector indList = pf.getUnrelatedIndividuals(); int numInds = indList.size(); if(affectedStatus == null || affectedStatus.size() != indList.size()) { affectedStatus = new Vector(indList.size()); for(int i=0;i<indList.size();i++) { Individual tempInd = ((Individual)indList.get(i)); affectedStatus.add(new Integer(tempInd.getAffectedStatus())); } } boolean[] useable = new boolean[indList.size()]; Arrays.fill(useable, false); //this loop determines who is eligible to be used for the case/control association test for(int i=0;i<useable.length;i++) { Individual tempInd = ((Individual)indList.get(i)); Family tempFam = pf.getFamily(tempInd.getFamilyID()); //need to check to make sure we don't include both parents and kids of trios //so, we only set useable[i] to true if Individual at index i is not the child of a trio in the indList if (!(tempFam.containsMember(tempInd.getMomID()) && tempFam.containsMember(tempInd.getDadID()))){ useable[i] = true; } else{ try{ if (!(indList.contains(tempFam.getMember(tempInd.getMomID())) || indList.contains(tempFam.getMember(tempInd.getDadID())))){ useable[i] = true; } }catch (PedFileException pfe){ } } } for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ byte allele1 = 0, allele2 = 0; int[][] counts = new int[2][2]; Individual currentInd; for (int j = 0; j < numInds; j++){ if(useable[j]) { currentInd = (Individual)indList.get(j); int cc = ((Integer)affectedStatus.get(j)).intValue(); if (cc == 0) continue; if (cc == 2) cc = 0; byte a1 = currentInd.getAllele(i,0); byte a2 = currentInd.getAllele(i,1); if (a1 >= 5 && a2 >= 5){ counts[cc][0]++; counts[cc][1]++; if (allele1 == 0){ allele1 = (byte)(a1 - 4); allele2 = (byte)(a2 - 4); } }else{ //seed the alleles as soon as they're found if (allele1 == 0){ allele1 = a1; if (a1 != a2){ allele2 = a2; } }else if (allele2 == 0){ if (a1 != allele1){ allele2 = a1; }else if (a2 != allele1){ allele2 = a2; } } if (a1 != 0){ if (a1 == allele1){ counts[cc][0] ++; }else{ counts[cc][1] ++; } } if (currentInd.getGender() == 2 || !Chromosome.getDataChrom().equals("chrx")){ if (a2 != 0){ if (a2 == allele1){ counts[cc][0]++; }else{ counts[cc][1]++; } } } } } } int[] g1 = {allele1}; int[] g2 = {allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setCaseCount(counts[0][0]); thisSNP1.setControlCount(counts[1][0]); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setCaseCount(counts[0][1]); thisSNP2.setControlCount(counts[1][1]); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getDisplayName(), currentMarker)); } } this.results = new Vector(results); } |
public void doTag(XMLOutput xmlOutput) throws Exception { | public void doTag(XMLOutput xmlOutput) throws JellyTagException { | public void doTag(XMLOutput xmlOutput) throws Exception { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( "<notFoundHandler> tag must be enclosed inside a <httpContext> tag" ); } NotFoundHandler notFoundHandler = new NotFoundHandler(); httpContext.addHandler(notFoundHandler); invokeBody(xmlOutput); } |
logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); | if (logger.isDebugEnabled()) logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toLowerCase(); if (logger.isDebugEnabled()) logger.debug("after replace of spaces: " + ident); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("identifiers must start with letter, appending X: " + ident); | if (logger.isDebugEnabled()) logger.debug("identifiers must start with letter; prepending X: " + ident); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("identifier was reserved word, appending X: " + ident); | if (logger.isDebugEnabled()) logger.debug("identifier was reserved word, prepending X: " + ident); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } | ident = ident.replaceAll("[^a-zA-Z0-9_$]", "_"); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
if (ident.length() < 129) { | if (ident.length() <= 63) { | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); | if (logger.isDebugEnabled()) logger.debug("truncating identifier: " + ident); String base = ident.substring(0, 60); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("new identifier: " + base + tiebreaker); | if (logger.isDebugEnabled()) logger.debug("new identifier: " + base + tiebreaker); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("physical identifier is not unique, regenerating: " + physicalName); | if (logger.isDebugEnabled()) logger.debug("physical identifier is not unique, regenerating: " + physicalName); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
if (ident.length() > 125) { base = ident.substring(0,125); | if (ident.length() > 63) { base = ident.substring(0, 60); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
logger.debug("regenerated identifier is: " + (base + tiebreaker)); | if (logger.isDebugEnabled()) logger.debug("regenerated identifier is: " + (base + tiebreaker)); | public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } } |
out.println("-- Created by SQLPower DB2 DDL Generator "+GENERATOR_VERSION+" --"); | println("-- Created by SQLPower DB2 DDL Generator "+GENERATOR_VERSION+" --"); | public void writeHeader() { out.println("-- Created by SQLPower DB2 DDL Generator "+GENERATOR_VERSION+" --"); } |
JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); | JDefaultButton okButton = new JDefaultButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); | public void actionPerformed(ActionEvent e) { // ArchitectPanelBuilder cannot handle this because of the // wizard-style buttons (right-justified FlowLayout). final JDialog d = new JDialog(frame,title ); JPanel plr = new JPanel(new BorderLayout(12,12)); plr.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(new ArchitectDataSource()); plr.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); ArchitectDataSource dbcs = dbcsPanel.getDbcs(); if ( comboBox != null ) { comboBox.addItem(dbcs); comboBox.setSelectedItem(dbcs); } frame.getUserSettings().getPlDotIni().addDataSource(dbcs); d.setVisible(false); } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }; JButton cancelButton = new JButton(cancelAction); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); buttonPanel.add(cancelButton); plr.add(buttonPanel, BorderLayout.SOUTH); d.getRootPane().setDefaultButton(okButton); d.setContentPane(plr); d.pack(); d.setLocationRelativeTo(frame); d.setVisible(true); } |
return (Project) context.getVariable( "org.apache.commons.jelly.werkz.Project" ); | return (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); | protected Project getProject() { ProjectTag tag = (ProjectTag) findAncestorWithClass(ProjectTag.class); if ( tag != null) { return tag.getProject(); } return (Project) context.getVariable( "org.apache.commons.jelly.werkz.Project" ); } |
dbcsPanel.setDbcs(new ArchitectDataSource()); | dbcsPanel.setDbcs(dbcs); | public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } } |
DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); | DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,false); | public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } } |
finally { if ( ! context.isCacheTags() ) { clearTag(); } } | public void run(JellyContext context, XMLOutput output) throws Exception { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; try { method.invoke(tag, arguments); } catch (Exception e) { String valueTypeName = (value != null ) ? value.getClass().getName() : "null"; log.warn( "Cannot call method: " + method.getName() + " as I cannot convert: " + value + " of type: " + valueTypeName + " into type: " + type.getName() ); throw createJellyException( "Cannot call method: " + method.getName() + " on tag of type: " + tag.getClass().getName() + " with value: " + value + " of type: " + valueTypeName + ". Exception: " + e, e ); } } try { tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } finally { if ( ! context.isCacheTags() ) { clearTag(); } } } |
|
maf = Math.rint(100.0*(numa1/(numa1+numa2)))/100.0; | maf = Math.rint(100.0*(numa2/(numa1+numa2)))/100.0; | void prepareMarkerInput(File infile, String[][] hapmapGoodies) throws IOException, HaploViewException{ //this method is called to gather data about the markers used. //It is assumed that the input file is two columns, the first being //the name and the second the absolute position. the maxdist is //used to determine beyond what distance comparisons will not be //made. if the infile param is null, loads up "dummy info" for //situation where no info file exists //An optional third column is supported which is designed to hold //association study data. If there is a third column there will be //a visual indicator in the D' display that there is additional data //and the detailed data can be viewed with a mouse press. Vector names = new Vector(); Vector positions = new Vector(); Vector extras = new Vector(); dupsToBeFlagged = false; try{ if (infile != null){ if (infile.length() < 1){ throw new HaploViewException("Info file is empty or does not exist: " + infile.getName()); } String currentLine; long prevloc = -1000000000; //read the input file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; while ((currentLine = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(currentLine); if (st.countTokens() > 1){ lineCount++; }else if (st.countTokens() == 1){ //complain if only one field found throw new HaploViewException("Info file format error on line "+lineCount+ ":\n Info file must be of format: <markername> <markerposition>"); }else{ //skip blank lines continue; } String name = st.nextToken(); String l = st.nextToken(); String extra = null; if (st.hasMoreTokens()) extra = st.nextToken(); long loc; try{ loc = Long.parseLong(l); }catch (NumberFormatException nfe){ throw new HaploViewException("Info file format error on line "+lineCount+ ":\n\"" + l + "\" should be of type long." + "\n Info file must be of format: <markername> <markerposition>"); } //basically if anyone is crazy enough to load a dataset, then go back and load //an out-of-order info file we tell them to bugger off and start over. if (loc < prevloc && Chromosome.markers != null){ throw new HaploViewException("Info file out of order with preloaded dataset:\n"+ name + "\nPlease reload data file and info file together."); } prevloc = loc; names.add(name); positions.add(l); extras.add(extra); } if (lineCount > Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too many\nmarkers in info file compared to data file.")); } if (lineCount < Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too few\nmarkers in info file compared to data file.")); } infoKnown=true; } if (hapmapGoodies != null){ //we know some stuff from the hapmap so we'll add it here for (int x=0; x < hapmapGoodies.length; x++){ names.add(hapmapGoodies[x][0]); positions.add(hapmapGoodies[x][1]); extras.add(null); } infoKnown = true; } else if (infile != null){ //we only sort if we read the info from an info file. if //it is from a hapmap file, then the markers were already sorted //when they were read in (in class Pedfile). int numLines = names.size(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines]; boolean needSort = false; //this loop stores the positions of each marker in an array (pos[]) in the order they appear in the file. //it also creates a hashtable with the positions as keys and their index in the pos[] array as the value for (int k = 0; k < (numLines); k++){ pos[k] = new Long((String)(positions.get(k))).longValue(); sortHelp.put(new Long(pos[k]),new Integer(k)); } //loop through and check if any markers are out of order for (int k = 1; k < (numLines); k++){ if(pos[k] < pos[k-1]) { needSort = true; break; } } //if any were out of order, then we need to put them in order if(needSort) { //sort the positions Arrays.sort(pos); Vector newNames = new Vector(); Vector newExtras = new Vector(); Vector newPositions = new Vector(); int[] realPos = new int[numLines]; //reorder the vectors names and extras so that they have the same order as the sorted markers for (int i = 0; i < pos.length; i++){ realPos[i] = ((Integer)(sortHelp.get(new Long(pos[i])))).intValue(); newNames.add(names.get(realPos[i])); newPositions.add(positions.get(realPos[i])); newExtras.add(extras.get(realPos[i])); } names = newNames; extras = newExtras; positions = newPositions; byte[] tempGenotype = new byte[pos.length]; //now we reorder all the individuals genotypes according to the sorted marker order for(int j=0;j<chromosomes.size();j++){ Chromosome tempChrom = (Chromosome)chromosomes.elementAt(j); for(int i =0;i<pos.length;i++){ tempGenotype[i] = tempChrom.getUnfilteredGenotype(realPos[i]); } for(int i=0;i<pos.length;i++) { tempChrom.setGenotype(tempGenotype[i],i); } } } } }catch (HaploViewException e){ throw(e); }finally{ double numChroms = chromosomes.size(); Vector markerInfo = new Vector(); double[] numBadGenotypes = new double[Chromosome.getUnfilteredSize()]; percentBadGenotypes = new double[Chromosome.getUnfilteredSize()]; Vector results = null; if (pedFile != null){ results = pedFile.getResults(); } long prevPosition = Long.MIN_VALUE; SNP prevMarker = null; for (int i = 0; i < Chromosome.getUnfilteredSize(); i++){ MarkerResult mr = null; if (results != null){ mr = (MarkerResult)results.elementAt(i); } //to compute minor/major alleles, browse chrom list and count instances of each allele byte a1 = 0; byte a2 = 0; double numa1 = 0; double numa2 = 0; for (int j = 0; j < chromosomes.size(); j++){ //if there is a data point for this marker on this chromosome byte thisAllele = ((Chromosome)chromosomes.elementAt(j)).getUnfilteredGenotype(i); if (!(thisAllele == 0)){ if (thisAllele >= 5){ numa1+=0.5; numa2+=0.5; if (thisAllele < 9){ if (a1==0){ a1 = (byte)(thisAllele-4); }else if (a2 == 0){ if (!(thisAllele-4 == a1)){ a2 = (byte)(thisAllele-4); } } } }else if (a1 == 0){ a1 = thisAllele; numa1++; }else if (thisAllele == a1){ numa1++; }else{ numa2++; a2 = thisAllele; } } else { numBadGenotypes[i]++; } } if (numa2 > numa1){ byte temp = a1; a1 = a2; a2 = temp; } double maf; if (mr != null){ maf = Math.rint(mr.getMAF()*100.0)/100.0; }else{ maf = Math.rint(100.0*(numa1/(numa1+numa2)))/100.0; } if (infoKnown){ long pos = Long.parseLong((String)positions.elementAt(i)); SNP thisMarker = (new SNP((String)names.elementAt(i), pos, maf, a1, a2, (String)extras.elementAt(i))); markerInfo.add(thisMarker); if (mr != null){ double genoPC = mr.getGenoPercent(); //check to make sure adjacent SNPs do not have identical positions if (prevPosition != Long.MIN_VALUE){ //only do this for markers 2..N, since we're comparing to the previous location if (pos == prevPosition){ dupsToBeFlagged = true; if (genoPC >= mr.getGenoPercent()){ //use this one because it has more genotypes thisMarker.setDup(1); prevMarker.setDup(2); }else{ //use the other one because it has more genotypes thisMarker.setDup(2); prevMarker.setDup(1); } } } prevPosition = pos; prevMarker = thisMarker; } }else{ markerInfo.add(new SNP("Marker " + String.valueOf(i+1), (i*4000), maf,a1,a2)); } percentBadGenotypes[i] = numBadGenotypes[i]/numChroms; } Chromosome.markers = markerInfo.toArray(); } } |
testRefImageDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\swingui\\TestThumbnailView\\" ); | testRefImageDir = new File( "/home/harri/projects/photovault/tests/images/photovault/swingui/TestThumbnailView/" ); | public Test_ThumbnailView() { testRefImageDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\swingui\\TestThumbnailView\\" ); testRefImageDir.mkdirs(); } |
File f = new File( "c:\\temp\\errorFile.png" ); | File f = new File( "/tmp/errorFile.png" ); | private boolean compareImgToFile( BufferedImage img, File file ) { if ( file.exists() ) { log.debug( "File exists" ); BufferedImage fImg = null; try { fImg = ImageIO.read( file ); log.debug( "Read image" ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); return false; } boolean eq = equals( img, fImg ); if ( !eq ) { File f = new File( "c:\\temp\\errorFile.png" ); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(f); writer.setOutput(ios); writer.write( img ); } catch( IOException e ) { fail( e.getMessage() ); } } return eq; } // The image file does not yet exist, so save it Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(file); writer.setOutput(ios); writer.write(img); } catch( IOException e ) { fail( e.getMessage() ); } return true; } |
File f = new File("c:\\java\\photovault\\testfiles\\test1.jpg" ); | File f = new File(testImgDir, "test1.jpg" ); | protected void setUp() { // Create a frame with the test instance name as the title frame = new JFrame(getName()); pane = (JPanel)frame.getContentPane(); pane.setLayout(new FlowLayout()); pane.setBorder(new EmptyBorder(50, 50, 50, 50)); tester = ComponentTester.getTester(ThumbnailView.class); File f = new File("c:\\java\\photovault\\testfiles\\test1.jpg" ); try { photo = PhotoInfo.addToDB( f ); } catch( PhotoNotFoundException e ) { fail( "error creating photo" ); } photo.setShootingPlace( "TESSTPLACE" ); } |
public void registerBeanTag(String name, BeanTag tag) { templates.put(name, tag); | public void registerBeanTag(String name, TagFactory factory) { templates.put(name, factory); | public void registerBeanTag(String name, BeanTag tag) { templates.put(name, tag); } |
log.warn( "Creating thumbnail" ); | log.debug( "Creating thumbnail" ); | protected void createThumbnail( Volume volume ) { log.warn( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); } |
log.debug( "Finding thumbnail for " + uid ); | log.debug( "getThumbnail: Finding thumbnail for " + uid ); | public Thumbnail getThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; } |
log.debug( "No thumbnail found, creating" ); | public Thumbnail getThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; } |
|
log.debug( "Finding thumbnail for " + uid ); | log.debug( "hasThumbnail: Finding thumbnail for " + uid ); | public boolean hasThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } } return ( thumbnail != null ); } |
exportMenuItems[2].setEnabled(false); | exportMenuItems[3].setEnabled(false); | public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String title = tabs.getTitleAt(tabs.getSelectedIndex()); if (title.equals(VIEW_DPRIME) || title.equals(VIEW_HAPLOTYPES)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (title.equals(VIEW_ASSOC) || title.equals(VIEW_CHECK_PANEL) || title.equals(VIEW_TAGGER)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else if (title.equals(VIEW_PLINK)){ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); exportMenuItems[2].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (title.equals(VIEW_ASSOC)){ JTabbedPane metaAssoc = ((JTabbedPane)((HaploviewTab)tabs.getSelectedComponent()).getComponent(0)); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold() && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ htp.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } } if (title.equals(VIEW_DPRIME)){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } Chromosome.doFilter(checkPanel.getMarkerResults()); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); dPrimeDisplay.revalidate(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } if (theData.finished){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } |
return -left; | return -1; | public int getPreciseMarkerAt(double pos){ int where = Arrays.binarySearch(alignedPositions,pos); if (where >= 0){ return where; }else{ int left = -where-2; int right = -where-1; if (left < 0){ left = 0; right = 1; } if (right >= alignedPositions.length){ right = alignedPositions.length-1; left = alignedPositions.length-1; } if (Math.abs(alignedPositions[right] - pos) < boxRadius){ return right; }else if (Math.abs(pos - alignedPositions[left]) < boxRadius){ return left; } else{ return -left; } } } |
displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); | if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); | public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } } |
displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); | public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } } |
|
currentSelection = null; | public void mouseReleased(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ //remove popped up window popupDrawRect = null; //cache last selection. lastSelection = currentSelection; repaint(); } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ //resize window once user has ceased dragging if (getCursor() == Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)){ noImage = true; if (resizeWMRect.width > 20){ wmMaxWidth = resizeWMRect.width; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); resizeWMRect = null; repaint(); } if (getCursor() == Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); if (blockRect != null){ //don't add the block if the dragging was really short, as it was probably just a twitch while clicking if (Math.abs(e.getX() - blockStartX) > boxRadius/2){ int firstMarker = getPreciseMarkerAt(blockStartX - clickXShift); int lastMarker = getPreciseMarkerAt(e.getX() - clickXShift); //we're moving left to right if (blockStartX > e.getX()){ int temp = firstMarker; firstMarker = lastMarker; lastMarker = temp; } //negative results represent starting or stopping the drag in "no-man's land" //so we adjust depending on which side we're on if (firstMarker < 0){ firstMarker = -firstMarker + 1; } if (lastMarker < 0){ lastMarker = -lastMarker; } theHV.changeBlocks(BLOX_CUSTOM); theData.addBlock(firstMarker, lastMarker); } blockRect = null; repaint(); } } } } |
|
Color green = new Color(0, 127, 0); | Color green = new Color(0, 170, 0); | public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //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. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // 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.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 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); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.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 g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: 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(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*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.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.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)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); | float cornerx = (float)xx-10; float cornery = top; float xpoints[] = {cornerx,cornerx+20,cornerx+10}; float ypoints[] = {cornery,cornery,cornery-10}; GeneralPath triangle = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); triangle.moveTo(xpoints[0],ypoints[0]); | public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //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. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // 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.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 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); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.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 g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: 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(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*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.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.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)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
star.lineTo(xpoints[index],ypoints[index]); | triangle.lineTo(xpoints[index],ypoints[index]); | public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //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. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // 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.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 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); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.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 g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: 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(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*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.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.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)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.