rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ continue; }else if (st.countTokens() == 1){ markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ markerNames = st.nextToken(); alleles = st.nextToken(); }else{ markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } }
public AssociationTestSet(String fileName) throws IOException, HaploViewException{ tests = new Vector(); whitelist = new HashSet(); File testListFile = new File(fileName); BufferedReader in = new BufferedReader(new FileReader(testListFile)); String currentLine; int lineCount = 0; //we need to be able to identify marker index by name Hashtable indicesByName = new Hashtable(); Iterator mitr = Chromosome.getAllMarkers().iterator(); int count = 0; while (mitr.hasNext()){ SNP n = (SNP) mitr.next(); indicesByName.put(n.getDisplayName(),new Integer(count)); count++; } while ((currentLine = in.readLine()) != null){ lineCount++; //first determine if a tab specifies a specific allele for a multi-marker test StringTokenizer st = new StringTokenizer(currentLine, "\t"); String markerNames; String alleles; if (st.countTokens() == 0){ //skip blank lines continue; }else if (st.countTokens() == 1){ //this is just a list of markers markerNames = st.nextToken(); alleles = null; }else if (st.countTokens() == 2){ //this has markers and alleles markerNames = st.nextToken(); alleles = st.nextToken(); }else{ //this is *!&#ed up markerNames = null; alleles = null; throw new HaploViewException("Format error on line " + lineCount + " of tests file."); } StringTokenizer mst = new StringTokenizer(markerNames, ", "); AssociationTest t = new AssociationTest(); while (mst.hasMoreTokens()) { String currentToken = mst.nextToken(); if (!indicesByName.containsKey(currentToken)){ throw new HaploViewException("I don't know anything about marker " + currentToken + " in custom tests file."); } Integer nt = (Integer) indicesByName.get(currentToken); t.addMarker(nt); } tests.add(t); if (alleles != null){ //we have alleles StringBuffer asb = new StringBuffer(); StringTokenizer ast = new StringTokenizer(alleles, ", "); if (ast.countTokens() != t.getNumMarkers()){ throw new HaploViewException("Allele and marker name mismatch on line " + lineCount + " of tests file."); } while (ast.hasMoreTokens()){ asb.append(ast.nextToken()); } t.specifyAllele(asb.toString()); } } }
public IndividualDialog (HaploData hd){
public IndividualDialog (HaploView h, String title) { super(h,title);
public IndividualDialog (HaploData hd){ Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
Vector people = hd.getPedFile().getAllIndividuals();
JPanel contents = new JPanel(); JTable table; contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector people = h.theData.getPedFile().getAllIndividuals(); Vector excludedPeople = h.theData.getPedFile().getAxedPeople();
public IndividualDialog (HaploData hd){ Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
table = new JTable(tableModel); IndividualCellRenderer renderer = new IndividualCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Long"), renderer); table.setDefaultRenderer(Class.forName("java.lang.String"),renderer); }catch (Exception e){ } table.getColumnModel().getColumn(2).setPreferredWidth(30); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("Close"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true);
public IndividualDialog (HaploData hd){ Vector people = hd.getPedFile().getAllIndividuals(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(currentInd.getGenoPC()*100)); data.add(tmpVec); } tableModel = new BasicTableModel(colNames, data); }
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults();
public MendelDialog (HaploView h, String title) { super(h,title); JPanel contents = new JPanel(); JTable table; contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector results = h.theData.getPedFile().getResults();
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
Vector tmpVec = new Vector();
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
tableModel = new BasicTableModel(colNames, data);
TableSorter sorter = new TableSorter(new BasicTableModel(colNames, data)); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); table.getColumnModel().getColumn(2).setPreferredWidth(30); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("Close"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true);
public MendelDialog(HaploData hd){ Vector results = hd.getPedFile().getResults(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("ChildID"); colNames.add("Marker"); colNames.add("Position"); Vector data = new Vector(); for(int i=0;i<results.size();i++) { MarkerResult currentResult = (MarkerResult)results.get(i); if (currentResult.getMendErrNum() > 0){ Vector tmpVec = new Vector(); Vector mendelErrors = currentResult.getMendelErrors(); for (int j = 0; j < mendelErrors.size(); j++){ MendelError error = (MendelError)mendelErrors.get(j); tmpVec.add(error.getFamilyID()); tmpVec.add(error.getChildID()); tmpVec.add(Chromosome.getUnfilteredMarker(i).getDisplayName()); tmpVec.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); data.add(tmpVec); } } } tableModel = new BasicTableModel(colNames, data); }
DPrimeDisplay(HaploData hd){ theData = hd; this.computePreferredSize();
DPrimeDisplay(HaploView h){ theData=h.theData; theHV = h; this.computePreferredSize(theHV.getGraphics());
DPrimeDisplay(HaploData hd){ //called when in cmd line mode, used to dump pngs theData = hd; this.computePreferredSize(); this.colorDPrime(); }
this.setDoubleBuffered(true); addMouseListener(this); addMouseMotionListener(this); this.setAutoscrolls(true);
DPrimeDisplay(HaploData hd){ //called when in cmd line mode, used to dump pngs theData = hd; this.computePreferredSize(); this.colorDPrime(); }
exportStart = start;
exportStart = Chromosome.filterIndex[start];
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize();
exportStop = Chromosome.filterIndex[stop-1]; if (exportStop >= Chromosome.getSize()){ exportStop = Chromosome.getSize()-1;
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
this.computePreferredSize();
public BufferedImage export(int start, int stop, boolean compress) throws HaploViewException { forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > Chromosome.getSize()){ exportStop = Chromosome.getSize(); } int startBS = boxSize; int startBR = boxRadius; boolean startPD = printDPrimeValues; boolean startMN = printMarkerNames; int startZL = zoomLevel; if (compress){ zoomLevel = 2; printDPrimeValues = false; printMarkerNames = false; if (boxSize > (1200/(stop - start))){ boxSize = 1200/(stop - start); if (boxSize < 2){ boxSize = 2; } //to make picture not look dumb we need to avoid odd numbers for really teeny boxes if (boxSize < 10){ if (boxSize%2 != 0){ boxSize++; } } boxRadius = boxSize/2; } this.computePreferredSize(); } Dimension pref = getPreferredSize(); if(pref.width > 10000 || pref.height > 10000) { throw new HaploViewException("Image too large. Try saving as compressed PNG."); } BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); boxSize = startBS; boxRadius = startBR; zoomLevel = startZL; printMarkerNames = startMN; printDPrimeValues = startPD; forExport = false; this.computePreferredSize(); return i; }
Vector permuteInd = new Vector(pedFile.getAllIndividuals().size());
Vector permuteInd = new Vector(); for (int i = 0; i < pedFile.getAllIndividuals().size(); i++){ permuteInd.add(null); }
public void doPermutations(int selection) { selectionType = selection; stopProcessing = false; Vector curResults = null; if (selectionType == CUSTOM){ activeAssocTestSet = custAssocTestSet; }else{ activeAssocTestSet = defaultAssocTestSet; } double curBest = 0; String curName = ""; for(int i=0;i<activeAssocTestSet.getFilteredResults().size();i++) { AssociationResult tmpRes = (AssociationResult) activeAssocTestSet.getFilteredResults().get(i); for (int j = 0; j < tmpRes.getAlleleCount(); j++){ if (tmpRes.getChiSquare(j) > curBest){ curName = tmpRes.getDisplayName(j); curBest = tmpRes.getChiSquare(j); } } } bestObsChiSq = curBest; bestObsName = curName; Haplotype[][] haplotypes = new Haplotype[activeAssocTestSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = activeAssocTestSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = activeAssocTestSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(haplotypes[j][k].getGeno(),haplotypes[j][k].getPercentage(), haplotypes[j][k].getMarkers(), haplotypes[j][k].getEM()); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; if(Options.getAssocTest() == ASSOC_CC) { Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } } //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = new Vector(pedFile.getAllIndividuals().size()); permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.set(j,Boolean.valueOf(true)); } else { permuteInd.set(j,Boolean.valueOf(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test if (selectionType != SINGLE_ONLY){ //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = fakeHaplos[j][0].getEM(); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = null; if (activeAssocTestSet.getFilterAlleles() == null){ ats = new AssociationTestSet(fakeHaplos, null); }else{ try{ ats = new AssociationTestSet(fakeHaplos,null,activeAssocTestSet.getFilterAlleles()); }catch (HaploViewException hve){ } } curResults.addAll(ats.getResults()); } //end of haplotype association test } //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
if (connection == null) { throw new JellyException( "Could not find a JMS connection called: " + name ); }
public void doTag(XMLOutput output) throws Exception { connection = MessengerManager.get( name ); if ( var != null ) { context.setVariable( var, connection ); } invokeBody(output); }
db.addVolume( v );
try { db.addVolume( v ); } catch (PhotovaultException ex) { }
protected void indexDir() { IndexerFileChooser fc = new IndexerFileChooser(); fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); int retval = fc.showDialog( this, "Select directory to index" ); if ( retval == JFileChooser.APPROVE_OPTION ) { File dir = fc.getSelectedFile(); // First check that this directory has not been indexed previously VolumeBase prevVolume = null; try { prevVolume = VolumeBase.getVolumeOfFile( dir ); } catch (IOException ex) { JOptionPane.showMessageDialog( this, "Problem reading directory: " + ex.getMessage(), "Photovault error", JOptionPane.ERROR_MESSAGE ); return; } if ( prevVolume != null ) { JOptionPane.showMessageDialog( this, "Directory " + dir.getAbsolutePath() + "\n has already been indexed to Photovault.", "Already indexed", JOptionPane.ERROR_MESSAGE ); return; } // Generate a unique name for the new volume String extVolName = "extvol_" + dir.getName(); if ( VolumeBase.getVolume( extVolName ) != null ) { int n = 2; while ( VolumeBase.getVolume( extVolName + n ) != null ) { n++; } extVolName += n; } ExternalVolume v = new ExternalVolume( extVolName, dir.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = settings.getCurrentDatabase(); db.addVolume( v ); // Set up the indexer ExtVolIndexer indexer = new ExtVolIndexer( v ); PhotoFolder parentFolder = fc.getExtvolParentFolder(); if ( parentFolder == null ) { parentFolder = PhotoFolder.getRoot(); } String rootFolderName = "extvol_" + dir.getName(); if ( rootFolderName.length() > PhotoFolder.NAME_LENGTH ) { rootFolderName = rootFolderName.substring( 0, PhotoFolder.NAME_LENGTH ); } PhotoFolder topFolder = PhotoFolder.create( rootFolderName, parentFolder ); topFolder.setDescription( "Indexed from " + dir.getAbsolutePath() ); indexer.setTopFolder( topFolder ); // Save the configuration of the new volume settings.saveConfig(); // Show status dialog & index the directory IndexerStatusDlg statusDlg = new IndexerStatusDlg( this, false ); statusDlg.setVisible( true ); statusDlg.runIndexer( indexer ); } }
Throwable rootCause = e; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() );
public static PhotoFolder getRoot() { PhotoFolder rootFolder = PhotoFolder.rootFolder; if ( rootFolder == null ) { ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); List folders = null; boolean mustCommit = false; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (List) query.execute(); } catch ( Exception e ) { txw.abort(); return null; } rootFolder = (PhotoFolder) folders.get( 0 ); PhotoFolder.rootFolder = rootFolder; // If a new transaction was created, commit it txw.commit(); } return rootFolder; }
Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( );
Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; File imageFile = original.getImageFile(); if ( imageFile != null && imageFile.canRead() ) { final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); return; }
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); }
} setImage( null ); throw new FileNotFoundException( "No original instance of photo " + photo.getUid() + " found" );
public void setPhoto( PhotoInfo photo ) throws FileNotFoundException { if ( this.photo != null ) { this.photo.removeChangeListener( this ); } this.photo = photo; if ( photo == null ) { setImage( null ); return; } log.debug( "JAIPhotoViewer.setPhoto() photo=" + photo.getUid() ); photo.addChangeListener( this ); // Find the original file ImageInstance original = null; Vector instances = photo.getInstances(); for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; break; } } if ( original == null ) { log.debug( "Error - no original image was found!!!" ); } else { File imageFile = original.getImageFile(); if ( imageFile == null ) { throw new FileNotFoundException( ); } final String imageFilePath = original.getImageFile().getAbsolutePath(); log.debug( "loading image " + imageFilePath ); PlanarImage origImage = JAI.create( "fileload", imageFilePath ); log.debug( "image " + imageFilePath + " loaded"); setImage( origImage ); instanceRotation = original.getRotated(); double rot = photo.getPrefRotation() - instanceRotation; imageView.setRotation( rot ); imageView.setCrop( photo.getCropBounds() ); } }
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering)
public DelegatedQueryExecutor(Storage<S> rootStorage, QueryExecutor<S> executor)
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query;
this(rootStorage, (executor = check(executor)).getFilter(), executor.getOrdering());
public DelegatedQueryExecutor(Storage<S> rootStorage, Filter<S> filter, OrderingList<S> ordering) throws FetchException { check(rootStorage); Query<S> query; if (filter == null) { query = rootStorage.query(); } else { query = rootStorage.query(filter); } if (ordering == null) { ordering = OrderingList.emptyList(); } else if (ordering.size() > 0) { query = query.orderBy(ordering.asStringArray()); } mFilter = filter; mOrdering = ordering; mQuery = query; }
ChainedProperty<B> bToAProperty,
Class<B> bType, String bToAProperty,
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
(repo, bToAProperty, aExecutor.getStorableType());
(repo, bType, bToAProperty, aExecutor.getStorableType());
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null);
mBFilter = aFilter.accept(new FilterTransformer(bType, bToAProperty), null);
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor);
mBOrdering = transformOrdering(bType, bToAProperty, aExecutor);
public JoinedQueryExecutor(Repository repo, ChainedProperty<B> bToAProperty, QueryExecutor<A> aExecutor) throws SupportException, FetchException, RepositoryException { mFactory = new JoinedCursorFactory<A, B> (repo, bToAProperty, aExecutor.getStorableType()); mAExecutor = aExecutor; Filter<A> aFilter = aExecutor.getFilter(); mAFilterValues = aFilter.initialFilterValues(); mBFilter = aFilter.accept(new FilterTransformer(bToAProperty), null); mBOrdering = transformOrdering(bToAProperty.getPrimeProperty().getEnclosingType(), bToAProperty.toString(), aExecutor); }
MBeanHome home = findExternal(config.getURL(), config.getUsername(), config.getPassword()); return new WLServerConnection(home.getMBeanServer());
Hashtable<String, Object> props = new Hashtable<String, Object>(); props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(Context.PROVIDER_URL, config.getURL()); props.put(Context.SECURITY_PRINCIPAL, config.getUsername()); props.put(Context.SECURITY_CREDENTIALS, config.getPassword()); Context ctx = new InitialContext(props); MBeanHome home = (MBeanHome) ctx.lookup(MBeanHome.JNDI_NAME + "." + "localhome"); return new WLServerConnection(home.getMBeanServer(), ctx);
public ServerConnection getServerConnection(ApplicationConfig config) throws ConnectionFailedException { try { MBeanHome home = findExternal(config.getURL(), config.getUsername(), config.getPassword()); return new WLServerConnection(home.getMBeanServer()); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
public WLServerConnection(MBeanServer mbeanServer){
public WLServerConnection(MBeanServer mbeanServer, Context ctx){
public WLServerConnection(MBeanServer mbeanServer){ super(mbeanServer, MBeanServer.class); assert mbeanServer != null; this.mbeanServer = (RemoteMBeanServer)mbeanServer; }
this.ctx = ctx;
public WLServerConnection(MBeanServer mbeanServer){ super(mbeanServer, MBeanServer.class); assert mbeanServer != null; this.mbeanServer = (RemoteMBeanServer)mbeanServer; }
super(rmiAdaptor, RMIAdaptor.class);
public JBossServerConnection(RMIAdaptor rmiAdaptor) { assert rmiAdaptor != null; this.rmiAdaptor = rmiAdaptor; }
registerTag( "tableLayout", TableLayoutTag.class ); registerTag( "tr", TrTag.class ); registerTag( "td", TdTag.class ); registerTag( "gridBagLayout", GridBagLayoutTag.class ); registerTag( "gbc", GbcTag.class );
public SwingTagLibrary() { registerTag( "action", ActionTag.class ); registerTag( "font", FontTag.class ); registerTag( "windowListener", WindowListenerTag.class ); // the border tags... registerTag( "titledBorder", TitledBorderTag.class ); // the layout tags... }
return new ComponentTag(factory);
if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); }
public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = super.createTagScript(name, attributes); if ( answer == null ) { final Factory factory = getFactory( name ); if ( factory != null ) { return new DynaTagScript( new TagFactory() { public Tag createTag() throws Exception { return new ComponentTag(factory); } } ); } } return answer; }
return new ComponentTag(factory);
if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); }
public Tag createTag() throws Exception { return new ComponentTag(factory); }
public DynaTagScript(TagFactory tagFactory) { super(tagFactory);
public DynaTagScript() {
public DynaTagScript(TagFactory tagFactory) { super(tagFactory); }
ArchitectSession sess = ArchitectSession.getInstance();
ArchitectSession sess = ArchitectSessionImpl.getInstance();
public void testJDBCClassLoader() throws Exception { // Side effect is to load my prefs; needed to avoid having to manually add jar to session. ArchitectFrame.getMainInstance(); ArchitectSession sess = ArchitectSession.getInstance(); JDBCClassLoader cl = sess.getJDBCClassLoader(); System.out.println("If this throws a ClassNotFoundException, update your Architect Preferences to include the PostGreSQL driver jar"); Class clazz = cl.findClass(PGSQL_DRIVER); // If we get here, this test has passed. assertNotNull("Loaded JDBC class %s%n", clazz); }
public JDBCClassLoader getJDBCClassLoader() { return jdbcClassLoader; }
public JDBCClassLoader getJDBCClassLoader();
public JDBCClassLoader getJDBCClassLoader() { return jdbcClassLoader; }
ex.printStackTrace();
logger.error("Error listening to added object", ex);
public void dbChildrenInserted(SQLObjectEvent e) { try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { listenToSQLObjectAndChildren(newEventSources[i]); } } catch (ArchitectException ex) { ex.printStackTrace(); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); }
ex.printStackTrace();
logger.error("Error unlistening to removed object", ex);
public void dbChildrenRemoved(SQLObjectEvent e) { try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { unlistenToSQLObjectAndChildren(oldEventSources[i]); } } catch (ArchitectException ex) { ex.printStackTrace(); } TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); }
logger.debug("dbObjectChanged SQLObjectEvent: "+e);
public void dbObjectChanged(SQLObjectEvent e) { SQLObject source = e.getSQLSource(); if (e.getPropertyName().equals("shortDisplayName")) { fireTreeNodesChanged(new TreeModelEvent(this, getPathToNode(source))); } else { logger.info("Ignoring dbObjectChanged "+e.getSQLSource().getName()+"."+e.getPropertyName()); } }
logger.debug("Sent a copy");
protected void fireTreeNodesRemoved(TreeModelEvent e) { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeNodesRemoved(e); } }
public static SQLObject[] getPathToNode(SQLObject node) {
public SQLObject[] getPathToNode(SQLObject node) {
public static SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); while (node != null) { path.add(0, node); node = node.getParent(); } return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
path.add(0, root);
public static SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); while (node != null) { path.add(0, node); node = node.getParent(); } return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
if (o.isPopulated()) {
if (o.isPopulated() && o.allowsChildren()) {
protected void listenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.addSQLObjectListener(this); if (o.isPopulated()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { listenToSQLObjectAndChildren((SQLObject) it.next()); } } }
if (o.isPopulated()) {
if (o.isPopulated() && o.allowsChildren()) {
protected void unlistenToSQLObjectAndChildren(SQLObject o) throws ArchitectException { o.removeSQLObjectListener(this); if (o.isPopulated()) { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { SQLObject ob = (SQLObject) it.next(); unlistenToSQLObjectAndChildren(ob); } } }
String name = file.getName(); String[] inputs = {null,null,name};
String fullName = file.getParent()+File.separator+file.getName(); String[] inputs = {null,null,fullName};
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("Filter")){ chromChoice = (String)chromChooser.getSelectedItem(); if (chromStart.getText().equals("")){ startPos = -1; }else{ startPos = (Long.parseLong(chromStart.getText()))*1000; } if (chromEnd.getText().equals("")){ endPos = -1; }else{ endPos = (Long.parseLong(chromEnd.getText()))*1000; } if (startPos > endPos){ JOptionPane.showMessageDialog(this.getParent(), "End position must be greater then start position.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (chiField.getText().equals("")){ chisq = -1; }else{ chisq = Double.parseDouble(chiField.getText()); } if (pvalChooser.getSelectedIndex() == 0){ pval = -1; }else if (pvalChooser.getSelectedIndex() == 1){ pval = .01; }else if (pvalChooser.getSelectedIndex() == 2){ pval = .001; }else if (pvalChooser.getSelectedIndex() == 3){ pval = .0001; }else if (pvalChooser.getSelectedIndex() == 4){ pval = .00001; } doFilters(); }else if (command.equals("generic filter")){ if (genericChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please select a column to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } columnChoice = (String)genericChooser.getSelectedItem(); if (signChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(this.getParent(), "Please choose >=, <=, or =.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } signChoice = (String)signChooser.getSelectedItem(); if (valueField.getText().equals("")){ JOptionPane.showMessageDialog(this.getParent(), "Please enter a value to filter on.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } value = valueField.getText(); doGenericFilter(); }else if (command.equals("top filter")){ numResults = Integer.parseInt(topField.getText()); doTopFilter(); }else if (command.equals("Reset Filters")){ clearFilters(); }else if (command.equals("Load Additional Results")){ HaploView.fc.setSelectedFile(new File("")); int returned = HaploView.fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = HaploView.fc.getSelectedFile(); String name = file.getName(); String[] inputs = {null,null,name}; hv.readWGA(inputs); }else if (command.equals("Go to Selected Region")){ gotoRegion(); } }
}else{ genericPass = true;
public void filterAll(String chr, int start, int end, String column, String s, String value){ resetFilters(); int rows = getRowCount(); Vector newFiltered = new Vector(); boolean chromPass = false; boolean genericPass = false; long realStart = start*1000; long realEnd = end*1000; int col = -1; for (int i = 0; i < rows; i++){ if (!(chr.equals(""))){ if (((String)getValueAt(i,1)).equalsIgnoreCase(chr)){ if ((((Long)getValueAt(i,3)).longValue() >= realStart) || (start == -1)){ if ((((Long)getValueAt(i,3)).longValue() <= realEnd) || (end == -1)){ chromPass = true; } } } }else{ chromPass = true; } if (column != null && s != null && value != null){ double rowVal; double val = 0; String stringVal = null; try{ val = Double.parseDouble(value); }catch (NumberFormatException nfe){ stringVal = value; } if (col == -1){ for (int j = 0; j < columnNames.size(); j++){ if(column.equalsIgnoreCase((String)columnNames.get(j))){ col = j; break; } } } if (getValueAt(i,col) != null){ if (stringVal != null){ if (((String)getValueAt(i,col)).equalsIgnoreCase(stringVal)){ genericPass = true; } }else{ try{ rowVal = ((Double)getValueAt(i,col)).doubleValue(); }catch (ClassCastException cce){ rowVal = Double.NaN; } if (s.equals(">=")){ if (rowVal >= val){ genericPass = true; } }else if (s.equals("<=")){ if (rowVal <= val){ genericPass = true; } }else{ if (rowVal == val){ genericPass = true; } } } }else{ genericPass = true; } }else{ genericPass = true; } if (chromPass && genericPass){ newFiltered.add(new Integer(i)); } chromPass = false; genericPass = false; } filtered = newFiltered; }
Method method = taskClass.getMethod( methodName, parameterTypes );
Method method = MethodUtils.getAccessibleMethod( taskClass, methodName, parameterTypes );
public void doTag(XMLOutput output) throws Exception { TaskSource tag = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Object task = tag.getTaskObject(); Object dataType = getDataType(); // now we need to configure the task with the data type // first try setting a property on the DynaBean wrapper of the task DynaBean dynaBean = tag.getDynaBean(); DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty dynaProperty = dynaClass.getDynaProperty(name); if ( dynaProperty != null ) { // lets set the bean property dynaBean.set( name, dataType ); } else { // lets invoke the addFoo() method instead String methodName = "add" + name.substring(0,1).toUpperCase() + name.substring(1); Class taskClass = task.getClass(); Class[] parameterTypes = new Class[] { dataType.getClass() }; Method method = taskClass.getMethod( methodName, parameterTypes ); if ( method == null ) { throw new JellyException( "Cannot add dataType: " + dataType + " to Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object[] parameters = new Object[] { dataType }; method.invoke( task, parameters ); } // run the body first to configure any nested DataType instances getBody().run(context, output); }
tag.setContext(context);
public void run(JellyContext context, XMLOutput output) throws Exception { // 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 }; method.invoke(tag, arguments); } tag.setContext(context); tag.doTag(output); }
public TagScript(TagFactory tagFactory) { this.tagFactory = tagFactory;
public TagScript() {
public TagScript(TagFactory tagFactory) { this.tagFactory = tagFactory; }
finally { if ( ! context.isCacheTags() ) { clearTag(); } }
public void run(JellyContext context, XMLOutput output) throws JellyTagException { if ( ! context.isCacheTags() ) { clearTag(); } try { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); if ( tag instanceof DynaTag ) { DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Class type = dynaTag.getAttributeType(name); Object value = null; if (type != null && type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluateRecurse(context); } dynaTag.setAttribute(name, value); } } else { // treat the tag as a bean DynaBean dynaBean = new ConvertingWrapDynaBean( tag ); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); DynaProperty property = dynaBean.getDynaClass().getDynaProperty(name); if (property == null) { throw new JellyException("This tag does not understand the '" + name + "' attribute" ); } Class type = property.getType(); Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluateRecurse(context); } dynaBean.set(name, value); } } tag.doTag(output); } catch (JellyTagException e) { handleException(e); } catch (JellyException e) { handleException(e); } catch (RuntimeException e) { handleException(e); } catch (Error e) { /* * Not sure if we should be converting errors to exceptions, * but not trivial to remove because JUnit tags throw * Errors in the normal course of operation. Hmm... */ handleException(e); } }
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE);
public TablePane(TablePane tp, PlayPenContentPane parent) { super(parent); this.model = tp.model; this.selectionListeners = new ArrayList<SelectionListener>(); this.dtl = new TablePaneDropListener(this); this.margin = (Insets) tp.margin.clone(); this.columnSelection = new ArrayList<Boolean>(tp.columnSelection); this.columnHighlight = new HashMap<SQLColumn,List<Color>>(tp.columnHighlight); try {
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
dtl = new TablePaneDropListener(this); updateUI();
PlayPenComponentUI newUi = tp.getUI().getClass().newInstance(); newUi.installUI(this); setUI(newUi); } catch (InstantiationException e) { throw new RuntimeException("Woops, couldn't invoke no-args constructor of "+tp.getUI().getClass().getName()); } catch (IllegalAccessException e) { throw new RuntimeException("Woops, couldn't access no-args constructor of "+tp.getUI().getClass().getName()); } this.insertionPoint = tp.insertionPoint; this.draggingColumn = tp.draggingColumn; this.selected = false;
public TablePane(SQLTable m, PlayPen parentPP) { super(parentPP.getPlayPenContentPane()); setModel(m); setOpaque(true); setInsertionPoint(COLUMN_INDEX_NONE); //dt = new DropTarget(parentPP, new TablePaneDropListener(this)); dtl = new TablePaneDropListener(this); updateUI(); }
public JellyAssertionFailedError(String message) { super(message);
public JellyAssertionFailedError() {
public JellyAssertionFailedError(String message) { super(message); }
JPanel buildPanel = new JPanel(); buildPanel.add(new JLabel("Genome build: ")); String[]b ={"34","35"}; buildBox = new JComboBox(b); buildBox.setSelectedIndex(1); buildPanel.add(buildBox); contents.add(buildPanel);
public GBrowseDialog(HaploView h, String title){ super (h,title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel chromPanel = new JPanel(); chromPanel.add(new JLabel("Chromosome")); String[] c = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "X", "Y"}; cbox = new JComboBox(c); if (Chromosome.getDataChrom() != null){ String which = Chromosome.getDataChrom().substring(3); for (int i = 0; i < c.length; i++){ if (which.equals(c[i])){ cbox.setSelectedIndex(i); } } } chromPanel.add(cbox); contents.add(chromPanel); JPanel boundsPanel = new JPanel(); boundsPanel.add(new JLabel("from")); minField = new JTextField(Long.toString(Chromosome.getMarker(0).getPosition()), 9); boundsPanel.add(minField); boundsPanel.add(new JLabel(" to")); maxField = new JTextField(Long.toString(Chromosome.getMarker(Chromosome.getSize()-1).getPosition()), 9); boundsPanel.add(maxField); contents.add(boundsPanel); JPanel buttonPanel = new JPanel(); JButton cancelBut = new JButton("Cancel"); cancelBut.addActionListener(this); JButton okBut = new JButton("OK"); okBut.addActionListener(this); buttonPanel.add(okBut); buttonPanel.add(cancelBut); contents.add(buttonPanel); this.getRootPane().setDefaultButton(okBut); contents.add(new JLabel("(Note: this option requires an internet connection)")); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
Chromosome.setDataBuild("ncbi_b"+buildBox.getSelectedItem());
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("OK")){ try{ long minpos = Long.parseLong(minField.getText()); long maxpos = Long.parseLong(maxField.getText()); if (maxpos <= minpos){ throw new HaploViewException("Boundary positions out of order."); } Chromosome.setDataChrom("chr"+cbox.getSelectedItem()); Options.setgBrowseLeft(minpos); Options.setgBrowseRight(maxpos); Options.setShowGBrowse(true); hv.gbEditItem.setEnabled(true); this.dispose(); hv.setCursor(new Cursor(Cursor.WAIT_CURSOR)); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { hv.dPrimeDisplay.computePreferredSize(); if (hv.dPrimeDisplay != null && hv.tabs.getSelectedIndex() == VIEW_D_NUM){ hv.dPrimeDisplay.repaint(); } hv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(this, "Boundary positions formatted incorrectly", "Input Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "Input Error", JOptionPane.ERROR_MESSAGE); } }else if (command.equals("Cancel")){ this.dispose(); } }
if ( ODMG.getODMGImplementation().currentTransaction() != null ) { fail( "Still in transaction" ); }
public void testIndexing() { int n; ExternalVolume v = new ExternalVolume( "extVol", extVolDir.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = settings.getDatabase( "pv_junit" ); db.addVolume( v ); ExtVolIndexer indexer = new ExtVolIndexer( v ); indexer.setTopFolder( topFolder ); TestListener l = new TestListener(); indexer.addIndexerListener( l ); assertEquals( "Indexing not started -> completeness must be 0", 0, indexer.getPercentComplete() ); assertNull( "StartTime must be null before starting", indexer.getStartTime() ); indexer.run(); // Check that all the files can be found PhotoInfo[] photos1 = PhotoInfo.retrieveByOrigHash( hash1 ); assertEquals( "Only 1 photo per picture should be found", 1, photos1.length ); PhotoInfo p1 = photos1[0]; assertEquals( "2 instances should be found in photo 1", 2, p1.getNumInstances() ); PhotoInfo[] photos2 = PhotoInfo.retrieveByOrigHash( hash2 ); assertEquals( "1 photo per picture should be found", 1, photos2.length ); PhotoInfo p2 = photos2[0]; assertEquals( "3 instances should be found in photo 2", 3, p2.getNumInstances() );//// ImageInstance i1 = p1.getInstance( 0 );// assertEquals( i1.getImageFile(), photo1 ); // CHeck that both instrances of p2 can be found boolean found[] = {false, false}; File files[] = {photo2inst1, photo2inst2}; for ( n = 0; n < p2.getNumInstances(); n++ ) { ImageInstance i = p2.getInstance( n ); for ( int m = 0; m < found.length; m++ ) { if ( files[m].equals( i.getImageFile() ) ) { found[m] = true; } } } for ( n = 0; n < found.length; n++ ) { assertTrue( "Photo " + n + " not found", found[n] ); } // Check that the folders have the correct photos PhotoInfo[] photosInTopFolder = { p1, p2 }; assertFolderHasPhotos( topFolder, photosInTopFolder ); PhotoFolder subFolder = topFolder.getSubfolder( 0 ); assertEquals( "Subfolder name not correct", "test", subFolder.getName() ); PhotoInfo[] photosInSubFolder = { p2 }; assertFolderHasPhotos( subFolder, photosInSubFolder ); // Check that the listener was called correctly assertEquals( "Wrong photo count in listener", 2, l.photoCount ); assertEquals( "Wrong photo count in indexer statistics", 2, indexer.getNewPhotoCount() ); assertEquals( "Wrong instance count in listener", 3, l.instanceCount ); assertEquals( "Wrong instance count in indexer statistics", 3, indexer.getNewInstanceCount() ); assertEquals( "Indexing complete 100%", 100, indexer.getPercentComplete() ); assertNotNull( "StartTime still null", indexer.getStartTime() ); // Next, let's make some modifications to the external volume try { // New file File testfile3 = new File( "testfiles", "test3.jpg" ); File f3 = new File( extVolDir, "test3.jpg"); FileUtils.copyFile( testfile3, f3 ); // Replace the test1 file with test3 File f1 = new File ( extVolDir, "test1.jpg" ); FileUtils.copyFile( testfile3, f1 ); // Remove 1 copy of test2 File f2 = new File( extVolDir, "test2.jpg" ); f2.delete(); } catch (IOException ex) { fail( "IOException while altering external volume: " + ex.getMessage() ); } indexer = new ExtVolIndexer( v ); indexer.setTopFolder( topFolder ); l = new TestListener(); indexer.addIndexerListener( l ); assertEquals( "Indexing not started -> completeness must be 0", 0, indexer.getPercentComplete() ); assertNull( "StartTime must be null before starting", indexer.getStartTime() ); indexer.run(); // Check that the folders have the correct photos PhotoInfo[] photos3 = PhotoInfo.retrieveByOrigHash( hash3 ); assertEquals( "1 photo per picture should be found", 1, photos3.length ); PhotoInfo p3 = photos3[0]; PhotoInfo photosInTopFolder2[] = { p3 }; assertFolderHasPhotos( topFolder, photosInTopFolder2 ); assertEquals( "More than 1 subfolder in topFolder", 1, topFolder.getSubfolderCount() ); subFolder = topFolder.getSubfolder( 0 ); assertEquals( "Subfolder name not correct", "test", subFolder.getName() ); PhotoInfo[] photosInSubFolder2 = { p2 }; assertFolderHasPhotos( subFolder, photosInSubFolder2 ); Collection p2folders = p2.getFolders(); assertFalse( "p2 must not be in topFolder", p2folders.contains( topFolder ) ); }
FileInputStream in = new FileInputStream( src ); FileOutputStream out = new FileOutputStream( dst ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close();
FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream( src ); out = new FileOutputStream( dst ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } } catch ( IOException e ) { throw e; } finally { IOException outEx = null; if ( out != null ) { try { out.close(); } catch (IOException ex) { outEx = ex; } } if ( in != null ) { try { in.close(); } catch (IOException ex) { throw ex; } } if ( outEx != null ) { throw outEx; } }
public static void copyFile( File src, File dst ) throws IOException { FileInputStream in = new FileInputStream( src ); FileOutputStream out = new FileOutputStream( dst ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close(); }
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally {
protected void calcHash() { hash = calcHash( imageFile ); if ( instanceType == INSTANCE_TYPE_ORIGINAL && photoUid > 0 ) {
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" );
PhotoInfo p = PhotoInfo.retrievePhotoInfo( photoUid ); if ( p != null ) { p.setOrigInstanceHash( hash ); } } catch (PhotoNotFoundException ex) {
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
return hash;
public static byte[] calcHash( File f ) { FileInputStream is = null; byte hash[] = null; try { is = new FileInputStream( f ); byte readBuffer[] = new byte[4096]; MessageDigest md = MessageDigest.getInstance("MD5"); int bytesRead = -1; while( ( bytesRead = is.read( readBuffer ) ) > 0 ) { md.update( readBuffer, 0, bytesRead ); } hash = md.digest(); } catch (NoSuchAlgorithmException ex) { log.error( "MD5 algorithm not found" ); } catch (FileNotFoundException ex) { log.error( f.getAbsolutePath() + "not found" ); } catch (IOException ex) { log.error( "IOException while calculating hash: " + ex.getMessage() ); } finally { try { is.close(); } catch (IOException ex) { log.error( "Cannot close stream after calculating hash" ); } } return hash; }
cleanupInstances();
public void run() { startTime = new Date(); indexDirectory( volume.getBaseDir(), topFolder, 0, 100 ); notifyListenersIndexingComplete(); }
request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Add Application");
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.canAccess(context.getUser(), ACL_ADD_APPLICATIONS); ApplicationForm appForm = (ApplicationForm)actionForm; ModuleConfig moduleConfig = ModuleRegistry.getModule(appForm.getType()); request.setAttribute(RequestAttributes.META_APP_CONFIG, moduleConfig.getMetaApplicationConfig()); return mapping.findForward(Forwards.SUCCESS); }
File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~");
File backupFile = new File (file.getParent(), file.getName()+"~"); File tempFile = new File (file.getParent(),"tmp___" + file.getName());
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~"); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile; } }
pm.setMillisToDecideToPopup(500);
pm.setMillisToDecideToPopup(0);
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~"); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile; } }
backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile;
boolean fstatus = false; fstatus = backupFile.delete(); logger.debug("deleting backup~ file: " + fstatus); fstatus = file.renameTo(backupFile); logger.debug("renaming current file to backupFile: " + fstatus); fstatus = tempFile.renameTo(file); logger.debug("renaming tempFile to current file: " + fstatus);
public void save(ProgressMonitor pm) throws IOException, ArchitectException { // write to temp file and then rename (this preserves old project file // when there's problems) if (file.exists() && !file.canWrite()) { // write problems with architect file will muck up the save process throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); } File tempFile = new File (file.getParent(),"tmp___" + file.getName()); File backupFile = new File (file.getParent(), file.getName()+"~"); out = new PrintWriter(new BufferedWriter(new FileWriter(tempFile))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; boolean saveOk = false; // use this to determine if save process worked this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); saveOk = true; } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } // do the rename dance if (saveOk) { backupFile.delete(); file.renameTo(backupFile); tempFile.renameTo(file); file = tempFile; } }
Hashtable tagsBySeq = new Hashtable();
Hashtable blockTagsByAllele = new Hashtable();
private void peelBack(Vector tagsToBePeeled){ Hashtable tagsBySeq = new Hashtable(); HashSet snpsInBlockTags = new HashSet(); for (int i = 0; i < tagsToBePeeled.size(); i++){ tagsBySeq.put(((TagSequence)tagsToBePeeled.get(i)).getSequence(), tagsToBePeeled.get(i)); } for (int i = 0; i < tagsToBePeeled.size(); i++){ TagSequence curTag = (TagSequence) tagsToBePeeled.get(i); if (forceInclude.contains(curTag.getSequence()) || snpsInBlockTags.contains(curTag.getSequence())){ continue; } Vector taggedByCurTag = curTag.getTagged(); //a hashset that contains all snps tagged by curtag //and all tag snps in LD with any of them HashSet comprehensiveBlock = new HashSet(); Vector availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } availTagSNPs.remove(curTag.getSequence()); for (int j = 0; j < taggedByCurTag.size(); j++) { SNP snp = (SNP) taggedByCurTag.elementAt(j); comprehensiveBlock.add(snp); HashSet victor = snp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); } alleleCorrelator.phaseAndCache(comprehensiveBlock); Hashtable bestPredictor = new Hashtable(); boolean peelSuccessful = true; for (int k = 0; k < taggedByCurTag.size(); k++){ //look to see if we can find a predictor for each thing curTag tags SNP thisTaggable = (SNP) taggedByCurTag.get(k); Vector victor = (Vector) tags.clone(); victor.remove(curTag); Vector potentialTests = generateTests(thisTaggable, victor); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), thisTaggable); if (lc.getRsq() >= minRSquared){ if (bestPredictor.containsKey(thisTaggable)){ if (lc.getRsq() > ((LocusCorrelation)bestPredictor.get(thisTaggable)).getRsq()){ bestPredictor.put(thisTaggable,lc); } }else{ bestPredictor.put(thisTaggable,lc); } } } if (thisTaggable.getTags().size() == 1 && !bestPredictor.containsKey(thisTaggable)){ peelSuccessful = false; break; } } if (peelSuccessful){ for (int k = 0; k < taggedByCurTag.size(); k++){ SNP thisTaggable = (SNP) taggedByCurTag.get(k); if (bestPredictor.containsKey(thisTaggable)){ Allele bpAllele = ((LocusCorrelation)bestPredictor.get(thisTaggable)).getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (tagsBySeq.containsKey(bpAllele)){ thisTaggable.addTag((TagSequence)tagsBySeq.get(bpAllele)); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(thisTaggable); tags.add(ts); tagsBySeq.put(bpAllele,ts); } } thisTaggable.removeTag(curTag); } tags.remove(curTag); } } }
for (int i = 0; i < tagsToBePeeled.size(); i++){ tagsBySeq.put(((TagSequence)tagsToBePeeled.get(i)).getSequence(), tagsToBePeeled.get(i)); }
private void peelBack(Vector tagsToBePeeled){ Hashtable tagsBySeq = new Hashtable(); HashSet snpsInBlockTags = new HashSet(); for (int i = 0; i < tagsToBePeeled.size(); i++){ tagsBySeq.put(((TagSequence)tagsToBePeeled.get(i)).getSequence(), tagsToBePeeled.get(i)); } for (int i = 0; i < tagsToBePeeled.size(); i++){ TagSequence curTag = (TagSequence) tagsToBePeeled.get(i); if (forceInclude.contains(curTag.getSequence()) || snpsInBlockTags.contains(curTag.getSequence())){ continue; } Vector taggedByCurTag = curTag.getTagged(); //a hashset that contains all snps tagged by curtag //and all tag snps in LD with any of them HashSet comprehensiveBlock = new HashSet(); Vector availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } availTagSNPs.remove(curTag.getSequence()); for (int j = 0; j < taggedByCurTag.size(); j++) { SNP snp = (SNP) taggedByCurTag.elementAt(j); comprehensiveBlock.add(snp); HashSet victor = snp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); } alleleCorrelator.phaseAndCache(comprehensiveBlock); Hashtable bestPredictor = new Hashtable(); boolean peelSuccessful = true; for (int k = 0; k < taggedByCurTag.size(); k++){ //look to see if we can find a predictor for each thing curTag tags SNP thisTaggable = (SNP) taggedByCurTag.get(k); Vector victor = (Vector) tags.clone(); victor.remove(curTag); Vector potentialTests = generateTests(thisTaggable, victor); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), thisTaggable); if (lc.getRsq() >= minRSquared){ if (bestPredictor.containsKey(thisTaggable)){ if (lc.getRsq() > ((LocusCorrelation)bestPredictor.get(thisTaggable)).getRsq()){ bestPredictor.put(thisTaggable,lc); } }else{ bestPredictor.put(thisTaggable,lc); } } } if (thisTaggable.getTags().size() == 1 && !bestPredictor.containsKey(thisTaggable)){ peelSuccessful = false; break; } } if (peelSuccessful){ for (int k = 0; k < taggedByCurTag.size(); k++){ SNP thisTaggable = (SNP) taggedByCurTag.get(k); if (bestPredictor.containsKey(thisTaggable)){ Allele bpAllele = ((LocusCorrelation)bestPredictor.get(thisTaggable)).getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (tagsBySeq.containsKey(bpAllele)){ thisTaggable.addTag((TagSequence)tagsBySeq.get(bpAllele)); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(thisTaggable); tags.add(ts); tagsBySeq.put(bpAllele,ts); } } thisTaggable.removeTag(curTag); } tags.remove(curTag); } } }
if (tagsBySeq.containsKey(bpAllele)){ thisTaggable.addTag((TagSequence)tagsBySeq.get(bpAllele));
if (blockTagsByAllele.containsKey(bpAllele)){ TagSequence ts = (TagSequence)blockTagsByAllele.get(bpAllele); ts.addTagged(thisTaggable);
private void peelBack(Vector tagsToBePeeled){ Hashtable tagsBySeq = new Hashtable(); HashSet snpsInBlockTags = new HashSet(); for (int i = 0; i < tagsToBePeeled.size(); i++){ tagsBySeq.put(((TagSequence)tagsToBePeeled.get(i)).getSequence(), tagsToBePeeled.get(i)); } for (int i = 0; i < tagsToBePeeled.size(); i++){ TagSequence curTag = (TagSequence) tagsToBePeeled.get(i); if (forceInclude.contains(curTag.getSequence()) || snpsInBlockTags.contains(curTag.getSequence())){ continue; } Vector taggedByCurTag = curTag.getTagged(); //a hashset that contains all snps tagged by curtag //and all tag snps in LD with any of them HashSet comprehensiveBlock = new HashSet(); Vector availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } availTagSNPs.remove(curTag.getSequence()); for (int j = 0; j < taggedByCurTag.size(); j++) { SNP snp = (SNP) taggedByCurTag.elementAt(j); comprehensiveBlock.add(snp); HashSet victor = snp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); } alleleCorrelator.phaseAndCache(comprehensiveBlock); Hashtable bestPredictor = new Hashtable(); boolean peelSuccessful = true; for (int k = 0; k < taggedByCurTag.size(); k++){ //look to see if we can find a predictor for each thing curTag tags SNP thisTaggable = (SNP) taggedByCurTag.get(k); Vector victor = (Vector) tags.clone(); victor.remove(curTag); Vector potentialTests = generateTests(thisTaggable, victor); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), thisTaggable); if (lc.getRsq() >= minRSquared){ if (bestPredictor.containsKey(thisTaggable)){ if (lc.getRsq() > ((LocusCorrelation)bestPredictor.get(thisTaggable)).getRsq()){ bestPredictor.put(thisTaggable,lc); } }else{ bestPredictor.put(thisTaggable,lc); } } } if (thisTaggable.getTags().size() == 1 && !bestPredictor.containsKey(thisTaggable)){ peelSuccessful = false; break; } } if (peelSuccessful){ for (int k = 0; k < taggedByCurTag.size(); k++){ SNP thisTaggable = (SNP) taggedByCurTag.get(k); if (bestPredictor.containsKey(thisTaggable)){ Allele bpAllele = ((LocusCorrelation)bestPredictor.get(thisTaggable)).getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (tagsBySeq.containsKey(bpAllele)){ thisTaggable.addTag((TagSequence)tagsBySeq.get(bpAllele)); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(thisTaggable); tags.add(ts); tagsBySeq.put(bpAllele,ts); } } thisTaggable.removeTag(curTag); } tags.remove(curTag); } } }
tagsBySeq.put(bpAllele,ts);
blockTagsByAllele.put(bpAllele,ts);
private void peelBack(Vector tagsToBePeeled){ Hashtable tagsBySeq = new Hashtable(); HashSet snpsInBlockTags = new HashSet(); for (int i = 0; i < tagsToBePeeled.size(); i++){ tagsBySeq.put(((TagSequence)tagsToBePeeled.get(i)).getSequence(), tagsToBePeeled.get(i)); } for (int i = 0; i < tagsToBePeeled.size(); i++){ TagSequence curTag = (TagSequence) tagsToBePeeled.get(i); if (forceInclude.contains(curTag.getSequence()) || snpsInBlockTags.contains(curTag.getSequence())){ continue; } Vector taggedByCurTag = curTag.getTagged(); //a hashset that contains all snps tagged by curtag //and all tag snps in LD with any of them HashSet comprehensiveBlock = new HashSet(); Vector availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } availTagSNPs.remove(curTag.getSequence()); for (int j = 0; j < taggedByCurTag.size(); j++) { SNP snp = (SNP) taggedByCurTag.elementAt(j); comprehensiveBlock.add(snp); HashSet victor = snp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); } alleleCorrelator.phaseAndCache(comprehensiveBlock); Hashtable bestPredictor = new Hashtable(); boolean peelSuccessful = true; for (int k = 0; k < taggedByCurTag.size(); k++){ //look to see if we can find a predictor for each thing curTag tags SNP thisTaggable = (SNP) taggedByCurTag.get(k); Vector victor = (Vector) tags.clone(); victor.remove(curTag); Vector potentialTests = generateTests(thisTaggable, victor); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), thisTaggable); if (lc.getRsq() >= minRSquared){ if (bestPredictor.containsKey(thisTaggable)){ if (lc.getRsq() > ((LocusCorrelation)bestPredictor.get(thisTaggable)).getRsq()){ bestPredictor.put(thisTaggable,lc); } }else{ bestPredictor.put(thisTaggable,lc); } } } if (thisTaggable.getTags().size() == 1 && !bestPredictor.containsKey(thisTaggable)){ peelSuccessful = false; break; } } if (peelSuccessful){ for (int k = 0; k < taggedByCurTag.size(); k++){ SNP thisTaggable = (SNP) taggedByCurTag.get(k); if (bestPredictor.containsKey(thisTaggable)){ Allele bpAllele = ((LocusCorrelation)bestPredictor.get(thisTaggable)).getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (tagsBySeq.containsKey(bpAllele)){ thisTaggable.addTag((TagSequence)tagsBySeq.get(bpAllele)); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(thisTaggable); tags.add(ts); tagsBySeq.put(bpAllele,ts); } } thisTaggable.removeTag(curTag); } tags.remove(curTag); } } }
i.calcHash();
public static ImageInstance create ( VolumeBase vol, File imgFile ) { ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance i = new ImageInstance(); i.volume = vol; i.volumeId = vol.getName(); i.imageFile = imgFile; i.fileSize = imgFile.length(); i.mtime = imgFile.lastModified(); i.fname = vol.mapFileToVolumeRelativeName( imgFile ); txw.lock( i, Transaction.WRITE ); i.calcHash(); // Read the rest of fields from the image file try { i.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } i.checkTime = new java.util.Date(); txw.commit(); return i; }
i.calcHash();
public static ImageInstance create ( VolumeBase vol, File imgFile ) { ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance i = new ImageInstance(); i.volume = vol; i.volumeId = vol.getName(); i.imageFile = imgFile; i.fileSize = imgFile.length(); i.mtime = imgFile.lastModified(); i.fname = vol.mapFileToVolumeRelativeName( imgFile ); txw.lock( i, Transaction.WRITE ); i.calcHash(); // Read the rest of fields from the image file try { i.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } i.checkTime = new java.util.Date(); txw.commit(); return i; }
ImageInputStream iis = ImageIO.createImageInputStream( imageFile ); if ( iis != null ) { reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); iis.close();
ImageInputStream iis = null; try { iis = ImageIO.createImageInputStream( imageFile ); if ( iis != null ) { reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); reader.dispose(); } } catch (IOException ex) { log.debug( "Exception in readImageFile: " + ex.getMessage() ); throw ex; } finally { if ( iis != null ) { try { iis.close(); } catch (IOException ex) { log.warn( "Cannot close image stream: " + ex.getMessage() ); } }
protected void readImageFile() throws IOException { // Find the JPEG image reader // TODO: THis shoud decode also other readers from fname Iterator readers = ImageIO.getImageReadersByFormatName("jpg"); ImageReader reader = (ImageReader)readers.next(); ImageInputStream iis = ImageIO.createImageInputStream( imageFile ); if ( iis != null ) { reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); iis.close(); } }
if(theData.getPedFile().isBogusParents()) {
if(type != HAPS && theData.getPedFile().isBogusParents()) {
void readGenotypes(String[] inputOptions, int type){ //input is a 2 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); try { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 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(ASSOC_NONE); } theData = new HaploData(); Vector result = null; if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ result = theData.linkageToChrom(inFile, type); } if(theData.getPedFile().isBogusParents()) { JOptionPane.showMessageDialog(this, "One or more individuals in the file reference non-existent parents.\nThese references have been ignored.", "File Error", JOptionPane.ERROR_MESSAGE); } //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); //initialize realIndex Chromosome.doFilter(Chromosome.getUnfilteredSize()); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(this); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); boolean[] markerResults = new boolean[result.size()]; for (int i = 0; i < result.size(); i++){ if (((MarkerResult)result.get(i)).getRating() > 0 && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2){ markerResults[i] = true; }else{ markerResults[i] = false; } } //set up the indexing to take into account skipped markers. Chromosome.doFilter(markerResults); } //let's start the math final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first 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)); 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() != ASSOC_NONE) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; JTabbedPane metaAssoc = new JTabbedPane(); try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } metaAssoc.add("Single Marker", tdtPanel); HaploAssocPanel htp = new HaploAssocPanel(theData.getHaplotypes()); metaAssoc.add("Haplotypes", htp); tabs.addTab("Association Results", metaAssoc); 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); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }
int countsOrRatios = SHOW_COUNTS;
int countsOrRatios = SHOW_HAP_COUNTS;
public void makeTable(Haplotype[][] haps) { this.removeAll(); initialHaplotypeDisplayThreshold = Options.getHaplotypeDisplayThreshold(); Vector colNames = new Vector(); colNames.add("Haplotype"); colNames.add("Freq."); if (Options.getAssocTest() == ASSOC_TRIO){ colNames.add("T:U"); }else{ colNames.add("Case, Control Ratios"); } colNames.add("Chi Squared"); colNames.add("p value"); HaplotypeAssociationNode root = new HaplotypeAssociationNode("Haplotype Associations"); String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; for(int i=0;i< haps.length;i++){ Haplotype[] curBlock = haps[i]; HaplotypeAssociationNode han = new HaplotypeAssociationNode("Block " + (i+1)); double chisq; for(int j=0;j< curBlock.length; j++) { if (curBlock[j].getPercentage()*100 >= Options.getHaplotypeDisplayThreshold()){ int[] genotypes = curBlock[j].getGeno(); StringBuffer curHap = new StringBuffer(genotypes.length); for(int k=0;k<genotypes.length;k++) { curHap.append(alleleCodes[genotypes[k]]); } double[][] counts; if(Options.getAssocTest() == ASSOC_TRIO) { counts = new double[1][2]; counts[0][0] = curBlock[j].getTransCount(); counts[0][1] = curBlock[j].getUntransCount(); } else { counts = new double[2][2]; counts[0][0] = curBlock[j].getCaseFreq(); counts[1][0] = curBlock[j].getControlFreq(); double caseSum=0; double controlSum=0; for (int k=0; k < curBlock.length; k++){ if (j!=k){ caseSum += curBlock[k].getCaseFreq(); controlSum += curBlock[k].getControlFreq(); } } counts[0][1] = caseSum; counts[1][1] = controlSum; } chisq = getChiSq(counts); han.add(new HaplotypeAssociationNode(curHap.toString(),curBlock[j].getPercentage(),counts,chisq,getPValue(chisq))); } } root.add(han); } int countsOrRatios = SHOW_COUNTS; if(jtt != null) { //if were just updating the table, then we want to retain the current status of countsOrRatios HaplotypeAssociationModel ham = (HaplotypeAssociationModel) jtt.getTree().getModel(); countsOrRatios = ham.getCountsOrRatios(); } jtt = new JTreeTable(new HaplotypeAssociationModel(colNames, root)); ((HaplotypeAssociationModel)(jtt.getTree().getModel())).setCountsOrRatios(countsOrRatios); jtt.getColumnModel().getColumn(0).setPreferredWidth(200); jtt.getColumnModel().getColumn(1).setPreferredWidth(50); //we need more space for the CC counts in the third column if(Options.getAssocTest() == ASSOC_CC) { jtt.getColumnModel().getColumn(2).setPreferredWidth(200); jtt.getColumnModel().getColumn(3).setPreferredWidth(75); jtt.getColumnModel().getColumn(4).setPreferredWidth(75); } else { jtt.getColumnModel().getColumn(2).setPreferredWidth(150); jtt.getColumnModel().getColumn(3).setPreferredWidth(100); jtt.getColumnModel().getColumn(4).setPreferredWidth(100); } jtt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); Font monoFont = new Font("Monospaced",Font.PLAIN,12); jtt.setFont(monoFont); JTree theTree = jtt.getTree(); theTree.setFont(monoFont); DefaultTreeCellRenderer r = new DefaultTreeCellRenderer(); r.setLeafIcon(null); r.setOpenIcon(null); r.setClosedIcon(null); theTree.setCellRenderer(r); jtt.setPreferredScrollableViewportSize(new Dimension(600,jtt.getPreferredScrollableViewportSize().height)); JScrollPane treeScroller = new JScrollPane(jtt); add(treeScroller); if(Options.getAssocTest() == ASSOC_CC) { JRadioButton countsButton = new JRadioButton("Show CC counts"); JRadioButton ratiosButton = new JRadioButton("Show CC ratios"); ButtonGroup bg = new ButtonGroup(); bg.add(countsButton); bg.add(ratiosButton); countsButton.addActionListener(this); ratiosButton.addActionListener(this); JPanel butPan = new JPanel(); butPan.add(countsButton); butPan.add(ratiosButton); add(butPan); if(countsOrRatios == SHOW_RATIOS) { ratiosButton.setSelected(true); }else{ countsButton.setSelected(true); } } }
JRadioButton ratiosButton = new JRadioButton("Show CC ratios");
JRadioButton ratiosButton = new JRadioButton("Show CC frequencies");
public void makeTable(Haplotype[][] haps) { this.removeAll(); initialHaplotypeDisplayThreshold = Options.getHaplotypeDisplayThreshold(); Vector colNames = new Vector(); colNames.add("Haplotype"); colNames.add("Freq."); if (Options.getAssocTest() == ASSOC_TRIO){ colNames.add("T:U"); }else{ colNames.add("Case, Control Ratios"); } colNames.add("Chi Squared"); colNames.add("p value"); HaplotypeAssociationNode root = new HaplotypeAssociationNode("Haplotype Associations"); String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; for(int i=0;i< haps.length;i++){ Haplotype[] curBlock = haps[i]; HaplotypeAssociationNode han = new HaplotypeAssociationNode("Block " + (i+1)); double chisq; for(int j=0;j< curBlock.length; j++) { if (curBlock[j].getPercentage()*100 >= Options.getHaplotypeDisplayThreshold()){ int[] genotypes = curBlock[j].getGeno(); StringBuffer curHap = new StringBuffer(genotypes.length); for(int k=0;k<genotypes.length;k++) { curHap.append(alleleCodes[genotypes[k]]); } double[][] counts; if(Options.getAssocTest() == ASSOC_TRIO) { counts = new double[1][2]; counts[0][0] = curBlock[j].getTransCount(); counts[0][1] = curBlock[j].getUntransCount(); } else { counts = new double[2][2]; counts[0][0] = curBlock[j].getCaseFreq(); counts[1][0] = curBlock[j].getControlFreq(); double caseSum=0; double controlSum=0; for (int k=0; k < curBlock.length; k++){ if (j!=k){ caseSum += curBlock[k].getCaseFreq(); controlSum += curBlock[k].getControlFreq(); } } counts[0][1] = caseSum; counts[1][1] = controlSum; } chisq = getChiSq(counts); han.add(new HaplotypeAssociationNode(curHap.toString(),curBlock[j].getPercentage(),counts,chisq,getPValue(chisq))); } } root.add(han); } int countsOrRatios = SHOW_COUNTS; if(jtt != null) { //if were just updating the table, then we want to retain the current status of countsOrRatios HaplotypeAssociationModel ham = (HaplotypeAssociationModel) jtt.getTree().getModel(); countsOrRatios = ham.getCountsOrRatios(); } jtt = new JTreeTable(new HaplotypeAssociationModel(colNames, root)); ((HaplotypeAssociationModel)(jtt.getTree().getModel())).setCountsOrRatios(countsOrRatios); jtt.getColumnModel().getColumn(0).setPreferredWidth(200); jtt.getColumnModel().getColumn(1).setPreferredWidth(50); //we need more space for the CC counts in the third column if(Options.getAssocTest() == ASSOC_CC) { jtt.getColumnModel().getColumn(2).setPreferredWidth(200); jtt.getColumnModel().getColumn(3).setPreferredWidth(75); jtt.getColumnModel().getColumn(4).setPreferredWidth(75); } else { jtt.getColumnModel().getColumn(2).setPreferredWidth(150); jtt.getColumnModel().getColumn(3).setPreferredWidth(100); jtt.getColumnModel().getColumn(4).setPreferredWidth(100); } jtt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); Font monoFont = new Font("Monospaced",Font.PLAIN,12); jtt.setFont(monoFont); JTree theTree = jtt.getTree(); theTree.setFont(monoFont); DefaultTreeCellRenderer r = new DefaultTreeCellRenderer(); r.setLeafIcon(null); r.setOpenIcon(null); r.setClosedIcon(null); theTree.setCellRenderer(r); jtt.setPreferredScrollableViewportSize(new Dimension(600,jtt.getPreferredScrollableViewportSize().height)); JScrollPane treeScroller = new JScrollPane(jtt); add(treeScroller); if(Options.getAssocTest() == ASSOC_CC) { JRadioButton countsButton = new JRadioButton("Show CC counts"); JRadioButton ratiosButton = new JRadioButton("Show CC ratios"); ButtonGroup bg = new ButtonGroup(); bg.add(countsButton); bg.add(ratiosButton); countsButton.addActionListener(this); ratiosButton.addActionListener(this); JPanel butPan = new JPanel(); butPan.add(countsButton); butPan.add(ratiosButton); add(butPan); if(countsOrRatios == SHOW_RATIOS) { ratiosButton.setSelected(true); }else{ countsButton.setSelected(true); } } }
if(countsOrRatios == SHOW_RATIOS) {
if(countsOrRatios == SHOW_HAP_RATIOS) {
public void makeTable(Haplotype[][] haps) { this.removeAll(); initialHaplotypeDisplayThreshold = Options.getHaplotypeDisplayThreshold(); Vector colNames = new Vector(); colNames.add("Haplotype"); colNames.add("Freq."); if (Options.getAssocTest() == ASSOC_TRIO){ colNames.add("T:U"); }else{ colNames.add("Case, Control Ratios"); } colNames.add("Chi Squared"); colNames.add("p value"); HaplotypeAssociationNode root = new HaplotypeAssociationNode("Haplotype Associations"); String[] alleleCodes = new String[5]; alleleCodes[0] = "X"; alleleCodes[1] = "A"; alleleCodes[2] = "C"; alleleCodes[3] = "G"; alleleCodes[4] = "T"; for(int i=0;i< haps.length;i++){ Haplotype[] curBlock = haps[i]; HaplotypeAssociationNode han = new HaplotypeAssociationNode("Block " + (i+1)); double chisq; for(int j=0;j< curBlock.length; j++) { if (curBlock[j].getPercentage()*100 >= Options.getHaplotypeDisplayThreshold()){ int[] genotypes = curBlock[j].getGeno(); StringBuffer curHap = new StringBuffer(genotypes.length); for(int k=0;k<genotypes.length;k++) { curHap.append(alleleCodes[genotypes[k]]); } double[][] counts; if(Options.getAssocTest() == ASSOC_TRIO) { counts = new double[1][2]; counts[0][0] = curBlock[j].getTransCount(); counts[0][1] = curBlock[j].getUntransCount(); } else { counts = new double[2][2]; counts[0][0] = curBlock[j].getCaseFreq(); counts[1][0] = curBlock[j].getControlFreq(); double caseSum=0; double controlSum=0; for (int k=0; k < curBlock.length; k++){ if (j!=k){ caseSum += curBlock[k].getCaseFreq(); controlSum += curBlock[k].getControlFreq(); } } counts[0][1] = caseSum; counts[1][1] = controlSum; } chisq = getChiSq(counts); han.add(new HaplotypeAssociationNode(curHap.toString(),curBlock[j].getPercentage(),counts,chisq,getPValue(chisq))); } } root.add(han); } int countsOrRatios = SHOW_COUNTS; if(jtt != null) { //if were just updating the table, then we want to retain the current status of countsOrRatios HaplotypeAssociationModel ham = (HaplotypeAssociationModel) jtt.getTree().getModel(); countsOrRatios = ham.getCountsOrRatios(); } jtt = new JTreeTable(new HaplotypeAssociationModel(colNames, root)); ((HaplotypeAssociationModel)(jtt.getTree().getModel())).setCountsOrRatios(countsOrRatios); jtt.getColumnModel().getColumn(0).setPreferredWidth(200); jtt.getColumnModel().getColumn(1).setPreferredWidth(50); //we need more space for the CC counts in the third column if(Options.getAssocTest() == ASSOC_CC) { jtt.getColumnModel().getColumn(2).setPreferredWidth(200); jtt.getColumnModel().getColumn(3).setPreferredWidth(75); jtt.getColumnModel().getColumn(4).setPreferredWidth(75); } else { jtt.getColumnModel().getColumn(2).setPreferredWidth(150); jtt.getColumnModel().getColumn(3).setPreferredWidth(100); jtt.getColumnModel().getColumn(4).setPreferredWidth(100); } jtt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); Font monoFont = new Font("Monospaced",Font.PLAIN,12); jtt.setFont(monoFont); JTree theTree = jtt.getTree(); theTree.setFont(monoFont); DefaultTreeCellRenderer r = new DefaultTreeCellRenderer(); r.setLeafIcon(null); r.setOpenIcon(null); r.setClosedIcon(null); theTree.setCellRenderer(r); jtt.setPreferredScrollableViewportSize(new Dimension(600,jtt.getPreferredScrollableViewportSize().height)); JScrollPane treeScroller = new JScrollPane(jtt); add(treeScroller); if(Options.getAssocTest() == ASSOC_CC) { JRadioButton countsButton = new JRadioButton("Show CC counts"); JRadioButton ratiosButton = new JRadioButton("Show CC ratios"); ButtonGroup bg = new ButtonGroup(); bg.add(countsButton); bg.add(ratiosButton); countsButton.addActionListener(this); ratiosButton.addActionListener(this); JPanel butPan = new JPanel(); butPan.add(countsButton); butPan.add(ratiosButton); add(butPan); if(countsOrRatios == SHOW_RATIOS) { ratiosButton.setSelected(true); }else{ countsButton.setSelected(true); } } }
tempVect.add(currentResult.getTURatio()); tempVect.add(new Double(currentResult.getChiSq())); tempVect.add(new Double(currentResult.getPValue()));
tempVect.add(currentResult.getTURatio(type)); tempVect.add(new Double(currentResult.getChiSq(type))); tempVect.add(currentResult.getPValue());
public void refreshTable(){ this.removeAll(); Vector tableData = new Vector(); int numRes = Chromosome.getFilteredSize(); for (int i = 0; i < numRes; i++){ Vector tempVect = new Vector(); TDTResult currentResult = (TDTResult)result.get(Chromosome.realIndex[i]); tempVect.add(currentResult.getName()); tempVect.add(currentResult.getTURatio()); tempVect.add(new Double(currentResult.getChiSq())); tempVect.add(new Double(currentResult.getPValue())); tableData.add(tempVect.clone()); } table = new JTable(tableData,tableColumnNames); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
this.setResizable(false);
public GBrowseDialog(HaploView h, String title){ super (h,title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel chromPanel = new JPanel(); chromPanel.add(new JLabel("Chromosome")); String[] c = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "X", "Y"}; cbox = new JComboBox(c); if (Chromosome.getDataChrom() != null){ String which = Chromosome.getDataChrom().substring(3); for (int i = 0; i < c.length; i++){ if (which.equals(c[i])){ cbox.setSelectedIndex(i); } } } chromPanel.add(cbox); contents.add(chromPanel); JPanel boundsPanel = new JPanel(); boundsPanel.add(new JLabel("from")); minField = new JTextField(Long.toString(Chromosome.getMarker(0).getPosition()), 9); boundsPanel.add(minField); boundsPanel.add(new JLabel(" to")); maxField = new JTextField(Long.toString(Chromosome.getMarker(Chromosome.getSize()-1).getPosition()), 9); boundsPanel.add(maxField); contents.add(boundsPanel); JPanel buttonPanel = new JPanel(); JButton cancelBut = new JButton("Cancel"); cancelBut.addActionListener(this); JButton okBut = new JButton("OK"); okBut.addActionListener(this); buttonPanel.add(okBut); buttonPanel.add(cancelBut); contents.add(buttonPanel); contents.add(new JLabel("(Note: this option requires an internet connection)")); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
this.setResizable(false);
public TweakBlockDefsDialog(String title, HaploView h){ super(h, title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel sfsPanel = new JPanel(); sfsPanel.setBorder(new TitledBorder("Gabriel et al.")); sfsPanel.setLayout(new BoxLayout(sfsPanel, BoxLayout.Y_AXIS)); JPanel holdPanel = new JPanel(); holdPanel.add(new JLabel("Confidence interval minima for strong LD:")); JPanel fieldPanel = new JPanel(); fieldPanel.setLayout(new BoxLayout(fieldPanel, BoxLayout.Y_AXIS)); JPanel top = new JPanel(); highLD = new NumberTextField(String.valueOf(FindBlocks.cutHighCI),4, true); top.add(new JLabel("Upper:")); top.add(highLD); fieldPanel.add(top); JPanel bottom = new JPanel(); lowLD = new NumberTextField(String.valueOf(FindBlocks.cutLowCI),4, true); bottom.add(new JLabel("Lower:")); bottom.add(lowLD); fieldPanel.add(bottom); holdPanel.add(fieldPanel); sfsPanel.add(holdPanel); holdPanel = new JPanel(); holdPanel.add(new JLabel("Upper confidence interval maximum for strong recombination:")); highRec = new NumberTextField(String.valueOf(FindBlocks.recHighCI),4,true); holdPanel.add(highRec); sfsPanel.add(holdPanel); holdPanel = new JPanel(); holdPanel.add(new JLabel("Fraction of strong LD in informative comparisons must be at least ")); informFrac = new NumberTextField(String.valueOf(FindBlocks.informFrac),4,true); holdPanel.add(informFrac); sfsPanel.add(holdPanel); holdPanel = new JPanel(); holdPanel.add(new JLabel("Exclude markers below ")); mafCut = new NumberTextField(String.valueOf(FindBlocks.mafThresh),4,true); holdPanel.add(mafCut); holdPanel.add(new JLabel(" MAF.")); sfsPanel.add(holdPanel); JPanel gamPanel = new JPanel(); gamPanel.setBorder(new TitledBorder("4 Gamete Rule")); gamPanel.add(new JLabel("4th gamete must be observed at frequency > ")); gamThresh = new NumberTextField(String.valueOf(FindBlocks.fourGameteCutoff), 5, true); gamPanel.add(gamThresh); JPanel spinePanel = new JPanel(); spinePanel.setBorder(new TitledBorder("Strong LD Spine")); spinePanel.add(new JLabel("Extend spine if D' > ")); spinedp = new NumberTextField(String.valueOf(FindBlocks.spineDP), 4, true); spinePanel.add(spinedp); JPanel butPanel = new JPanel(); JButton button = new JButton("OK"); button.addActionListener(this); butPanel.add(button); button = new JButton("Cancel"); button.addActionListener(this); butPanel.add(button); contents.add(sfsPanel); contents.add(gamPanel); contents.add(spinePanel); contents.add(butPanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
this.setResizable(false);
public ExportDialog(HaploView h){ super(h, "Export Data"); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel tabPanel = new JPanel(); int currTab = hv.tabs.getSelectedIndex(); tabPanel.setBorder(new TitledBorder("Tab to Export")); tabPanel.setLayout(new BoxLayout(tabPanel,BoxLayout.Y_AXIS)); tabPanel.setAlignmentX(CENTER_ALIGNMENT); ButtonGroup g1 = new ButtonGroup(); dpButton = new JRadioButton("LD"); dpButton.setActionCommand("ldtab"); dpButton.addActionListener(this); g1.add(dpButton); tabPanel.add(dpButton); if (currTab == VIEW_D_NUM){ dpButton.setSelected(true); } hapButton = new JRadioButton("Haplotypes"); hapButton.setActionCommand("haptab"); hapButton.addActionListener(this); g1.add(hapButton); tabPanel.add(hapButton); if (currTab == VIEW_HAP_NUM){ hapButton.setSelected(true); } if (hv.checkPanel != null){ checkButton = new JRadioButton("Data Checks"); checkButton.setActionCommand("checktab"); checkButton.addActionListener(this); g1.add(checkButton); tabPanel.add(checkButton); if (currTab == VIEW_CHECK_NUM){ checkButton.setSelected(true); } } if (Options.getAssocTest() != ASSOC_NONE){ assocButton = new JRadioButton("Association Tests"); assocButton.setActionCommand("assoctab"); assocButton.addActionListener(this); g1.add(assocButton); tabPanel.add(assocButton); if (currTab == VIEW_TDT_NUM){ assocButton.setSelected(true); } } contents.add(tabPanel); JPanel formatPanel = new JPanel(); formatPanel.setBorder(new TitledBorder("Output Format")); ButtonGroup g2 = new ButtonGroup(); txtButton = new JRadioButton("Text"); txtButton.addActionListener(this); formatPanel.add(txtButton); g2.add(txtButton); txtButton.setSelected(true); pngButton = new JRadioButton("PNG Image"); pngButton.addActionListener(this); formatPanel.add(pngButton); g2.add(pngButton); compressCheckBox = new JCheckBox("Compress image (smaller file)"); formatPanel.add(compressCheckBox); compressCheckBox.setEnabled(false); if (currTab == VIEW_CHECK_NUM || currTab == VIEW_TDT_NUM){ pngButton.setEnabled(false); } contents.add(formatPanel); JPanel rangePanel = new JPanel(); rangePanel.setBorder(new TitledBorder("Range")); ButtonGroup g3 = new ButtonGroup(); allButton = new JRadioButton("All"); allButton.addActionListener(this); rangePanel.add(allButton); g3.add(allButton); allButton.setSelected(true); someButton = new JRadioButton("Marker "); someButton.addActionListener(this); rangePanel.add(someButton); g3.add(someButton); lowRange = new NumberTextField("",5,false); rangePanel.add(lowRange); rangePanel.add(new JLabel(" to ")); upperRange = new NumberTextField("",5,false); rangePanel.add(upperRange); upperRange.setEnabled(false); lowRange.setEnabled(false); adjButton = new JRadioButton("Adjacent markers only"); adjButton.addActionListener(this); rangePanel.add(adjButton); g3.add(adjButton); if (currTab != VIEW_D_NUM){ someButton.setEnabled(false); adjButton.setEnabled(false); } contents.add(rangePanel); JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); okButton.addActionListener(this); choicePanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
this.setResizable(false);
public ProportionalSpacingDialog(HaploView h, String title){ super (h, title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JSlider slider = new JSlider(0,100, (int)(Options.getSpacingThreshold()*200)); Hashtable labeltable = new Hashtable(); labeltable.put(new Integer(0), new JLabel("None")); labeltable.put(new Integer(100), new JLabel ("Full")); slider.setLabelTable( labeltable ); slider.setPaintLabels(true); slider.addChangeListener(this); contents.add(slider); JButton doneButton = new JButton("Done"); doneButton.addActionListener(this); contents.add(doneButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
public String getPVal(){
public Double getPVal(){
public String getPVal(){ return pval; }
public TDTPanel(Vector chromosomes) { result = TDT.calcTDT(chromosomes);
public TDTPanel(Vector chromosomes, int t) { type = t; if (type == 1){ result = TDT.calcTrioTDT(chromosomes); }else{ result = TDT.calcCCTDT(chromosomes); }
public TDTPanel(Vector chromosomes) { result = TDT.calcTDT(chromosomes); tableColumnNames.add("Name"); tableColumnNames.add("T:U"); tableColumnNames.add("Chi Squared"); tableColumnNames.add("p value"); refreshTable(); }
tableColumnNames.add("T:U");
if (type == 1){ tableColumnNames.add("T:U"); }else{ tableColumnNames.add("Case, Control Ratios"); }
public TDTPanel(Vector chromosomes) { result = TDT.calcTDT(chromosomes); tableColumnNames.add("Name"); tableColumnNames.add("T:U"); tableColumnNames.add("Chi Squared"); tableColumnNames.add("p value"); refreshTable(); }
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
public HaploAssocPanel(Haplotype[][] haps){ //this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); makeTable(haps); }
Chromosome(String p, String i, byte[] g, boolean a, String o){
Chromosome(String p, String i, byte[] g, String o){
Chromosome(String p, String i, byte[] g, boolean a, String o){ ped = p; individual = i; genotypes = g; affected = a; origin = o; trueSize = genotypes.length; }
affected = a;
Chromosome(String p, String i, byte[] g, boolean a, String o){ ped = p; individual = i; genotypes = g; affected = a; origin = o; trueSize = genotypes.length; }
PhotoFolder topFolder = PhotoFolder.create( "extvol_" + dir.getName(),
String rootFolderName = "extvol_" + dir.getName(); if ( rootFolderName.length() > PhotoFolder.NAME_LENGTH ) { rootFolderName = rootFolderName.substring( 0, PhotoFolder.NAME_LENGTH ); } PhotoFolder topFolder = PhotoFolder.create( rootFolderName,
protected void indexDir() { IndexerFileChooser fc = new IndexerFileChooser(); fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); int retval = fc.showDialog( this, "Select directory to index" ); if ( retval == JFileChooser.APPROVE_OPTION ) { File dir = fc.getSelectedFile(); // First check that this directory has not been indexed previously VolumeBase prevVolume = null; try { prevVolume = VolumeBase.getVolumeOfFile( dir ); } catch (IOException ex) { JOptionPane.showMessageDialog( this, "Problem reading directory: " + ex.getMessage(), "Photovault error", JOptionPane.ERROR_MESSAGE ); return; } if ( prevVolume != null ) { JOptionPane.showMessageDialog( this, "Directory " + dir.getAbsolutePath() + "\n has already been indexed to Photovault.", "Already indexed", JOptionPane.ERROR_MESSAGE ); return; } // Generate a unique name for the new volume String extVolName = "extvol_" + dir.getName(); if ( VolumeBase.getVolume( extVolName ) != null ) { int n = 2; while ( VolumeBase.getVolume( extVolName + n ) != null ) { n++; } extVolName += n; } ExternalVolume v = new ExternalVolume( extVolName, dir.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = settings.getCurrentDatabase(); db.addVolume( v ); // Set up the indexer ExtVolIndexer indexer = new ExtVolIndexer( v ); PhotoFolder parentFolder = fc.getExtvolParentFolder(); if ( parentFolder == null ) { parentFolder = PhotoFolder.getRoot(); } PhotoFolder topFolder = PhotoFolder.create( "extvol_" + dir.getName(), parentFolder ); topFolder.setDescription( "Indexed from " + dir.getAbsolutePath() ); indexer.setTopFolder( topFolder ); // Save the configuration of the new volume settings.saveConfig(); // Show status dialog & index the directory IndexerStatusDlg statusDlg = new IndexerStatusDlg( this, false ); statusDlg.setVisible( true ); statusDlg.runIndexer( indexer ); } }
menuItem = new JMenuItem("Open");
menuItem = new JMenuItem("Open Linkage File"); menuItem.addActionListener(this); fileMenu.add(menuItem); menuItem = new JMenuItem("Open Haplotype File");
public HaploView(){ JMenu fileMenu, toolMenu, helpMenu, blockMenu; JMenuBar menuBar = new JMenuBar(); JMenuItem menuItem; addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ System.exit(0); } }); setJMenuBar(menuBar); fileMenu = new JMenu("File"); menuBar.add(fileMenu); toolMenu = new JMenu("Tools"); menuBar.add(toolMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ menuItem = new JMenuItem("Open"); menuItem.addActionListener(this); fileMenu.add(menuItem); loadInfoMenuItem.addActionListener(this); loadInfoMenuItem.setEnabled(false); toolMenu.add(loadInfoMenuItem); toolMenu.addSeparator(); clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); guessBlocksMenuItem.addActionListener(this); guessBlocksMenuItem.setEnabled(false); toolMenu.add(guessBlocksMenuItem); toolMenu.addSeparator(); hapMenuItem.addActionListener(this); hapMenuItem.setEnabled(false); toolMenu.add(hapMenuItem); customizeHapsMenuItem.addActionListener(this); customizeHapsMenuItem.setEnabled(false); toolMenu.add(customizeHapsMenuItem); toolMenu.addSeparator(); saveHapsMenuItem.addActionListener(this); saveHapsMenuItem.setEnabled(false); toolMenu.add(saveHapsMenuItem); saveHapsPicMenuItem.addActionListener(this); saveHapsPicMenuItem.setEnabled(false); toolMenu.add(saveHapsPicMenuItem); saveDprimeMenuItem.addActionListener(this); saveDprimeMenuItem.setEnabled(false); toolMenu.add(saveDprimeMenuItem); exportMenuItem.addActionListener(this); exportMenuItem.setEnabled(false); toolMenu.add(exportMenuItem); fileMenu.addSeparator(); menuItem = new JMenuItem("Exit"); menuItem.addActionListener(this); fileMenu.add(menuItem); }
if (command == "Open"){
if (command == "Open Haplotype File" || command == "Open Linkage File"){
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == "Open"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ theData = new HaploData(fc.getSelectedFile()); infileName = fc.getSelectedFile().getName(); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; drawPicture(theData); loadInfoMenuItem.setEnabled(true); hapMenuItem.setEnabled(true); customizeHapsMenuItem.setEnabled(true); exportMenuItem.setEnabled(true); saveDprimeMenuItem.setEnabled(true); clearBlocksMenuItem.setEnabled(true); guessBlocksMenuItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } } else if (command == loadInfoStr){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ int good = theData.prepareMarkerInput(fc.getSelectedFile()); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; // loadInfoMenuItem.setEnabled(false); drawPicture(theData); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == "Define Blocks"){ defineBlocks(); }else if (command == "Customize Haplotype Output"){ customizeHaps(); }else if (command == "Tutorial"){ showHelp(); }else if (command == "Export LD Picture to JPG"){ doExportDPrime(); }else if (command == "Dump LD Output to Text"){ saveDprimeToText(); }else if (command == "Save Haplotypes to Text"){ saveHapsToText(); }else if (command == "Save Haplotypes to JPG"){ saveHapsPic(); }else if (command == "Generate Haplotypes"){ try{ drawHaplos(theData.generateHaplotypes(theData.blocks, haploThresh)); saveHapsMenuItem.setEnabled(true); saveHapsPicMenuItem.setEnabled(true); }catch (IOException ioe){} } else if (command == "Exit"){ System.exit(0); } }
theData = new HaploData(fc.getSelectedFile()); infileName = fc.getSelectedFile().getName();
theData = new HaploData(inputFile); infileName = inputFile.getName();
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == "Open"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ theData = new HaploData(fc.getSelectedFile()); infileName = fc.getSelectedFile().getName(); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.finished){ timer.stop(); progressMonitor.close(); infoKnown=false; drawPicture(theData); loadInfoMenuItem.setEnabled(true); hapMenuItem.setEnabled(true); customizeHapsMenuItem.setEnabled(true); exportMenuItem.setEnabled(true); saveDprimeMenuItem.setEnabled(true); clearBlocksMenuItem.setEnabled(true); guessBlocksMenuItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } } else if (command == loadInfoStr){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ int good = theData.prepareMarkerInput(fc.getSelectedFile()); if (good == -1){ JOptionPane.showMessageDialog(this, "Number of markers in info file does not match number of markers in dataset.", "Error", JOptionPane.ERROR_MESSAGE); }else{ infoKnown=true; // loadInfoMenuItem.setEnabled(false); drawPicture(theData); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == "Define Blocks"){ defineBlocks(); }else if (command == "Customize Haplotype Output"){ customizeHaps(); }else if (command == "Tutorial"){ showHelp(); }else if (command == "Export LD Picture to JPG"){ doExportDPrime(); }else if (command == "Dump LD Output to Text"){ saveDprimeToText(); }else if (command == "Save Haplotypes to Text"){ saveHapsToText(); }else if (command == "Save Haplotypes to JPG"){ saveHapsPic(); }else if (command == "Generate Haplotypes"){ try{ drawHaplos(theData.generateHaplotypes(theData.blocks, haploThresh)); saveHapsMenuItem.setEnabled(true); saveHapsPicMenuItem.setEnabled(true); }catch (IOException ioe){} } else if (command == "Exit"){ System.exit(0); } }
int myRating = ((CheckDataTableModel)((TableSorter)table.getModel()).getTableModel()).getRating(row); int myDupStatus = ((CheckDataTableModel)((TableSorter)table.getModel()).getTableModel()).getDupStatus(row);
int myRating = ((CheckDataTableSorter)table.getModel()).getRating(row); int myDupStatus = ((CheckDataTableSorter)table.getModel()).getDupStatus(row);
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)((TableSorter)table.getModel()).getTableModel()).getRating(row); int myDupStatus = ((CheckDataTableModel)((TableSorter)table.getModel()).getTableModel()).getDupStatus(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); cell.setBackground(Color.white); if (myDupStatus > 0){ //I'm a dup so color the background in bright, ugly yellow cell.setBackground(Color.yellow); } //bitmasking to decode the status bits if (myRating < 0){ myRating *= -1; if ((myRating & 1) != 0){ if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if ((myRating & 2) != 0){ if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if ((myRating & 4) != 0){ if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if ((myRating & 8) != 0){ if (thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } if ((myRating & 16) != 0){ if (thisColumnName.equals("MAF")){ cell.setForeground(Color.red); } } } return cell; }
TableSorter sorter = new TableSorter(tableModel);
CheckDataTableSorter sorter = new CheckDataTableSorter(tableModel);
public CheckDataPanel(HaploView hv){ this(hv.theData); this.hv = hv; setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel missingPanel = new JPanel(); JLabel countsLabel; 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); missingPanel.add(countsLabel); JButton missingButton = new JButton("Show Excluded Individuals"); JButton individualButton = new JButton("Individual Summary"); individualButton.setEnabled(true); JButton mendelButton = new JButton("Mendel Errors"); mendelButton.setEnabled(true); if (hv.theData.getPedFile().getAxedPeople().size() == 0){ missingButton.setEnabled(false); } missingButton.addActionListener(this); missingPanel.add(missingButton); individualButton.addActionListener(this); missingPanel.add(individualButton); mendelButton.addActionListener(this); missingPanel.add(mendelButton); missingPanel.setBorder(BorderFactory.createLineBorder(Color.black)); JPanel extraPanel = new JPanel(); extraPanel.add(missingPanel); TableSorter sorter = new TableSorter(tableModel); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Long"), renderer); table.setDefaultRenderer(Class.forName("java.lang.String"),renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(0).setMinWidth(30); if (theData.infoKnown){ table.getColumnModel().getColumn(1).setMinWidth(100); table.getColumnModel().getColumn(2).setMinWidth(60); } JScrollPane tableScroller = new JScrollPane(table); //changed 600 to 800 and tableScroller.getPreferredSize().height to Integer.MAX_VALUE. tableScroller.setMaximumSize(new Dimension(800, Integer.MAX_VALUE)); add(extraPanel); add(tableScroller); if (theData.dupsToBeFlagged){ JOptionPane.showMessageDialog(hv, "Two or more SNPs have identical position. They have been flagged in yellow\n"+ "and the less completely genotyped duplicate has been deselected.", "Duplicate SNPs", JOptionPane.INFORMATION_MESSAGE); } if (theData.dupNames){ JOptionPane.showMessageDialog(hv, "Two or more SNPs have identical names. They have been renamed with\n"+ ".X extensions where X is an integer unique to each duplicate.", "Duplicate SNPs", JOptionPane.INFORMATION_MESSAGE); } }
String[] columnNames = {"FamilyID", "IndividualID", "Reason"}; String[][] data = new String[axedPeople.size()][3];
Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Reason"); Vector data = new Vector();
public FilteredIndividualsDialog(HaploView h, String title) { super(h,title); BasicTableModel tableModel; JTable table; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector axedPeople = h.theData.getPedFile().getAxedPeople(); String[] columnNames = {"FamilyID", "IndividualID", "Reason"}; String[][] data = new String[axedPeople.size()][3]; for(int i=0;i<axedPeople.size();i++) { Individual currentInd = (Individual) axedPeople.get(i); data[i][0] = currentInd.getFamilyID(); data[i][1] = currentInd.getIndividualID(); data[i][2] = currentInd.getReasonImAxed(); } tableModel = new BasicTableModel(new Vector(Arrays.asList(columnNames)),new Vector(Arrays.asList(data))); table = new JTable(tableModel); table.getColumnModel().getColumn(2).setPreferredWidth(300); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
data[i][0] = currentInd.getFamilyID(); data[i][1] = currentInd.getIndividualID(); data[i][2] = currentInd.getReasonImAxed();
tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(currentInd.getReasonImAxed()); data.add(tmpVec);
public FilteredIndividualsDialog(HaploView h, String title) { super(h,title); BasicTableModel tableModel; JTable table; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector axedPeople = h.theData.getPedFile().getAxedPeople(); String[] columnNames = {"FamilyID", "IndividualID", "Reason"}; String[][] data = new String[axedPeople.size()][3]; for(int i=0;i<axedPeople.size();i++) { Individual currentInd = (Individual) axedPeople.get(i); data[i][0] = currentInd.getFamilyID(); data[i][1] = currentInd.getIndividualID(); data[i][2] = currentInd.getReasonImAxed(); } tableModel = new BasicTableModel(new Vector(Arrays.asList(columnNames)),new Vector(Arrays.asList(data))); table = new JTable(tableModel); table.getColumnModel().getColumn(2).setPreferredWidth(300); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
tableModel = new BasicTableModel(new Vector(Arrays.asList(columnNames)),new Vector(Arrays.asList(data)));
tableModel = new BasicTableModel(colNames, data);
public FilteredIndividualsDialog(HaploView h, String title) { super(h,title); BasicTableModel tableModel; JTable table; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector axedPeople = h.theData.getPedFile().getAxedPeople(); String[] columnNames = {"FamilyID", "IndividualID", "Reason"}; String[][] data = new String[axedPeople.size()][3]; for(int i=0;i<axedPeople.size();i++) { Individual currentInd = (Individual) axedPeople.get(i); data[i][0] = currentInd.getFamilyID(); data[i][1] = currentInd.getIndividualID(); data[i][2] = currentInd.getReasonImAxed(); } tableModel = new BasicTableModel(new Vector(Arrays.asList(columnNames)),new Vector(Arrays.asList(data))); table = new JTable(tableModel); table.getColumnModel().getColumn(2).setPreferredWidth(300); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
registerBeanFactory( "buttonGroup", ButtonGroup.class );
protected void registerFactories() { registerBeanFactory( "button", JButton.class ); registerBeanFactory( "checkBox", JCheckBox.class ); registerBeanFactory( "checkBoxMenuItem", JCheckBoxMenuItem.class ); registerBeanFactory( "comboBox", JComboBox.class ); // how to add content there ? // Have a ComboBoxModel (just one should have a Table or Tree Model objects) ? // can the element control it's children ? // but children should also be able to be any component (as Swing comps. are all container) registerBeanFactory( "desktopPane", JDesktopPane.class ); registerBeanFactory( "dialog", JDialog.class ); registerBeanFactory( "editorPane", JEditorPane.class ); registerBeanFactory( "fileChooser", JFileChooser.class ); registerBeanFactory( "frame", JFrame.class ); registerBeanFactory( "internalFrame", JInternalFrame.class ); registerBeanFactory( "label", JLabel.class ); registerBeanFactory( "list", JList.class ); registerBeanFactory( "menu", JMenu.class ); registerBeanFactory( "menuBar", JMenuBar.class ); registerBeanFactory( "menuItem", JMenuItem.class ); registerBeanFactory( "panel", JPanel.class ); registerBeanFactory( "passwordField", JPasswordField.class ); registerBeanFactory( "popupMenu", JPopupMenu.class ); registerBeanFactory( "radioButton", JRadioButton.class ); registerBeanFactory( "radioButtonMenuItem", JRadioButtonMenuItem.class ); registerBeanFactory( "optionPane", JOptionPane.class ); registerBeanFactory( "scrollPane", JScrollPane.class ); registerBeanFactory( "separator", JSeparator.class ); registerFactory( "splitPane", new Factory() { public Object newInstance() { JSplitPane answer = new JSplitPane(); answer.setLeftComponent(null); answer.setRightComponent(null); answer.setTopComponent(null); answer.setBottomComponent(null); return answer; } } ); // Box related layout components registerFactory( "hbox", new Factory() { public Object newInstance() { return Box.createHorizontalBox(); } } ); registerFactory( "vbox", new Factory() { public Object newInstance() { return Box.createVerticalBox(); } } ); registerBeanFactory( "tabbedPane", JTabbedPane.class ); registerBeanFactory( "table", JTable.class ); registerBeanFactory( "textArea", JTextArea.class ); registerBeanFactory( "textField", JTextField.class ); registerBeanFactory( "toggleButton", JToggleButton.class ); registerBeanFactory( "tree", JTree.class ); registerBeanFactory( "toolBar", JToolBar.class ); }
}else if (chromChoice.equals("Y")){ filters.add("24");
public void gotoRegion(){ if (table.getSelectedRow() == -1){ JOptionPane.showMessageDialog(this, "Please select a region.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } String gotoChrom = (String)table.getValueAt(table.getSelectedRow(),1); String gotoMarker = (String)table.getValueAt(table.getSelectedRow(),2); long markerPosition = ((Long)(table.getValueAt(table.getSelectedRow(),3))).longValue(); Vector filters = new Vector(); if (chromChoice != null && !chromChoice.equals("")){ if(chromChoice.equals("X")){ filters.add("23"); }else{ filters.add(new Integer(chromChooser.getSelectedIndex()).toString()); } filters.add(new Integer(startPos).toString()); filters.add(new Integer(endPos).toString()); }else{ filters.add(""); filters.add("0"); filters.add("0"); } filters.add(new Integer(genericChooser.getSelectedIndex()).toString()); filters.add(new Integer(signChooser.getSelectedIndex()).toString()); filters.add(valueField.getText()); hv.setPlinkFilters(filters); RegionDialog rd = new RegionDialog(hv,gotoChrom,gotoMarker,markerPosition,"Go to Region"); rd.pack(); rd.setVisible(true); }
super.setAttribute( name, ((Expression) value).evaluateAsValue(context) );
super.setAttribute( name, ((Expression) value).evaluateRecurse(context) );
public void setAttribute(String name, Object value) { if ( value == null ) { // should we send in null? super.setAttribute( name, "" ); } else { if ( value instanceof Expression ) { super.setAttribute( name, ((Expression) value).evaluateAsValue(context) ); } else { super.setAttribute( name, value.toString() ); } } }
public void run(Context context, XMLOutput output) throws Exception {
public void run(JellyContext context, XMLOutput output) throws Exception {
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new IllegalArgumentException( "The var attribute cannot be null" ); } if ( value != null ) { Object answer = value.evaluate( context ); context.setVariable( var, answer ); } else { // must use body to get the value String text = getBodyText( context ); context.setVariable( var, text ); } }
String text = getBodyText( context );
String text = getBodyText();
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new IllegalArgumentException( "The var attribute cannot be null" ); } if ( value != null ) { Object answer = value.evaluate( context ); context.setVariable( var, answer ); } else { // must use body to get the value String text = getBodyText( context ); context.setVariable( var, text ); } }
String testImgDir = "c:\\java\\photovault\\testfiles";
public void testCreationFromImage() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } assertNotNull( photo ); assertTrue( photo.getNumInstances() > 0 ); photo.delete(); }