rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); | textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), outputFile); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; | textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), outputFile);; | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
OutputFile = validateOutputFile(fileName + ".LD"); | outputFile = validateOutputFile(fileName + ".LD"); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); | textData.saveDprimeToText(outputFile, TABLE_TYPE, 0, Chromosome.getSize()); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); | textData.saveDprimeToText(outputFile, LIVE_TYPE, 0, Chromosome.getSize()); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
OutputFile = validateOutputFile(fileName + ".LD.PNG"); | outputFile = validateOutputFile(fileName + ".LD.PNG"); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); | Jimi.putImage("image/png", i, outputFile.getAbsolutePath()); | private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ if (randomizeAffection){ Vector aff = new Vector(); int j=0, k=0; for (int i = 0; i < textData.getPedFile().getNumIndividuals(); i++){ if (i%2 == 0){ aff.add(new Integer(1)); j++; }else{ aff.add(new Integer(2)); k++; } } Collections.shuffle(aff); markerTestSet = new AssociationTestSet(textData.getPedFile(),aff,Chromosome.getAllMarkers()); }else{ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); } markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.setPermTests(doPermutationTest); customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced included tags since I don't know about it."); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s) && !quietMode) { System.out.println("Warning: skipping marker " + s + " in the list of forced excluded tags since I don't know about it."); } } //chuck out filtered jazz from excludes, and nonexistent markers from both forceExcludeTags.retainAll(filteredNames); forceIncludeTags.retainAll(names); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging,maxNumTags,findTags); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } } |
String volumeRoot = "c:\\temp\\photoVaultVolumeTest"; volume = new Volume( "testVolume", volumeRoot ); | try { volumeRoot = File.createTempFile( "photovaultVolumeTest", "" ); volumeRoot.delete(); volumeRoot.mkdir(); extvolRoot = File.createTempFile( "photovaultVolumeTestExt", "" ); extvolRoot.delete(); extvolRoot.mkdir(); } catch (IOException ex) { ex.printStackTrace(); } volume = new Volume( "testVolume", volumeRoot.getAbsolutePath() ); | public void setUp() { String volumeRoot = "c:\\temp\\photoVaultVolumeTest"; volume = new Volume( "testVolume", volumeRoot ); extVol = new ExternalVolume( "extVolume", extvolRoot.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase curDb = settings.getCurrentDatabase(); curDb.addVolume( extVol ); } |
topicID = Integer.parseInt(topic.toString()); | topicID = topic.getIdentifier().intValue(); | public PresentationObject getTopicsOverView(IWContext iwc){ Table T = new Table(); int row = 1; T.add(getTopicLink(-1,iwrb.getLocalizedString("new_topic","New topic")),1,row); row++; T.add(tf.format(iwrb.getLocalizedString("name","Name"),tf.HEADER),1,row); T.add(tf.format(iwrb.getLocalizedString("category","Category"),tf.HEADER),2,row); T.add(tf.format(iwrb.getLocalizedString("mail_server","Mail server"),tf.HEADER),3,row); T.add(tf.format(iwrb.getLocalizedString("subscribers","Subscribers"),tf.HEADER),4,row); T.add(tf.format(iwrb.getLocalizedString("welcome","Welcome"),tf.HEADER),5,row); row++; if(!topics.isEmpty()){ Iterator iter = topics.values().iterator(); EmailTopic topic; ICCategory category; EmailAccount account; EmailLetter welcome; Collection welcomes; Collection accounts; int emailCount; int topicID; while(iter.hasNext()){ topic = (EmailTopic) iter.next(); topicID = Integer.parseInt(topic.toString()); T.add(getTopicLink(topicID,topic.getName()),1,row); category = (ICCategory) categories.get(Integer.toString(topic.getCategoryId())); T.add(tf.format(category.getName()),2,row); accounts = MailFinder.getInstance().getTopicAccounts(topicID,MailProtocol.SMTP); if(accounts!=null && !accounts.isEmpty()){ account = (EmailAccount) accounts.iterator().next(); T.add(getAccountLink(topicID,Integer.parseInt( account.toString()),account.getHost()),3,row); } else{ T.add(getAccountLink(topicID,-1,"X"),3,row); } emailCount = MailFinder.getInstance().getListEmailsCount(topic.getListId()); T.add((getSubscribersLink(topicID,String.valueOf(emailCount))),4,row); welcomes = MailFinder.getInstance().getEmailLetters(topicID,MailLetter.TYPE_SUBSCRIPTION); if(welcomes!=null && !welcomes.isEmpty()){ welcome = (MailLetter) welcomes.iterator().next(); T.add(getWelcomeLetterLink(Integer.parseInt(welcome.toString()),topicID,welcome.getSubject()),5,row); //T.add(tf.format(welcome.getSubject()),5,row); } else{ T.add(getWelcomeLetterLink(-1,topicID,"X"),5,row); } row++; } } return T; } |
query = query.withValues(values.getValuesFor(filter)); | query = query.withValues(values.getSuppliedValuesFor(filter)); | private Query<S> applyFilterValues(FilterValues<S> values) { // FIXME: figure out how to transfer values directly to query. Query<S> query = mQuery; Filter<S> filter = query.getFilter(); // FIXME: this code can get confused if filter has constants. if (values != null && filter != null && query.getBlankParameterCount() != 0) { // FIXME: throws exception if not all values supplied query = query.withValues(values.getValuesFor(filter)); } return query; } |
returnStrings = new String[]{plinkFileField.getText(), plinkMapField.getText(),embed}; | returnStrings = new String[]{plinkFileField.getText(), plinkMapField.getText(),null,embed}; | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(BROWSE_GENO)){ browse(GENO_FILE); }else if (command.equals(BROWSE_HAPS)){ browse(HAPS_FILE); }else if (command.equals(BROWSE_HMP)){ browse(HMP_FILE); }else if (command.equals(BROWSE_PHASE)){ browse(PHASED_FILE); }else if (command.equals(BROWSE_SAMPLE)){ browse(SAMPLE_FILE); }else if (command.equals(BROWSE_LEGEND)){ browse(LEGEND_FILE); }else if (command.equals(BROWSE_INFO)){ browse(INFO_FILE); }else if (command.equals(BROWSE_ASSOC)){ browse(ASSOC_FILE); }else if (command.equals(BROWSE_WGA)){ browse(PLINK_FILE); }else if (command.equals(BROWSE_MAP)){ browse(MAP_FILE); } else if (command.equals("OK")){ //workaround for dumb Swing can't requestFocus until shown bug //this one seems to throw a harmless exception in certain versions of the linux JRE try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { pedFileField.requestFocus(); }}); }catch (RuntimeException re){ } int currTab = dataFormatPane.getSelectedIndex(); if (currTab == 0){ fileType = PED_FILE; }else if (currTab == 1){ fileType = HAPS_FILE; }else if (currTab == 2){ fileType = HMP_FILE; }else if (currTab == 3){ fileType = PHASED_FILE; }else if (currTab == 4){ fileType = PHASEDHMPDL_FILE; }else if (currTab == 5){ fileType = PLINK_FILE; } HaploView caller = (HaploView)this.getParent(); if(missingCutoffField.getText().equals("")) { Options.setMissingThreshold(1); } else { double missingThreshold = (double)(Integer.parseInt(missingCutoffField.getText())) / 100; if(missingThreshold > 1) { JOptionPane.showMessageDialog(caller, "Missing cutoff must be between 0 and 100", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } Options.setMissingThreshold(missingThreshold); } if (doAssociation.isSelected() && fileType == PED_FILE){ if (trioButton.isSelected()){ Options.setAssocTest(ASSOC_TRIO); if(standardTDT.isSelected()){ Options.setTdtType(TDT_STD); }else if(parenTDT.isSelected()) { Options.setTdtType(TDT_PAREN); } } else { Options.setAssocTest(ASSOC_CC); } }else{ Options.setAssocTest(ASSOC_NONE); } if (xChrom.isSelected() && fileType == PED_FILE){ Chromosome.setDataChrom("chrx"); }else if (hapsXChrom.isSelected() && fileType == HAPS_FILE){ Chromosome.setDataChrom("chrx"); } else { Chromosome.setDataChrom("none"); } if (doGB.isSelected() && fileType == HMP_FILE){ Options.setShowGBrowse(true); }else{ Options.setShowGBrowse(false); } Options.setgBrowseLeft(0); Options.setgBrowseRight(0); if (maxComparisonDistField.getText().equals("")){ Options.setMaxDistance(0); }else{ Options.setMaxDistance(Integer.parseInt(maxComparisonDistField.getText())); } if (fileType == PHASED_FILE){ if (gZip.isSelected()){ Options.setGzip(true); }else{ Options.setGzip(false); } isDownloaded = false; if (phaseDoGB.isSelected()){ Options.setShowGBrowse(true); if (loadChromChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(caller, "HapMap Info Track download requires a chromosome.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } }else{ Options.setShowGBrowse(false); } if (loadChromChooser.getSelectedIndex() == -1){ chromChoice = ""; }else{ chromChoice = (String)loadChromChooser.getSelectedItem(); } } if (fileType == PHASEDHMPDL_FILE){ isDownloaded = true; if (downloadDoGB.isSelected()){ Options.setShowGBrowse(true); }else{ Options.setShowGBrowse(false); } if (chromChooser.getSelectedIndex() == -1){ JOptionPane.showMessageDialog(caller, "Please select a chromosome.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (chromStartField.getText().equals("")){ JOptionPane.showMessageDialog(caller, "Please enter a starting value.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (chromEndField.getText().equals("")){ JOptionPane.showMessageDialog(caller, "Please enter an ending value.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } if (Integer.parseInt(chromStartField.getText()) >= Integer.parseInt(chromEndField.getText())){ JOptionPane.showMessageDialog(caller, "End position must be larger then start position.", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } chromChoice = (String)chromChooser.getSelectedItem(); popChoice = (String)popChooser.getSelectedItem(); } if (fileType == PLINK_FILE){ if (embeddedMap.isSelected()){ embed = "Y"; } } String[] returnStrings; if (fileType == HAPS_FILE){ returnStrings = new String[]{hapsFileField.getText(), hapsInfoField.getText(),null}; if (returnStrings[1].equals("")) returnStrings[1] = null; }else if (fileType == HMP_FILE){ returnStrings = new String[]{hmpFileField.getText(),null,null}; }else if (fileType == PHASED_FILE ){ returnStrings = new String[]{phaseFileField.getText(), phaseSampleField.getText(), phaseLegendField.getText(),"",chromChoice}; }else if (fileType == PHASEDHMPDL_FILE){ returnStrings = new String[]{"Chr" + chromChoice + ":" + popChoice + ":" + chromStartField.getText() + ".." + chromEndField.getText(), popChoice, chromStartField.getText(), chromEndField.getText(), chromChoice}; }else if (fileType == PLINK_FILE){ returnStrings = new String[]{plinkFileField.getText(), plinkMapField.getText(),embed}; } else{ returnStrings = new String[]{pedFileField.getText(), pedInfoField.getText(), testFileField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; if (returnStrings[2].equals("") || !doAssociation.isSelected()) returnStrings[2] = null; } //if a dataset was previously loaded during this session, discard the display panes for it. caller.clearDisplays(); caller.setPlinkData(null,null); this.dispose(); if (fileType != PLINK_FILE){ caller.readGenotypes(returnStrings, fileType, isDownloaded); }else{ caller.readWGA(returnStrings); } }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("association")){ switchAssoc(doAssociation.isSelected()); }else if(command.equals("tdt")){ standardTDT.setEnabled(true); if (!xChrom.isSelected()){ parenTDT.setEnabled(true); } }else if(command.equals("ccButton")){ standardTDT.setEnabled(false); parenTDT.setEnabled(false); }else if (command.equals("xChrom")){ if (xChrom.isSelected()){ parenTDT.setEnabled(false); standardTDT.setSelected(true); }else if (standardTDT.isEnabled()){ parenTDT.setEnabled(true); } }else if (command.equals("Integrated Map Info")){ if (embeddedMap.isSelected()){ embeddedMap.setSelected(true); mapLabel.setEnabled(false); plinkMapField.setEnabled(false); browsePlinkMapButton.setEnabled(false); }else{ embeddedMap.setSelected(false); mapLabel.setEnabled(true); plinkMapField.setEnabled(true); browsePlinkMapButton.setEnabled(true); } }else if (command.equals("Proxy Settings")){ ProxyDialog pd = new ProxyDialog(this,"Proxy Settings"); pd.pack(); pd.setVisible(true); } } |
XMLParser parser = (XMLParser) parserPool.get(); if (parser == null) { parser = createXMLParser(); parserPool.set(parser); } | XMLParser parser = createXMLParser(); | protected XMLParser getXMLParser() { XMLParser parser = (XMLParser) parserPool.get(); if (parser == null) { parser = createXMLParser(); parserPool.set(parser); } return parser; } |
Enumeration enum= listModel.elements(); while (enum.hasMoreElements()) { v.add(enum.nextElement()); | Enumeration items = listModel.elements(); while (items.hasMoreElements()) { v.add(items.nextElement()); | public void buildPage(String template, JellyContext ctx) { // try {// // Embedded embedded = new Embedded();// embedded.setOutputStream(new FileOutputStream("out.html"));// //embedded.setVariable("some-var","some-object");// // embedded.setScript("file:///anoncvs/jakarta-commons-sandbox/jelly/sample.jelly");// //or one can do.// //embedded.setScript(scriptAsInputStream);// // boolean bStatus=embedded.execute();// if(!bStatus) //if error// {// System.out.println(embedded.getErrorMsg());// }//// } catch (Exception e) {// e.printStackTrace();// } try { OutputStream output = new FileOutputStream("demopage.html"); JellyContext context = new JellyContext(); context.setVariable("name",nameField.getText()); context.setVariable("background",colorField.getText()); context.setVariable("url",urlField.getText()); Vector v = new Vector(); Enumeration enum= listModel.elements(); while (enum.hasMoreElements()) { v.add(enum.nextElement()); } context.setVariable("hobbies", v); XMLOutput xmlOutput = XMLOutput.createXMLOutput(output); context.runScript( resolveURL("src/test/org/apache/commons/jelly/demos/"+template), xmlOutput ); xmlOutput.flush(); System.out.println("Finished merging template"); } catch (Exception e) { |
e.printStackTrace(); } } | public void buildPage(String template, JellyContext ctx) { // try {// // Embedded embedded = new Embedded();// embedded.setOutputStream(new FileOutputStream("out.html"));// //embedded.setVariable("some-var","some-object");// // embedded.setScript("file:///anoncvs/jakarta-commons-sandbox/jelly/sample.jelly");// //or one can do.// //embedded.setScript(scriptAsInputStream);// // boolean bStatus=embedded.execute();// if(!bStatus) //if error// {// System.out.println(embedded.getErrorMsg());// }//// } catch (Exception e) {// e.printStackTrace();// } try { OutputStream output = new FileOutputStream("demopage.html"); JellyContext context = new JellyContext(); context.setVariable("name",nameField.getText()); context.setVariable("background",colorField.getText()); context.setVariable("url",urlField.getText()); Vector v = new Vector(); Enumeration enum= listModel.elements(); while (enum.hasMoreElements()) { v.add(enum.nextElement()); } context.setVariable("hobbies", v); XMLOutput xmlOutput = XMLOutput.createXMLOutput(output); context.runScript( resolveURL("src/test/org/apache/commons/jelly/demos/"+template), xmlOutput ); xmlOutput.flush(); System.out.println("Finished merging template"); } catch (Exception e) { |
|
JTable table; TDT theTDT = new TDT(); Vector result = theTDT.calcTDT(chromosomes); Vector tableColumnNames = new Vector(); | public TDTPanel(Vector chromosomes) { JTable table; TDT theTDT = new TDT(); Vector result = theTDT.calcTDT(chromosomes); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("Chi Squared"); tableColumnNames.add("T/U Ratio"); tableColumnNames.add("p value"); 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(new Double(currentResult.getChiSq())); tempVect.add(currentResult.getTURatio()); tempVect.add(new Double(currentResult.getPValue())); tableData.add(tempVect.clone()); } table = new JTable(tableData,tableColumnNames); //table.setPreferredSize(new Dimension(200,200)); //for(int i=0;i<table.getColumnModel().getColumnCount();i++){ // table.getColumnModel().getColumn(i).setPreferredWidth(6); //} JScrollPane tableScroller = new JScrollPane(table); //tableScroller.getViewport().setPreferredSize(new Dimension(200, height)); add(tableScroller); } |
|
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(new Double(currentResult.getChiSq())); tempVect.add(currentResult.getTURatio()); tempVect.add(new Double(currentResult.getPValue())); tableData.add(tempVect.clone()); } table = new JTable(tableData,tableColumnNames); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); | public TDTPanel(Vector chromosomes) { JTable table; TDT theTDT = new TDT(); Vector result = theTDT.calcTDT(chromosomes); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("Chi Squared"); tableColumnNames.add("T/U Ratio"); tableColumnNames.add("p value"); 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(new Double(currentResult.getChiSq())); tempVect.add(currentResult.getTURatio()); tempVect.add(new Double(currentResult.getPValue())); tableData.add(tempVect.clone()); } table = new JTable(tableData,tableColumnNames); //table.setPreferredSize(new Dimension(200,200)); //for(int i=0;i<table.getColumnModel().getColumnCount();i++){ // table.getColumnModel().getColumn(i).setPreferredWidth(6); //} JScrollPane tableScroller = new JScrollPane(table); //tableScroller.getViewport().setPreferredSize(new Dimension(200, height)); add(tableScroller); } |
|
folderTreePane = new FolderTreePane( ctrl.getFolderController() ); pane.add( folderTreePane, BorderLayout.NORTH ); | GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; pane.add( folderTreePane, c ); | protected void createFolderPaneUI() { JPanel pane = new JPanel(); tabPane.addTab( "Folders", pane ); folderTreePane = new FolderTreePane( ctrl.getFolderController() ); pane.add( folderTreePane, BorderLayout.NORTH ); } |
this.parent = parent; setName(name); this.remarks = remarks; this.objectType = objectType; this.children = new ArrayList(); | setup(parent, name, remarks, objectType); | public SQLTable(SQLObject parent, String name, String remarks, String objectType, boolean startPopulated) throws ArchitectException { logger.debug("NEW TABLE "+name+"@"+hashCode()); this.parent = parent; setName(name); this.remarks = remarks; this.objectType = objectType; this.children = new ArrayList(); initFolders(startPopulated); } |
if (this.objectType == null) throw new NullPointerException(); | public void setObjectType(String argObjectType) { String oldObjectType = this.objectType; this.objectType = argObjectType; fireDbObjectChanged("objectType",oldObjectType, argObjectType); } |
|
new NumberTextField(String.valueOf(parent.displayThresh), 3, false)); | new NumberTextField(String.valueOf(Options.getHaplotypeDisplayThreshold()), 3, false)); | public HaplotypeDisplayController(HaplotypeDisplay parent){ this.parent = parent; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS)); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS)); JPanel hapPercentPanel = new JPanel(); hapPercentPanel.add(new JLabel("Examine haplotypes above ")); hapPercentPanel.add(minDisplayField = new NumberTextField(String.valueOf(parent.displayThresh), 3, false)); hapPercentPanel.add(new JLabel("%")); leftPanel.add(hapPercentPanel); JPanel thinPanel = new JPanel(); thinPanel.add(new JLabel("Connect with thin lines if > ")); thinPanel.add(minThinField = new NumberTextField(String.valueOf(parent.thinThresh), 3, false)); thinPanel.add(new JLabel("%")); leftPanel.add(thinPanel); JPanel thickPanel = new JPanel(); thickPanel.add(new JLabel("Connect with thick lines if > ")); thickPanel.add(minThickField = new NumberTextField(String.valueOf(parent.thickThresh), 3, false)); thickPanel.add(new JLabel("%")); leftPanel.add(thickPanel); //numericAlleles = new JCheckBox("Display alleles as numbers."); //add(numericAlleles); JLabel dispLab = new JLabel("Display alleles as:"); rightPanel.add(dispLab); JRadioButton letBut = new JRadioButton("letters"); letBut.setActionCommand("0"); letBut.setSelected(true); rightPanel.add(letBut); JRadioButton numBut = new JRadioButton("numbers"); numBut.setActionCommand("1"); rightPanel.add(numBut); JRadioButton sqBut = new JRadioButton("colored squares"); sqBut.setActionCommand("2"); rightPanel.add(sqBut); alleleDisplayGroup = new ButtonGroup(); alleleDisplayGroup.add(letBut); alleleDisplayGroup.add(numBut); alleleDisplayGroup.add(sqBut); JPanel optionPanel = new JPanel(); optionPanel.add(leftPanel); optionPanel.add(rightPanel); add(optionPanel); goButton = new JButton("Go"); goButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { setDisplayThresh(Integer.parseInt(minDisplayField.getText())); setThinThresh(Integer.parseInt(minThinField.getText())); setThickThresh(Integer.parseInt(minThickField.getText())); setNumericAlls(alleleDisplayGroup.getSelection().getActionCommand()); paintIt(); } }); add(goButton); fieldSize = minDisplayField.getPreferredSize(); } |
if (parent.displayThresh != amount){ parent.adjustDisplay(amount); | if (Options.getHaplotypeDisplayThreshold() != amount){ Options.setHaplotypeDisplayThreshold(amount); parent.adjustDisplay(); | public void setDisplayThresh(int amount){ if (parent.displayThresh != amount){ parent.adjustDisplay(amount); } } |
protected int countSourceTables(int count, SQLObject o) throws ArchitectException { | protected int countSourceTables(SQLObject o) throws ArchitectException { | protected int countSourceTables(int count, SQLObject o) throws ArchitectException { if (o instanceof SQLTable) { return count + 1; } else { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { count += countSourceTables(count, (SQLObject) it.next()); } } return count; } |
return count + 1; | return 1; } else if (o == playPen.getDatabase()) { return 0; | protected int countSourceTables(int count, SQLObject o) throws ArchitectException { if (o instanceof SQLTable) { return count + 1; } else { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { count += countSourceTables(count, (SQLObject) it.next()); } } return count; } |
count += countSourceTables(count, (SQLObject) it.next()); | myCount += countSourceTables((SQLObject) it.next()); | protected int countSourceTables(int count, SQLObject o) throws ArchitectException { if (o instanceof SQLTable) { return count + 1; } else { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { count += countSourceTables(count, (SQLObject) it.next()); } } return count; } |
return count; | protected int countSourceTables(int count, SQLObject o) throws ArchitectException { if (o instanceof SQLTable) { return count + 1; } else { Iterator it = o.getChildren().iterator(); while (it.hasNext()) { count += countSourceTables(count, (SQLObject) it.next()); } } return count; } |
|
pm.setMaximum(countSourceTables(0, (SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getComponentCount() * 2); | int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); | public void save(ProgressMonitor pm) throws IOException, ArchitectException { out = new PrintWriter(new BufferedWriter(new FileWriter(file))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; this.pm = pm; pm.setMinimum(0); pm.setMaximum(countSourceTables(0, (SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getComponentCount() * 2); progress = 0; 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>"); saveDBCS(); saveSourceDatabases(); saveTargetDatabase(); savePlayPen(); indent--; println("</architect-project>"); } finally { out.close(); out = null; pm.close(); pm = null; } } |
logger.debug("column "+o+" source is "+sourceCol+" (hash "+sourceCol.hashCode() +"; id "+objectIdMap.get(sourceCol) +", parent "+sourceCol.getParent()+" hash "+sourceCol.getParent().hashCode() +", parent "+sourceCol.getParent().getParent()+" hash "+sourceCol.getParent().getParent().hashCode() +", parent "+sourceCol.getParent().getParent().getParent()+" hash "+sourceCol.getParent().getParent().getParent().hashCode() +")"); | protected void saveSQLObject(SQLObject o) throws IOException, ArchitectException { String id = (String) objectIdMap.get(o); if (id != null) { println("<reference ref-id=\""+id+"\" />"); return; } String type; Map propNames = new TreeMap(); if (o instanceof SQLDatabase) { id = "DB"+objectIdMap.size(); type = "database"; propNames.put("dbcs-ref", dbcsIdMap.get(((SQLDatabase) o).getConnectionSpec())); } else if (o instanceof SQLCatalog) { id = "CAT"+objectIdMap.size(); type = "catalog"; propNames.put("catalogName", ((SQLCatalog) o).getCatalogName()); } else if (o instanceof SQLSchema) { id = "SCH"+objectIdMap.size(); type = "schema"; propNames.put("schemaName", ((SQLSchema) o).getSchemaName()); } else if (o instanceof SQLTable) { id = "TAB"+objectIdMap.size(); type = "table"; propNames.put("tableName", ((SQLTable) o).getTableName()); propNames.put("remarks", ((SQLTable) o).getRemarks()); propNames.put("objectType", ((SQLTable) o).getObjectType()); propNames.put("primaryKeyName", ((SQLTable) o).getPrimaryKeyName()); pm.setProgress(++progress); pm.setNote(o.getShortDisplayName()); } else if (o instanceof SQLTable.Folder) { id = "FOL"+objectIdMap.size(); type = "folder"; propNames.put("name", ((SQLTable.Folder) o).getName()); } else if (o instanceof SQLColumn) { id = "COL"+objectIdMap.size(); type = "column"; SQLColumn sourceCol = ((SQLColumn) o).getSourceColumn(); if (sourceCol != null) { logger.debug("column "+o+" source is "+sourceCol+" (hash "+sourceCol.hashCode() +"; id "+objectIdMap.get(sourceCol) +", parent "+sourceCol.getParent()+" hash "+sourceCol.getParent().hashCode() +", parent "+sourceCol.getParent().getParent()+" hash "+sourceCol.getParent().getParent().hashCode() +", parent "+sourceCol.getParent().getParent().getParent()+" hash "+sourceCol.getParent().getParent().getParent().hashCode() +")"); propNames.put("source-column-ref", objectIdMap.get(sourceCol)); } propNames.put("columnName", ((SQLColumn) o).getColumnName()); propNames.put("type", new Integer(((SQLColumn) o).getType())); propNames.put("sourceDBTypeName", ((SQLColumn) o).getSourceDBTypeName()); propNames.put("scale", new Integer(((SQLColumn) o).getScale())); propNames.put("precision", new Integer(((SQLColumn) o).getPrecision())); propNames.put("nullable", new Integer(((SQLColumn) o).getNullable())); propNames.put("remarks", ((SQLColumn) o).getRemarks()); propNames.put("defaultValue", ((SQLColumn) o).getDefaultValue()); propNames.put("primaryKeySeq", ((SQLColumn) o).getPrimaryKeySeq()); propNames.put("autoIncrement", new Boolean(((SQLColumn) o).isAutoIncrement())); } else if (o instanceof SQLRelationship) { id = "REL"+objectIdMap.size(); type = "relationship"; propNames.put("pk-table-ref", objectIdMap.get(((SQLRelationship) o).getPkTable())); propNames.put("fk-table-ref", objectIdMap.get(((SQLRelationship) o).getFkTable())); propNames.put("updateRule", new Integer(((SQLRelationship) o).getUpdateRule())); propNames.put("deleteRule", new Integer(((SQLRelationship) o).getDeleteRule())); propNames.put("deferrability", new Integer(((SQLRelationship) o).getDeferrability())); propNames.put("name", ((SQLRelationship) o).getName()); } else if (o instanceof SQLRelationship.ColumnMapping) { id = "CMP"+objectIdMap.size(); type = "column-mapping"; propNames.put("pk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getPkColumn())); propNames.put("fk-column-ref", objectIdMap.get(((SQLRelationship.ColumnMapping) o).getFkColumn())); } else { throw new UnsupportedOperationException("Woops, the SQLObject type " +o.getClass().getName()+" is not supported!"); } objectIdMap.put(o, id); //print("<"+type+" hashCode=\""+o.hashCode()+"\" id=\""+id+"\" "); print("<"+type+" id=\""+id+"\" "); Iterator props = propNames.keySet().iterator(); while (props.hasNext()) { Object key = props.next(); Object value = propNames.get(key); if (value != null) { niprint(key+"=\""+value+"\" "); } } if (o.allowsChildren()) { niprintln(">"); Iterator children = o.getChildren().iterator(); indent++; while (children.hasNext()) { SQLObject child = (SQLObject) children.next(); if ( ! (child instanceof SQLRelationship)) { saveSQLObject(child); } } if (o instanceof SQLDatabase) { saveRelationships((SQLDatabase) o); } indent--; println("</"+type+">"); } else { niprintln("/>"); } } |
|
Tag tag = getTag(); | public void run(JellyContext context, XMLOutput output) throws Exception { startNamespacePrefixes(output); if ( firstRun ) { firstRun = false; // lets see if we have a dynamic tag tag = findDynamicTag(context, (StaticTag) tag); } try { tag.setContext(context); 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(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } endNamespacePrefixes(output); } |
|
if ( tag == null ) { return; } | public void run(JellyContext context, XMLOutput output) throws Exception { startNamespacePrefixes(output); if ( firstRun ) { firstRun = false; // lets see if we have a dynamic tag tag = findDynamicTag(context, (StaticTag) tag); } try { tag.setContext(context); 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(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } endNamespacePrefixes(output); } |
|
WeblogicApplicationForm appForm = (WeblogicApplicationForm)actionForm; | ApplicationForm appForm = (ApplicationForm)actionForm; | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { WeblogicApplicationForm appForm = (WeblogicApplicationForm)actionForm; ApplicationConfig config = ApplicationConfigManager.getApplicationConfig( appForm.getApplicationId()); assert config != null; config.setName(appForm.getName()); config.setHost(appForm.getHost()); config.setPort(new Integer(appForm.getPort())); config.setUsername(appForm.getUsername()); final String password = appForm.getPassword(); if(!password.equals(config.getPassword())){ config.setPassword(password); } ApplicationConfigManager.updateApplication(config); return mapping.findForward(Forwards.SUCCESS); } |
config.setPort(new Integer(appForm.getPort())); | if(appForm.getPort() != null) config.setPort(new Integer(appForm.getPort())); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { WeblogicApplicationForm appForm = (WeblogicApplicationForm)actionForm; ApplicationConfig config = ApplicationConfigManager.getApplicationConfig( appForm.getApplicationId()); assert config != null; config.setName(appForm.getName()); config.setHost(appForm.getHost()); config.setPort(new Integer(appForm.getPort())); config.setUsername(appForm.getUsername()); final String password = appForm.getPassword(); if(!password.equals(config.getPassword())){ config.setPassword(password); } ApplicationConfigManager.updateApplication(config); return mapping.findForward(Forwards.SUCCESS); } |
if(!password.equals(config.getPassword())){ | if(password != null && !password.equals(config.getPassword())){ | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { WeblogicApplicationForm appForm = (WeblogicApplicationForm)actionForm; ApplicationConfig config = ApplicationConfigManager.getApplicationConfig( appForm.getApplicationId()); assert config != null; config.setName(appForm.getName()); config.setHost(appForm.getHost()); config.setPort(new Integer(appForm.getPort())); config.setUsername(appForm.getUsername()); final String password = appForm.getPassword(); if(!password.equals(config.getPassword())){ config.setPassword(password); } ApplicationConfigManager.updateApplication(config); return mapping.findForward(Forwards.SUCCESS); } |
return new FileScannerTag(new FileScanner(getProject())); | return new FileScannerTag(new FileScanner()); | public TagScript createCustomTagScript(final String name, Attributes attributes) throws Exception { // custom Ant tags if ( name.equals("fileScanner") ) { return new BeanTagScript( new TagFactory() { public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner(getProject())); } } ); } return null; } |
return new FileScannerTag(new FileScanner(getProject())); | return new FileScannerTag(new FileScanner()); | public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner(getProject())); } |
public static Project createProject() { Project project = new Project(); | public static Project createProject(JellyContext context) { GrantProject project = new GrantProject(); project.setPropsHandler(new JellyPropsHandler(context)); | public static Project createProject() { Project project = new Project(); BuildLogger logger = new NoBannerLogger(); logger.setMessageOutputLevel( org.apache.tools.ant.Project.MSG_INFO ); logger.setOutputPrintStream( System.out ); logger.setErrorPrintStream( System.err); project.addBuildListener( logger ); project.init(); // force lazy construction which avoids null pointer exceptions when using // file sets project.getBaseDir(); return project; } |
AntTag tag = new AntTag( getProject(), name ); | AntTag tag = new AntTag( name ); | public Tag createTag(String name) throws Exception { AntTag tag = new AntTag( getProject(), name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return tag; } |
Project project = (Project) context.findVariable( "org.apache.commons.jelly.ant.Project" ); | Project project = (Project) context.findVariable( PROJECT_CONTEXT_HANDLE ); | public static Project getProject(JellyContext context) { Project project = (Project) context.findVariable( "org.apache.commons.jelly.ant.Project" ); if ( project == null ) { project = createProject(); context.setVariable( "org.apache.commons.jelly.ant.Project", project ); } return project; } |
project = createProject(); context.setVariable( "org.apache.commons.jelly.ant.Project", project ); | project = createProject(context); context.setVariable( PROJECT_CONTEXT_HANDLE , project ); | public static Project getProject(JellyContext context) { Project project = (Project) context.findVariable( "org.apache.commons.jelly.ant.Project" ); if ( project == null ) { project = createProject(); context.setVariable( "org.apache.commons.jelly.ant.Project", project ); } return project; } |
TablePane tp = (TablePane) getComponent(j); if (selectedChild == tp) selectedChild = null; if (tp.getModel() == c[i]) { remove(j); fireEvent = true; | if (getComponent(j) instanceof TablePane) { TablePane tp = (TablePane) getComponent(j); if (selectedChild == tp) selectedChild = null; if (tp.getModel() == c[i]) { remove(j); fireEvent = true; } | public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("SQLObject children got removed: "+e); boolean fireEvent = false; SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { try { ArchitectUtils.unlistenToHierarchy(this, c[i]); } catch (ArchitectException ex) { logger.error("Couldn't unlisten to removed object", ex); } if (c[i] instanceof SQLTable) { for (int j = 0; j < getComponentCount(); j++) { TablePane tp = (TablePane) getComponent(j); if (selectedChild == tp) selectedChild = null; if (tp.getModel() == c[i]) { remove(j); fireEvent = true; } } } else if (c[i] instanceof SQLRelationship) { for (int j = 0, n = getComponentCount(); j < n; j++) { Relationship r = (Relationship) getComponent(j); if (selectedChild == r) selectedChild = null; if (r.getModel() == c[i]) { remove(j); fireEvent = true; } } } } if (fireEvent) { firePropertyChange("model.children", null, null); repaint(); } } |
Relationship r = (Relationship) getComponent(j); if (selectedChild == r) selectedChild = null; if (r.getModel() == c[i]) { remove(j); fireEvent = true; | if (getComponent(j) instanceof Relationship) { Relationship r = (Relationship) getComponent(j); if (selectedChild == r) selectedChild = null; if (r.getModel() == c[i]) { remove(j); fireEvent = true; } | public void dbChildrenRemoved(SQLObjectEvent e) { logger.debug("SQLObject children got removed: "+e); boolean fireEvent = false; SQLObject o = e.getSQLSource(); SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { try { ArchitectUtils.unlistenToHierarchy(this, c[i]); } catch (ArchitectException ex) { logger.error("Couldn't unlisten to removed object", ex); } if (c[i] instanceof SQLTable) { for (int j = 0; j < getComponentCount(); j++) { TablePane tp = (TablePane) getComponent(j); if (selectedChild == tp) selectedChild = null; if (tp.getModel() == c[i]) { remove(j); fireEvent = true; } } } else if (c[i] instanceof SQLRelationship) { for (int j = 0, n = getComponentCount(); j < n; j++) { Relationship r = (Relationship) getComponent(j); if (selectedChild == r) selectedChild = null; if (r.getModel() == c[i]) { remove(j); fireEvent = true; } } } } if (fireEvent) { firePropertyChange("model.children", null, null); repaint(); } } |
selectedChild = e.getSelectedItem(); fireSelectionEvent(e.getSelectedItem()); | if (e.getSelectedItem().isSelected()) { logger.debug("Child "+e.getSelectedItem()+" is now selected"); selectedChild = e.getSelectedItem(); fireSelectionEvent(e.getSelectedItem()); } | public void itemSelected(SelectionEvent e) { selectedChild = e.getSelectedItem(); fireSelectionEvent(e.getSelectedItem()); } |
tablePanePopup.addSeparator(); mi = new JMenuItem("Create Relationship"); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem("Show listeners"); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { TablePane tp = (TablePane) getSelection(); JOptionPane.showMessageDialog(tp, new JScrollPane(new JList(new java.util.Vector(tp.getModel().getSQLObjectListeners())))); } }); tablePanePopup.add(mi); | if (logger.isDebugEnabled()) { tablePanePopup.addSeparator(); mi = new JMenuItem("Show listeners"); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { TablePane tp = (TablePane) getSelection(); JOptionPane.showMessageDialog(tp, new JScrollPane(new JList(new java.util.Vector(tp.getModel().getSQLObjectListeners())))); } }); tablePanePopup.add(mi); } | void setupTablePanePopup() { ArchitectFrame af = ArchitectFrame.getMainInstance(); tablePanePopup = new JPopupMenu(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(af.insertColumnAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(af.deleteColumnAction); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem(); mi.setAction(af.editTableAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(af.deleteTableAction); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem("Create Relationship"); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem("Show listeners"); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { TablePane tp = (TablePane) getSelection(); JOptionPane.showMessageDialog(tp, new JScrollPane(new JList(new java.util.Vector(tp.getModel().getSQLObjectListeners())))); } }); tablePanePopup.add(mi); } |
table.initSingleColumnSize(viewColumn); | initSingleColumnSize(viewColumn); | public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); //XXX: Should change to a better condition for size editting // for now, it's just ctrl click on the header if (e.isControlDown()){ table.initSingleColumnSize(viewColumn); } } |
public TableModelColumnAutofit(TableModel tableModel, ProfileTable table){ | public TableModelColumnAutofit(TableModel tableModel, JTable table){ | public TableModelColumnAutofit(TableModel tableModel, ProfileTable table){ this.tableModel = tableModel; this.table = table; mouseListener = new MouseListener(); } |
startDrawingTime = System.currentTimeMillis(); | public void paint( Graphics g ) { super.paint( g ); Graphics2D g2 = (Graphics2D) g; // Current position in which attributes can be drawn Dimension compSize = getSize(); int ypos = ((int)compSize.getHeight())/2; if ( thumbnail != null ) { // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = ((int)(compSize.getWidth() - img.getWidth()))/(int)2; int y = ((int)(compSize.getHeight() - img.getHeight()))/(int)2; g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; } // Draw the attributes if ( photo != null ) { Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000; log.warn( "Accuracy = " + accuracy ); String dateStr = ""; if ( accuracy > 0 ) { // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( "dd.MM.yyyy" ); Date lower = new Date( photo.getShootTime().getTime() - accuracy ); Date upper = new Date( photo.getShootTime().getTime() + accuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lower + " - " + upper; } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( photo.getShootTime() ); } TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = ((int)(compSize.getWidth()-bounds.getWidth()))/2 - (int)bounds.getMinX(); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = ((int)(compSize.getWidth()-bounds.getWidth()))/2 - (int)bounds.getMinX(); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } } } |
|
long endTime = System.currentTimeMillis(); log.debug( "Drawn thumbnail, thumb fetch " + (startDrawingTime - startTime) + ", thumb draw " + (attrDrawingStartTime - startDrawingTime) + ", attribute draw " + (endTime - attrDrawingStartTime) + ", total " + (endTime - startTime) ); | public void paint( Graphics g ) { super.paint( g ); Graphics2D g2 = (Graphics2D) g; // Current position in which attributes can be drawn Dimension compSize = getSize(); int ypos = ((int)compSize.getHeight())/2; if ( thumbnail != null ) { // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = ((int)(compSize.getWidth() - img.getWidth()))/(int)2; int y = ((int)(compSize.getHeight() - img.getHeight()))/(int)2; g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; } // Draw the attributes if ( photo != null ) { Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000; log.warn( "Accuracy = " + accuracy ); String dateStr = ""; if ( accuracy > 0 ) { // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( "dd.MM.yyyy" ); Date lower = new Date( photo.getShootTime().getTime() - accuracy ); Date upper = new Date( photo.getShootTime().getTime() + accuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lower + " - " + upper; } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( photo.getShootTime() ); } TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = ((int)(compSize.getWidth()-bounds.getWidth()))/2 - (int)bounds.getMinX(); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = ((int)(compSize.getWidth()-bounds.getWidth()))/2 - (int)bounds.getMinX(); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } } } |
|
if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } | notifier.run(); | protected void fireTreeNodesChanged(TreeModelEvent e) { final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeNodesChanged(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
if (SwingUtilities.isEventDispatchThread()) { | protected void fireTreeNodesInserted(TreeModelEvent e) { if (logger.isDebugEnabled()) logger.debug("Firing treeNodesInserted event: "+e); final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeNodesInserted(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
|
} else { SwingUtilities.invokeLater(notifier); } | protected void fireTreeNodesInserted(TreeModelEvent e) { if (logger.isDebugEnabled()) logger.debug("Firing treeNodesInserted event: "+e); final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeNodesInserted(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
|
if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } | notifier.run(); | protected void fireTreeNodesRemoved(TreeModelEvent e) { if (logger.isDebugEnabled()) logger.debug("Firing treeNodesRemoved event "+e); final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeNodesRemoved(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
if (SwingUtilities.isEventDispatchThread()) { | protected void fireTreeStructureChanged(TreeModelEvent e) { final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeStructureChanged(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
|
} else { SwingUtilities.invokeLater(notifier); } | protected void fireTreeStructureChanged(TreeModelEvent e) { final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeStructureChanged(ev); } } }; if (SwingUtilities.isEventDispatchThread()) { notifier.run(); } else { SwingUtilities.invokeLater(notifier); } } |
|
for(int i=0; i< parent.getChildCount(); i++){ parent.removeChild(0); } | protected SQLExceptionNode putExceptionNodeUnder(final SQLObject parent, Throwable ex) { // dig for root cause and message logger.info("Adding exception node under "+parent, ex); String message = ex.getMessage(); Throwable cause = ex; while (cause.getCause() != null) { cause = cause.getCause(); if (cause.getMessage() != null && cause.getMessage().length() > 0) { message = cause.getMessage(); } } if (message == null || message.length() == 0) { message = "Check application log for details"; } final SQLExceptionNode excNode = new SQLExceptionNode(ex, message); excNode.setParent((SQLObject) parent); /* This is likely to fail, but it should convince the parent that it is populated */ try { parent.getChildCount(); } catch (ArchitectException e) { logger.error("Couldn't populate parent node of exception"); } try { parent.addChild(excNode); } catch (ArchitectException e) { logger.error("Couldn't add SQLExceptionNode \""+excNode.getName()+"\" to tree model:", e); JOptionPane.showMessageDialog(null, "Failed to add SQLExceptionNode:\n"+e.getMessage()); } return excNode; } |
|
if(!(allele1T == 5 && allele1U == 5 && allele2T !=5 && allele2U != 5) && !(allele1T != 5 && allele1U != 5 && allele2T ==5 && allele2U == 5)) { curRes.tallyInd(allele1T,allele1U); curRes.tallyInd(allele2T,allele2U); } | curRes.tallyInd(allele1T,allele1U); curRes.tallyInd(allele2T,allele2U); | public static Vector calcTDT(Vector chromosomes) { Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for(int k=0;k<numMarkers;k++){ results.add(new TDTResult(Chromosome.getMarker(k))); } for(int i=0;i<chromosomes.size()-3;i++){ Chromosome chrom1T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom1U = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2U = (Chromosome)chromosomes.get(i); //System.out.println("ind1T: " + chrom1T.getPed() + "\t" + chrom1T.getIndividual() ); //System.out.println("ind1U: " + chrom1U.getPed() + "\t" + chrom1U.getIndividual() ); //System.out.println("ind2T: " + chrom2T.getPed() + "\t" + chrom2T.getIndividual() ); //System.out.println("ind2U: " + chrom2U.getPed() + "\t" + chrom2U.getIndividual() ); for(int j=0;j<numMarkers;j++){ byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); TDTResult curRes = (TDTResult)results.get(j); //System.out.println("marker "+ j + ":\t " + allele1T + "\t" + allele1U + "\t" + allele2T + "\t" + allele2U); if(!(allele1T == 5 && allele1U == 5 && allele2T !=5 && allele2U != 5) && !(allele1T != 5 && allele1U != 5 && allele2T ==5 && allele2U == 5)) { //handling missing kid parent het case curRes.tallyInd(allele1T,allele1U); curRes.tallyInd(allele2T,allele2U); } } } for(int i=0;i<results.size();i++){ TDTResult tempRes = (TDTResult)results.get(i); int[][] counts = tempRes.counts; //System.out.println( counts[0][0] + "\t" + counts[1][1] + "\t" + counts[0][1] + "\t" + counts[1][0]); } return results; } |
r.setPkConnectionPoint(translatePoint(e.getPoint())); | r.setPkConnectionPoint(translatePoint(p)); | public void mouseMoved(MouseEvent e) { if (movingPk) { r.setPkConnectionPoint(translatePoint(e.getPoint())); } else { r.setFkConnectionPoint(translatePoint(e.getPoint())); } } |
r.setFkConnectionPoint(translatePoint(e.getPoint())); | r.setFkConnectionPoint(translatePoint(p)); | public void mouseMoved(MouseEvent e) { if (movingPk) { r.setPkConnectionPoint(translatePoint(e.getPoint())); } else { r.setFkConnectionPoint(translatePoint(e.getPoint())); } } |
setOpaque(true); | setOpaque(false); | protected void setup() { pkConnectionPoint = new Point(); fkConnectionPoint = new Point(); updateUI(); setOpaque(true); setBackground(Color.green); model.addSQLObjectListener(this); setToolTipText(model.getName()); ui.bestConnectionPoints(pkTable, fkTable, pkConnectionPoint, // in pktable-space fkConnectionPoint); // in fktable-space createPopup(); setVisible(true); mouseListener = new MouseListener(); addMouseListener(mouseListener); addMouseMotionListener(mouseListener); } |
int missing=0; for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if(theGeno == 0 || nextGeno == 0) missing++; } if (! (missing > theBlock.length/2 || missing > missingLimit)){ | boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= missingLimit){ tooManyMissingInASegment = true; } totalMissing += missing; } if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ | Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] preFiltBlock = (int[])blocks.elementAt(k); int[] theBlock; int[] selectedMarkers = new int[0]; int[] equivClass = new int[0]; if (preFiltBlock.length > 30){ equivClass = new int[preFiltBlock.length]; int classCounter = 0; for (int x = 0; x < preFiltBlock.length; x++){ int marker1 = preFiltBlock[x]; //already been lumped into an equivalency class if (equivClass[x] != 0){ continue; } //start a new equivalency class for this SNP classCounter ++; equivClass[x] = classCounter; for (int y = x+1; y < preFiltBlock.length; y++){ int marker2 = preFiltBlock[y]; if (marker1 > marker2){ int tmp = marker1; marker1 = marker2; marker2 = tmp; } if (filteredDPrimeTable[marker1][marker2].getRSquared() == 1.0){ //these two SNPs are redundant equivClass[y] = classCounter; } } } //parse equivalency classes selectedMarkers = new int[classCounter]; for (int x = 0; x < selectedMarkers.length; x++){ selectedMarkers[x] = -1; } for (int x = 0; x < classCounter; x++){ double genoPC = 1.0; for (int y = 0; y < equivClass.length; y++){ if (equivClass[y] == x+1){ //int[]tossed = new int[3]; if (percentBadGenotypes[preFiltBlock[y]] < genoPC){ selectedMarkers[x] = preFiltBlock[y]; genoPC = percentBadGenotypes[preFiltBlock[y]]; } } } } theBlock = selectedMarkers; Arrays.sort(theBlock); //System.out.println("Block " + k + " " + theBlock.length + "/" + preFiltBlock.length); }else{ theBlock = preFiltBlock; } byte[] thisHap; Vector inputHaploVector = new Vector(); for (int i = 0; i < chromosomes.size(); i++){ thisHap = new byte[theBlock.length]; Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); int missing=0; //int dhet=0; for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if(theGeno == 0 || nextGeno == 0) missing++; } if (! (missing > theBlock.length/2 || missing > missingLimit)){ for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } inputHaploVector.add(thisHap); thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if (nextGeno >= 5){ thisHap[j] = 'h'; } else { if (nextGeno == a1){ thisHap[j] = '1'; }else if (nextGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } inputHaploVector.add(thisHap); } } byte[][] input_haplos = (byte[][])inputHaploVector.toArray(new byte[0][0]); //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } String EMreturn = new String(""); int[] num_haplos_present = new int[1]; Vector haplos_present = new Vector(); Vector haplo_freq = new Vector(); //kirby patch EM theEM = new EM(); theEM.full_em_breakup(input_haplos, 4, num_haplos_present, haplos_present, haplo_freq, block_size, 0); for (int j = 0; j < haplos_present.size(); j++){ EMreturn += (String)haplos_present.elementAt(j)+"\t"+(String)haplo_freq.elementAt(j)+"\t"; } StringTokenizer st = new StringTokenizer(EMreturn); int p = 0; Haplotype[] tempArray = new Haplotype[st.countTokens()/2]; while(st.hasMoreTokens()){ String aString = st.nextToken(); int[] genos = new int[aString.length()]; for (int j = 0; j < aString.length(); j++){ byte returnBit = Byte.parseByte(aString.substring(j,j+1)); if (returnBit == 1){ genos[j] = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); }else{ if (Chromosome.getFilteredMarker(theBlock[j]).getMinor() == 0){ genos[j] = 8; }else{ genos[j] = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); } } } if (selectedMarkers.length > 0){ //we need to reassemble the haplotypes Hashtable hapsHash = new Hashtable(); //add to hash all the genotypes we phased for (int q = 0; q < genos.length; q++){ hapsHash.put(new Integer(theBlock[q]), new Integer(genos[q])); } //now add all the genotypes we didn't bother phasing, based on //which marker they are identical to for (int q = 0; q < equivClass.length; q++){ int currentClass = equivClass[q]-1; if (selectedMarkers[currentClass] == preFiltBlock[q]){ //we alredy added the phased genotypes above continue; } int indexIntoBlock=0; for (int x = 0; x < theBlock.length; x++){ if (theBlock[x] == selectedMarkers[currentClass]){ indexIntoBlock = x; break; } } //this (somewhat laboriously) reconstructs whether to add the minor or major allele if (Chromosome.getFilteredMarker(selectedMarkers[currentClass]).getMajor() == genos[indexIntoBlock]){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getFilteredMarker(preFiltBlock[q]).getMajor())); }else{ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getFilteredMarker(preFiltBlock[q]).getMinor())); } } genos = new int[preFiltBlock.length]; for (int q = 0; q < preFiltBlock.length; q++){ genos[q] = ((Integer)hapsHash.get(new Integer(preFiltBlock[q]))).intValue(); } } double tempPerc = Double.parseDouble(st.nextToken()); if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, preFiltBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; } |
int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } | Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] preFiltBlock = (int[])blocks.elementAt(k); int[] theBlock; int[] selectedMarkers = new int[0]; int[] equivClass = new int[0]; if (preFiltBlock.length > 30){ equivClass = new int[preFiltBlock.length]; int classCounter = 0; for (int x = 0; x < preFiltBlock.length; x++){ int marker1 = preFiltBlock[x]; //already been lumped into an equivalency class if (equivClass[x] != 0){ continue; } //start a new equivalency class for this SNP classCounter ++; equivClass[x] = classCounter; for (int y = x+1; y < preFiltBlock.length; y++){ int marker2 = preFiltBlock[y]; if (marker1 > marker2){ int tmp = marker1; marker1 = marker2; marker2 = tmp; } if (filteredDPrimeTable[marker1][marker2].getRSquared() == 1.0){ //these two SNPs are redundant equivClass[y] = classCounter; } } } //parse equivalency classes selectedMarkers = new int[classCounter]; for (int x = 0; x < selectedMarkers.length; x++){ selectedMarkers[x] = -1; } for (int x = 0; x < classCounter; x++){ double genoPC = 1.0; for (int y = 0; y < equivClass.length; y++){ if (equivClass[y] == x+1){ //int[]tossed = new int[3]; if (percentBadGenotypes[preFiltBlock[y]] < genoPC){ selectedMarkers[x] = preFiltBlock[y]; genoPC = percentBadGenotypes[preFiltBlock[y]]; } } } } theBlock = selectedMarkers; Arrays.sort(theBlock); //System.out.println("Block " + k + " " + theBlock.length + "/" + preFiltBlock.length); }else{ theBlock = preFiltBlock; } byte[] thisHap; Vector inputHaploVector = new Vector(); for (int i = 0; i < chromosomes.size(); i++){ thisHap = new byte[theBlock.length]; Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); int missing=0; //int dhet=0; for (int j = 0; j < theBlock.length; j++){ byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if(theGeno == 0 || nextGeno == 0) missing++; } if (! (missing > theBlock.length/2 || missing > missingLimit)){ for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getFilteredGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } inputHaploVector.add(thisHap); thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); byte nextGeno = nextChrom.getFilteredGenotype(theBlock[j]); if (nextGeno >= 5){ thisHap[j] = 'h'; } else { if (nextGeno == a1){ thisHap[j] = '1'; }else if (nextGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } inputHaploVector.add(thisHap); } } byte[][] input_haplos = (byte[][])inputHaploVector.toArray(new byte[0][0]); //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } String EMreturn = new String(""); int[] num_haplos_present = new int[1]; Vector haplos_present = new Vector(); Vector haplo_freq = new Vector(); //kirby patch EM theEM = new EM(); theEM.full_em_breakup(input_haplos, 4, num_haplos_present, haplos_present, haplo_freq, block_size, 0); for (int j = 0; j < haplos_present.size(); j++){ EMreturn += (String)haplos_present.elementAt(j)+"\t"+(String)haplo_freq.elementAt(j)+"\t"; } StringTokenizer st = new StringTokenizer(EMreturn); int p = 0; Haplotype[] tempArray = new Haplotype[st.countTokens()/2]; while(st.hasMoreTokens()){ String aString = st.nextToken(); int[] genos = new int[aString.length()]; for (int j = 0; j < aString.length(); j++){ byte returnBit = Byte.parseByte(aString.substring(j,j+1)); if (returnBit == 1){ genos[j] = Chromosome.getFilteredMarker(theBlock[j]).getMajor(); }else{ if (Chromosome.getFilteredMarker(theBlock[j]).getMinor() == 0){ genos[j] = 8; }else{ genos[j] = Chromosome.getFilteredMarker(theBlock[j]).getMinor(); } } } if (selectedMarkers.length > 0){ //we need to reassemble the haplotypes Hashtable hapsHash = new Hashtable(); //add to hash all the genotypes we phased for (int q = 0; q < genos.length; q++){ hapsHash.put(new Integer(theBlock[q]), new Integer(genos[q])); } //now add all the genotypes we didn't bother phasing, based on //which marker they are identical to for (int q = 0; q < equivClass.length; q++){ int currentClass = equivClass[q]-1; if (selectedMarkers[currentClass] == preFiltBlock[q]){ //we alredy added the phased genotypes above continue; } int indexIntoBlock=0; for (int x = 0; x < theBlock.length; x++){ if (theBlock[x] == selectedMarkers[currentClass]){ indexIntoBlock = x; break; } } //this (somewhat laboriously) reconstructs whether to add the minor or major allele if (Chromosome.getFilteredMarker(selectedMarkers[currentClass]).getMajor() == genos[indexIntoBlock]){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getFilteredMarker(preFiltBlock[q]).getMajor())); }else{ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getFilteredMarker(preFiltBlock[q]).getMinor())); } } genos = new int[preFiltBlock.length]; for (int q = 0; q < preFiltBlock.length; q++){ genos[q] = ((Integer)hapsHash.get(new Integer(preFiltBlock[q]))).intValue(); } } double tempPerc = Double.parseDouble(st.nextToken()); if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, preFiltBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; } |
|
public Object createObject(Attributes attributes) { | public Object createObject(Attributes attributes) throws ArchitectException{ | public Object createObject(Attributes attributes) { SQLTable tab = new SQLTable(); String id = attributes.getValue("id"); if (id != null) { objectIdMap.put(id, tab); } else { logger.warn("No ID found in table element while loading project!"); } String populated = attributes.getValue("populated"); if (populated != null && populated.equals("false")) { try { tab.initFolders(false); } catch (ArchitectException e) { logger.error("Couldn't add folder to table \""+tab.getName()+"\"", e); JOptionPane.showMessageDialog(null, "Failed to add folder to table:\n"+e.getMessage()); } } return tab; } |
public Tag createTag() throws Exception { | public Tag createTag(String name, Attributes attributes) throws Exception { | public Tag createTag() throws Exception { return (Tag) tagClass.newInstance(); } |
log.warn( "ancestor " + ancestor.getName() ); | protected PhotoFolder[] findFolderPath( PhotoFolder folder ) { // Construct a TreePath for this object // Number of ancestors between this Vector ancestors = new Vector(); // Add first the final folder ancestors.add( folder ); PhotoFolder ancestor = folder.getParentFolder(); while ( ancestor != rootFolder && ancestor != null ) { ancestors.add( ancestor ); ancestor = ancestor.getParentFolder(); } // Add the root folder to the ancestors if ( ancestor == rootFolder ) { ancestors.add( ancestor ); } // Now ancestors has the path but in reversed order. PhotoFolder[] path = new PhotoFolder[ ancestors.size() ]; for ( int m = 0; m < ancestors.size(); m++ ) { path[m] = (PhotoFolder) ancestors.get( ancestors.size()-1-m ); } return path; } |
|
log.warn( "collectionChanged " + path.length ); | public void photoCollectionChanged(PhotoCollectionChangeEvent e) { PhotoFolder changedFolder = (PhotoFolder)e.getSource(); PhotoFolder[] path = findFolderPath( changedFolder ); // Construct the correct event TreeModelEvent treeEvent = new TreeModelEvent( changedFolder, path ); fireTreeModelEvent( treeEvent ); } |
|
log.warn( "structureChanged " + path.length ); | public void structureChanged( PhotoFolderEvent e ) { PhotoFolder changedFolder = (PhotoFolder)e.getSource(); PhotoFolder[] path = findFolderPath( changedFolder ); // Construct the correct event TreeModelEvent treeEvent = new TreeModelEvent( changedFolder, path ); fireTreeModelEvent( treeEvent ); } |
|
log.warn( "subfolderChanged " + path.length ); | public void subfolderChanged( PhotoFolderEvent e ) { PhotoFolder changedFolder = (PhotoFolder)e.getSource(); PhotoFolder[] path = findFolderPath( changedFolder ); // Construct the correct event TreeModelEvent treeEvent = new TreeModelEvent( changedFolder, path ); fireTreeModelEvent( treeEvent ); } |
|
select = createXPathFromBody(xpathContext); | throw new MissingAttributeException( "select" ); | public void doTag(XMLOutput output) throws Exception { Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } String text = select.valueOf(xpathContext); if ( text != null ) { output.write(text); } } |
String text = select.valueOf(xpathContext); | String text = select.stringValueOf(xpathContext); | public void doTag(XMLOutput output) throws Exception { Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } String text = select.valueOf(xpathContext); if ( text != null ) { output.write(text); } } |
final JellyContext newContext = new JellyContext(context); | public void doTag(final XMLOutput output) throws Exception { if ( xmlOutput == null ) { // lets default to system.out xmlOutput = XMLOutput.createXMLOutput( System.out ); } Thread thread = new Thread( new Runnable() { public void run() { try { invokeBody(xmlOutput); xmlOutput.close(); } catch (Exception e) { e.printStackTrace(); } } } ); if ( name != null ) { thread.setName( name ); } thread.start(); } |
|
invokeBody(xmlOutput); | getBody().run(newContext, xmlOutput); | public void doTag(final XMLOutput output) throws Exception { if ( xmlOutput == null ) { // lets default to system.out xmlOutput = XMLOutput.createXMLOutput( System.out ); } Thread thread = new Thread( new Runnable() { public void run() { try { invokeBody(xmlOutput); xmlOutput.close(); } catch (Exception e) { e.printStackTrace(); } } } ); if ( name != null ) { thread.setName( name ); } thread.start(); } |
invokeBody(xmlOutput); | getBody().run(newContext, xmlOutput); | public void run() { try { invokeBody(xmlOutput); xmlOutput.close(); } catch (Exception e) { e.printStackTrace(); } } |
if (configFile == null) configFile = ConfigFile.getDefaultInstance(); | public void actionPerformed(ActionEvent e) { if (configFile == null) configFile = ConfigFile.getDefaultInstance(); try { sprefs.setInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_X, getLocation().x); sprefs.setInt(SwingUserSettings.MAIN_FRAME_Y, getLocation().y); sprefs.setInt(SwingUserSettings.MAIN_FRAME_WIDTH, getWidth()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_HEIGHT, getHeight()); configFile.write(prefs); } catch (ArchitectException ex) { logger.error("Couldn't save settings", ex); } } |
|
sprefs.setInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_X, getLocation().x); sprefs.setInt(SwingUserSettings.MAIN_FRAME_Y, getLocation().y); sprefs.setInt(SwingUserSettings.MAIN_FRAME_WIDTH, getWidth()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_HEIGHT, getHeight()); configFile.write(prefs); } catch (ArchitectException ex) { logger.error("Couldn't save settings", ex); | setProject(new SwingUIProject("New Project")); } catch (Exception ex) { JOptionPane.showMessageDialog(ArchitectFrame.this, "Can't create new project: "+ex.getMessage()); logger.error("Got exception while creating new project", ex); | public void actionPerformed(ActionEvent e) { if (configFile == null) configFile = ConfigFile.getDefaultInstance(); try { sprefs.setInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_X, getLocation().x); sprefs.setInt(SwingUserSettings.MAIN_FRAME_Y, getLocation().y); sprefs.setInt(SwingUserSettings.MAIN_FRAME_WIDTH, getWidth()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_HEIGHT, getHeight()); configFile.write(prefs); } catch (ArchitectException ex) { logger.error("Couldn't save settings", ex); } } |
project = new SwingUIProject("New Project"); setName("Power*Architect: "+project.getName()); | public ArchitectFrame() throws ArchitectException { mainInstance = this; try { ConfigFile cf = ConfigFile.getDefaultInstance(); prefs = cf.read(); sprefs = prefs.getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } project = new SwingUIProject("New Project"); setName("Power*Architect: "+project.getName()); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(saveSettingsAction)); menuBar.add(fileMenu); setJMenuBar(menuBar); playpen = new PlayPen(project.getTargetDatabase()); List databases = project.getSourceDatabases();// Iterator it = prefs.getConnections().iterator();// while (it.hasNext()) {// databases.add(new SQLDatabase((DBConnectionSpec) it.next()));// } dbTree = new DBTree(databases); ((SQLObject) dbTree.getModel().getRoot()).addChild(project.getTargetDatabase()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(dbTree), new JScrollPane(playpen)); cp.add(splitPane, BorderLayout.CENTER); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, dbTree.getPreferredSize().width)); toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(new CreateRelationshipAction(playpen))); cp.add(toolBar, BorderLayout.NORTH); Rectangle bounds = new Rectangle(); bounds.x = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } |
|
playpen = new PlayPen(project.getTargetDatabase()); List databases = project.getSourceDatabases(); dbTree = new DBTree(databases); ((SQLObject) dbTree.getModel().getRoot()).addChild(project.getTargetDatabase()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(dbTree), new JScrollPane(playpen)); cp.add(splitPane, BorderLayout.CENTER); | toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(createRelationshipAction)); cp.add(toolBar, BorderLayout.NORTH); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); getContentPane().add(splitPane, BorderLayout.CENTER); logger.debug("Added splitpane to content pane"); | public ArchitectFrame() throws ArchitectException { mainInstance = this; try { ConfigFile cf = ConfigFile.getDefaultInstance(); prefs = cf.read(); sprefs = prefs.getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } project = new SwingUIProject("New Project"); setName("Power*Architect: "+project.getName()); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(saveSettingsAction)); menuBar.add(fileMenu); setJMenuBar(menuBar); playpen = new PlayPen(project.getTargetDatabase()); List databases = project.getSourceDatabases();// Iterator it = prefs.getConnections().iterator();// while (it.hasNext()) {// databases.add(new SQLDatabase((DBConnectionSpec) it.next()));// } dbTree = new DBTree(databases); ((SQLObject) dbTree.getModel().getRoot()).addChild(project.getTargetDatabase()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(dbTree), new JScrollPane(playpen)); cp.add(splitPane, BorderLayout.CENTER); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, dbTree.getPreferredSize().width)); toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(new CreateRelationshipAction(playpen))); cp.add(toolBar, BorderLayout.NORTH); Rectangle bounds = new Rectangle(); bounds.x = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } |
dbTree.getPreferredSize().width)); toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(new CreateRelationshipAction(playpen))); cp.add(toolBar, BorderLayout.NORTH); | 150)); | public ArchitectFrame() throws ArchitectException { mainInstance = this; try { ConfigFile cf = ConfigFile.getDefaultInstance(); prefs = cf.read(); sprefs = prefs.getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } project = new SwingUIProject("New Project"); setName("Power*Architect: "+project.getName()); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(saveSettingsAction)); menuBar.add(fileMenu); setJMenuBar(menuBar); playpen = new PlayPen(project.getTargetDatabase()); List databases = project.getSourceDatabases();// Iterator it = prefs.getConnections().iterator();// while (it.hasNext()) {// databases.add(new SQLDatabase((DBConnectionSpec) it.next()));// } dbTree = new DBTree(databases); ((SQLObject) dbTree.getModel().getRoot()).addChild(project.getTargetDatabase()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(dbTree), new JScrollPane(playpen)); cp.add(splitPane, BorderLayout.CENTER); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, dbTree.getPreferredSize().width)); toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(new CreateRelationshipAction(playpen))); cp.add(toolBar, BorderLayout.NORTH); Rectangle bounds = new Rectangle(); bounds.x = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } |
setProject(new SwingUIProject("New Project")); | public ArchitectFrame() throws ArchitectException { mainInstance = this; try { ConfigFile cf = ConfigFile.getDefaultInstance(); prefs = cf.read(); sprefs = prefs.getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } project = new SwingUIProject("New Project"); setName("Power*Architect: "+project.getName()); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(saveSettingsAction)); menuBar.add(fileMenu); setJMenuBar(menuBar); playpen = new PlayPen(project.getTargetDatabase()); List databases = project.getSourceDatabases();// Iterator it = prefs.getConnections().iterator();// while (it.hasNext()) {// databases.add(new SQLDatabase((DBConnectionSpec) it.next()));// } dbTree = new DBTree(databases); ((SQLObject) dbTree.getModel().getRoot()).addChild(project.getTargetDatabase()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(dbTree), new JScrollPane(playpen)); cp.add(splitPane, BorderLayout.CENTER); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, dbTree.getPreferredSize().width)); toolBar = new JToolBar(); toolBar.add(new JButton(saveSettingsAction)); toolBar.add(new JButton(new CreateRelationshipAction(playpen))); cp.add(toolBar, BorderLayout.NORTH); Rectangle bounds = new Rectangle(); bounds.x = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } |
|
JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(null); int returned = fc.showOpenDialog(this); | HaploView h = (HaploView) this.getParent(); h.fc.setSelectedFile(null); int returned = h.fc.showOpenDialog(this); | void browse(int browseType){ String name; String markerInfoName = ""; JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(null); int returned = fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = fc.getSelectedFile(); if (browseType == GENO){ name = file.getName(); genoFileField.setText(file.getParent()+File.separator+name); if(infoFileField.getText().equals("")){ //baseName should be everything but the final ".XXX" extension StringTokenizer st = new StringTokenizer(name,"."); String baseName = st.nextToken(); for (int i = 0; i < st.countTokens()-1; i++){ baseName = baseName.concat(".").concat(st.nextToken()); } //check for info file for original file sample.haps //either sample.haps.info or sample.info File maybeMarkers1 = new File(file.getParent(), name + MARKER_DATA_EXT); File maybeMarkers2 = new File(file.getParent(), baseName + MARKER_DATA_EXT); if (maybeMarkers1.exists()){ markerInfoName = maybeMarkers1.getName(); }else if (maybeMarkers2.exists()){ markerInfoName = maybeMarkers2.getName(); }else{ return; } infoFileField.setText(file.getParent()+File.separator+markerInfoName); } }else if (browseType==INFO){ markerInfoName = file.getName(); infoFileField.setText(file.getParent()+File.separator+markerInfoName); } } |
File file = fc.getSelectedFile(); | File file = h.fc.getSelectedFile(); | void browse(int browseType){ String name; String markerInfoName = ""; JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(null); int returned = fc.showOpenDialog(this); if (returned != JFileChooser.APPROVE_OPTION) return; File file = fc.getSelectedFile(); if (browseType == GENO){ name = file.getName(); genoFileField.setText(file.getParent()+File.separator+name); if(infoFileField.getText().equals("")){ //baseName should be everything but the final ".XXX" extension StringTokenizer st = new StringTokenizer(name,"."); String baseName = st.nextToken(); for (int i = 0; i < st.countTokens()-1; i++){ baseName = baseName.concat(".").concat(st.nextToken()); } //check for info file for original file sample.haps //either sample.haps.info or sample.info File maybeMarkers1 = new File(file.getParent(), name + MARKER_DATA_EXT); File maybeMarkers2 = new File(file.getParent(), baseName + MARKER_DATA_EXT); if (maybeMarkers1.exists()){ markerInfoName = maybeMarkers1.getName(); }else if (maybeMarkers2.exists()){ markerInfoName = maybeMarkers2.getName(); }else{ return; } infoFileField.setText(file.getParent()+File.separator+markerInfoName); } }else if (browseType==INFO){ markerInfoName = file.getName(); infoFileField.setText(file.getParent()+File.separator+markerInfoName); } } |
(new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); | (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)); | public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { TablePane tp = (TablePane) evt.getSource(); if (evt.getClickCount() == 2) { // double click if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } } } |
public CompareSchemaWorker (SQLSchema source, SQLSchema target ) throws ArchitectException { | public CompareSchemaWorker (SQLSchema source, SQLSchema target, GenericDDLGenerator gen ) throws ArchitectException { | public CompareSchemaWorker (SQLSchema source, SQLSchema target ) throws ArchitectException { this.source = source; this.target = target; jobSize = source.getChildren().size(); progress = 0; finished = false; } |
ddlGenerator = gen; | public CompareSchemaWorker (SQLSchema source, SQLSchema target ) throws ArchitectException { this.source = source; this.target = target; jobSize = source.getChildren().size(); progress = 0; finished = false; } |
|
OracleDDLGenerator od = new OracleDDLGenerator(); | public void run() { // FIXME: this should not be hardwired to oracle! OracleDDLGenerator od = new OracleDDLGenerator(); final DefaultStyledDocument output = new DefaultStyledDocument(); SimpleAttributeSet attrsSource = new SimpleAttributeSet(); SimpleAttributeSet attrsTarget = new SimpleAttributeSet(); SimpleAttributeSet attrsSame = new SimpleAttributeSet(); SimpleAttributeSet attrsMsg = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrsSource, "Courier New"); StyleConstants.setFontSize(attrsSource, 12); StyleConstants.setForeground(attrsSource, Color.red); StyleConstants.setFontFamily(attrsTarget, "Courier New"); StyleConstants.setFontSize(attrsTarget, 12); StyleConstants.setForeground(attrsTarget, Color.green); StyleConstants.setFontFamily(attrsSame, "Courier New"); StyleConstants.setFontSize(attrsSame, 12); StyleConstants.setForeground(attrsSame, Color.black); StyleConstants.setFontFamily(attrsMsg, "Courier New"); StyleConstants.setFontSize(attrsMsg, 12); StyleConstants.setForeground(attrsMsg, Color.orange); try { List sourceTablesList = source.getChildren(); List targetTablesList = target.getChildren(); Iterator it = sourceTablesList.iterator(); while (it.hasNext()) { SQLObject table = (SQLObject) it.next(); if ( table instanceof SQLTable ) { SQLTable targetTable = targetSQLSchema.getTableByName( table.getName() ); if ( targetTable == null ) { output.insertString(output.getLength(), "<<<TABLE NOT FOUND IN " + targetDatabase.getDataSource().getDisplayName() + "." + targetSchemaDropdown.getSelectedItem() + ">>>" + newline, attrsMsg ); output.insertString(output.getLength(), table.toString() + newline, attrsSource ); } else { output.insertString(output.getLength(), newline + table.toString() + newline, attrsSame ); Iterator it2 = (((SQLTable)table).getColumns()).iterator(); while (it2.hasNext()) { SQLObject column = (SQLObject) it2.next(); if ( column instanceof SQLColumn ) { SQLColumn targetColumn = targetTable.getColumnByName( ((SQLColumn)column).getName() ); if ( targetColumn == null ) { output.insertString(output.getLength(), " <<<NEW COLUMN>>>" + newline, attrsMsg ); output.insertString(output.getLength(), " " + ((SQLColumn)column).toString() + newline, attrsSource ); } else { if ( ((SQLColumn)column).getType() != targetColumn.getType() ) { output.insertString(output.getLength(), " <<<DIFFERENT DATA TYPE>>>" + newline, attrsMsg ); output.insertString(output.getLength(), " " + ((SQLColumn)column).getName(), attrsSame ); output.insertString(output.getLength(), " " + ca.sqlpower.architect.swingui.SQLType.getTypeName(((SQLColumn)column).getType()) +"("+((SQLColumn)column).getScale()+")" + newline, attrsSource ); } else if ( ((SQLColumn)column).getScale() != targetColumn.getScale() ) { output.insertString(output.getLength(), " <<<DIFFERENT SCALE>>>" + newline, attrsMsg ); output.insertString(output.getLength(), " " + ((SQLColumn)column).getName() + " " + ca.sqlpower.architect.swingui.SQLType.getTypeName(((SQLColumn)column).getType()) , attrsSame ); output.insertString(output.getLength(), " ("+((SQLColumn)column).getScale()+")" + newline, attrsSource ); } else { output.insertString(output.getLength(), " " + ca.sqlpower.architect.swingui.SQLType.getTypeName(((SQLColumn)column).getType()) +"("+((SQLColumn)column).getScale()+")" + newline, attrsSame ); } // compare column data type/scale } // column } // is column } // while table children } // table exist } // is table progress++; } // schema children, while loop } catch ( ArchitectException exp ) { System.err.println(exp.toString()); } catch (BadLocationException ble) { System.err.println("Couldn't insert styled text."); } finally { finished = true; } SwingUtilities.invokeLater(new Runnable() { public void run() { outputTextPane.setDocument(output); } }); } |
|
if ( sourceInd ) { sourceSchemaDropdown.removeAllItems(); sourceSchemaDropdown.setVisible(true); Iterator it = schema.iterator(); while (it.hasNext()) { sourceSchemaDropdown.addItem((String)it.next()); } if (sourceSchemaDropdown.getItemCount() >0) { sourceSchemaDropdown.setEnabled(true); } sourceDatabase = db; } else { targetSchemaDropdown.removeAllItems(); targetSchemaDropdown.setVisible(true); Iterator it = schema.iterator(); while (it.hasNext()) { targetSchemaDropdown.addItem((String)it.next()); } if (targetSchemaDropdown.getItemCount() >0) { targetSchemaDropdown.setEnabled(true); } sourceDatabase = db; } startCompareAction.enableIfPossible(); | outputTextPane.setDocument(output); | public void run() { if ( sourceInd ) { sourceSchemaDropdown.removeAllItems(); sourceSchemaDropdown.setVisible(true); Iterator it = schema.iterator(); while (it.hasNext()) { sourceSchemaDropdown.addItem((String)it.next()); } // If it has a schema set this enabled if (sourceSchemaDropdown.getItemCount() >0) { sourceSchemaDropdown.setEnabled(true); } sourceDatabase = db; } else { targetSchemaDropdown.removeAllItems(); targetSchemaDropdown.setVisible(true); Iterator it = schema.iterator(); while (it.hasNext()) { targetSchemaDropdown.addItem((String)it.next()); } // If it has a target set this enabled if (targetSchemaDropdown.getItemCount() >0) { targetSchemaDropdown.setEnabled(true); } sourceDatabase = db; } startCompareAction.enableIfPossible(); } |
public Integer getJobSize() throws ArchitectException { return progressMonitor.getJobSize(); } | public Integer getJobSize() throws ArchitectException; | public Integer getJobSize() throws ArchitectException { return progressMonitor.getJobSize(); } |
public int getProgress() throws ArchitectException { return progressMonitor.getProgress(); } | public int getProgress() throws ArchitectException; | public int getProgress() throws ArchitectException { return progressMonitor.getProgress(); } |
public boolean isFinished() throws ArchitectException { return progressMonitor.isFinished(); } | public boolean isFinished() throws ArchitectException; | public boolean isFinished() throws ArchitectException { return progressMonitor.isFinished(); } |
sourceSQLSchema = sourceDatabase.getSchemaByName((String)sourceSchemaDropdown.getSelectedItem()); targetSQLSchema = targetDatabase.getSchemaByName((String)targetSchemaDropdown.getSelectedItem()); CompareSchemaWorker worker = new CompareSchemaWorker(sourceSQLSchema,targetSQLSchema); StyledDocument styledDoc = outputTextPane.getStyledDocument(); if (styledDoc instanceof AbstractDocument) { outputDoc = (AbstractDocument)styledDoc; } else { System.err.println("Text pane's document isn't an AbstractDocument!"); return; } outputDoc.insertString(outputDoc.getLength(), "Please wait..." + worker.getJobSize() + newline, attrsMsg ); CompareProgressWatcher watcher = new CompareProgressWatcher(progressBar,worker); new javax.swing.Timer(100, watcher).start(); new Thread(worker).start(); | if (targetSQLSchema != null && sourceSQLSchema != null) { LabelValueBean lvb =(LabelValueBean) sqlTypeDropdown.getSelectedItem(); CompareSchemaWorker worker = new CompareSchemaWorker(sourceSQLSchema,targetSQLSchema,(GenericDDLGenerator)(((Class )(lvb.getValue())).newInstance())); StyledDocument styledDoc = outputTextPane.getStyledDocument(); if (styledDoc instanceof AbstractDocument) { outputDoc = (AbstractDocument)styledDoc; } else { System.err.println("Text pane's document isn't an AbstractDocument!"); return; } outputDoc.insertString(outputDoc.getLength(), "Please wait..." + worker.getJobSize() + newline, attrsMsg ); CompareProgressWatcher watcher = new CompareProgressWatcher(progressBar,worker); new javax.swing.Timer(100, watcher).start(); new Thread(worker).start(); } | public void actionPerformed(ActionEvent e) { try { startCompareAction.setEnabled(false); SimpleAttributeSet attrsMsg = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrsMsg, "Courier New"); StyleConstants.setFontSize(attrsMsg, 12); StyleConstants.setForeground(attrsMsg, Color.orange); sourceSQLSchema = sourceDatabase.getSchemaByName((String)sourceSchemaDropdown.getSelectedItem()); targetSQLSchema = targetDatabase.getSchemaByName((String)targetSchemaDropdown.getSelectedItem()); CompareSchemaWorker worker = new CompareSchemaWorker(sourceSQLSchema,targetSQLSchema); StyledDocument styledDoc = outputTextPane.getStyledDocument(); if (styledDoc instanceof AbstractDocument) { outputDoc = (AbstractDocument)styledDoc; } else { System.err.println("Text pane's document isn't an AbstractDocument!"); return; } outputDoc.insertString(outputDoc.getLength(), "Please wait..." + worker.getJobSize() + newline, attrsMsg ); CompareProgressWatcher watcher = new CompareProgressWatcher(progressBar,worker); new javax.swing.Timer(100, watcher).start(); new Thread(worker).start(); } catch ( ArchitectException exp) { logger.error("SchemaListerProgressWatcher failt2", exp); } catch (BadLocationException ble) { System.err.println("Couldn't insert styled text."); } } |
System.err.println("Couldn't insert styled text."); } | logger.error("Couldn't insert styled text."); } catch (InstantiationException ie) { logger.error("Someone put a non GenericDDLGenerator class into the lvb contained in the source pulldown menu",ie); } catch (IllegalAccessException iae) { logger.error("Cannot access the classes's constructor ",iae); } | public void actionPerformed(ActionEvent e) { try { startCompareAction.setEnabled(false); SimpleAttributeSet attrsMsg = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrsMsg, "Courier New"); StyleConstants.setFontSize(attrsMsg, 12); StyleConstants.setForeground(attrsMsg, Color.orange); sourceSQLSchema = sourceDatabase.getSchemaByName((String)sourceSchemaDropdown.getSelectedItem()); targetSQLSchema = targetDatabase.getSchemaByName((String)targetSchemaDropdown.getSelectedItem()); CompareSchemaWorker worker = new CompareSchemaWorker(sourceSQLSchema,targetSQLSchema); StyledDocument styledDoc = outputTextPane.getStyledDocument(); if (styledDoc instanceof AbstractDocument) { outputDoc = (AbstractDocument)styledDoc; } else { System.err.println("Text pane's document isn't an AbstractDocument!"); return; } outputDoc.insertString(outputDoc.getLength(), "Please wait..." + worker.getJobSize() + newline, attrsMsg ); CompareProgressWatcher watcher = new CompareProgressWatcher(progressBar,worker); new javax.swing.Timer(100, watcher).start(); new Thread(worker).start(); } catch ( ArchitectException exp) { logger.error("SchemaListerProgressWatcher failt2", exp); } catch (BadLocationException ble) { System.err.println("Couldn't insert styled text."); } } |
JRadioButton sourcePlayPenRadio = new JRadioButton(); | sourcePlayPenRadio = new JRadioButton(); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
JRadioButton sourcePhysicalRadio = new JRadioButton(); | sourcePhysicalRadio = new JRadioButton(); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
sourceDatabaseDropdown.addActionListener(new ConnectionListener()); | sourceDatabaseDropdown.addActionListener(new CatalogPopulator(sourceSchemaDropdown,sourceCatalogDropdown)); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); | targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
targetDatabaseDropdown.addActionListener(new ConnectionListener()); | targetDatabaseDropdown.addActionListener(new CatalogPopulator(targetSchemaDropdown,targetCatalogDropdown)); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
|
JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); | sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); | private void buildUI() { ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); // layout source database option/combox target combox JRadioButton sourcePlayPenRadio = new JRadioButton(); sourcePlayPenRadio.setName("sourcePlayPenRadio"); sourcePlayPenRadio.setActionCommand("Project"); sourcePlayPenRadio.setSelected(true); JRadioButton sourcePhysicalRadio = new JRadioButton(); sourcePhysicalRadio.setName("sourcePhysicalRadio"); sourcePhysicalRadio.setActionCommand("SQL Connection"); //Group the radio buttons. ButtonGroup sourceButtonGroup = new ButtonGroup(); sourceButtonGroup.add(sourcePlayPenRadio); sourceButtonGroup.add(sourcePhysicalRadio); //Register a listener for the radio buttons. sourcePlayPenRadio.addActionListener(new SourceOptionListener()); sourcePhysicalRadio.addActionListener(new SourceOptionListener()); sourceDatabaseDropdown = new JComboBox(); sourceDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { sourceDatabaseDropdown.addItem(ds); } sourceDatabaseDropdown.setName("sourceDatabaseDropdown"); sourceDatabaseDropdown.addActionListener(new ConnectionListener()); sourceDatabaseDropdown.setEnabled(false); sourceDatabaseDropdown.setRenderer(dataSourceRenderer); sourceNewConnButton = new JButton("New..."); sourceNewConnButton.setName("sourceNewConnButton"); sourceNewConnButton.setEnabled(false); sourceNewConnButton.addActionListener(newConnectionAction); sourceCatalogDropdown = new JComboBox(); sourceCatalogDropdown.setName("sourceCatalogDropdown"); sourceCatalogDropdown.setEnabled(false); sourceSchemaDropdown = new JComboBox(); sourceSchemaDropdown.setName("sourceSchemaDropdown"); sourceSchemaDropdown.setEnabled(false); targetDatabaseDropdown = new JComboBox(); targetDatabaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { targetDatabaseDropdown.addItem(ds); } targetDatabaseDropdown.setName("targetDatabaseDropdown"); targetDatabaseDropdown.setRenderer(dataSourceRenderer); targetDatabaseDropdown.addActionListener(new ConnectionListener()); targetNewConnButton = new JButton("New..."); targetNewConnButton.setName("targetNewConnButton"); targetNewConnButton.setEnabled(true); targetNewConnButton.addActionListener(newConnectionAction); targetCatalogDropdown = new JComboBox(); targetCatalogDropdown.setName("targetCatalogDropdown"); targetCatalogDropdown.setEnabled(false); targetSchemaDropdown = new JComboBox(); targetSchemaDropdown.setName("targetSchemaDropdown"); targetSchemaDropdown.setEnabled(false); progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); // layout compare methods check box and syntax combox JRadioButton sourceLikeTargetButton = new JRadioButton(); sourceLikeTargetButton.setName("sourceLikeTargetButton"); sourceLikeTargetButton.setActionCommand("source like target"); sourceLikeTargetButton.setSelected(false); JRadioButton targetLikeSourceButton = new JRadioButton( ); targetLikeSourceButton.setName("targetLikeSourceButton"); targetLikeSourceButton.setActionCommand("target like source"); targetLikeSourceButton.setSelected(false); JRadioButton justCompareButton = new JRadioButton(); justCompareButton.setName("justCompareButton"); justCompareButton.setActionCommand("compare"); justCompareButton.setSelected(true); //Group the radio buttons. ButtonGroup operationGroup = new ButtonGroup(); operationGroup.add(sourceLikeTargetButton); operationGroup.add(targetLikeSourceButton); operationGroup.add(justCompareButton); JComboBox sqlTypeDropdown = new JComboBox(DDLUtils.getDDLTypes()); sqlTypeDropdown.setName("sqlTypeDropDown"); OutputChoiceListener listener = new OutputChoiceListener(sqlTypeDropdown); JRadioButton sqlButton = new JRadioButton( ); sqlButton.setName("sqlButton"); sqlButton.setActionCommand("sqlButton"); sqlButton.setSelected(true); sqlButton.addActionListener(listener); JRadioButton englishButton = new JRadioButton(); englishButton.setName("englishButton"); englishButton.setActionCommand("english"); englishButton.setSelected(false); englishButton.addActionListener(listener); //Group the radio buttons. ButtonGroup outputGroup = new ButtonGroup(); outputGroup.add(sqlButton); outputGroup.add(englishButton); // outputDoc outputTextPane outputTextPane = new JTextPane(); outputTextPane.setCaretPosition(0); outputTextPane.setMargin(new Insets(5,5,5,5)); JScrollPane scrollPane = new JScrollPane(outputTextPane); scrollPane.setPreferredSize(new Dimension(300, 300)); startCompareAction = new StartCompareAction(); startCompareAction.setEnabled(false); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); FormLayout formLayout = new FormLayout("20dlu, 2dlu, pref, 4dlu," + "pref:grow, 2dlu, pref, 4dlu," + "pref:grow, 4dlu, pref:grow", ""); formLayout.setColumnGroups(new int[][] {{5,9,11}}); JPanel panel = logger.isDebugEnabled() ? new FormDebugPanel() : new JPanel(); DefaultFormBuilder builder = new DefaultFormBuilder(formLayout, panel); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.appendSeparator("Compare Source"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePlayPenRadio); builder.append("Project ["+project.getName()+"]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(sourcePhysicalRadio); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(sourceDatabaseDropdown); builder.append(sourceNewConnButton, sourceCatalogDropdown, sourceSchemaDropdown); builder.appendSeparator("With Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append("Physical Database"); builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(targetDatabaseDropdown); builder.append(targetNewConnButton, targetCatalogDropdown, targetSchemaDropdown); builder.appendSeparator("Output Format"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sqlButton); JPanel ddlTypePanel = new JPanel(new BorderLayout(3,3)); ddlTypePanel.add(new JLabel("SQL for"), BorderLayout.WEST); ddlTypePanel.add(sqlTypeDropdown, BorderLayout.CENTER); // ddl generator type list builder.append(ddlTypePanel); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(englishButton); builder.append("English descriptions"); builder.nextLine(); builder.appendSeparator("Comparison Sense"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(sourceLikeTargetButton); builder.append("How to make Source like Target"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(targetLikeSourceButton); builder.append("How to make Target like Source"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(2); builder.append(justCompareButton); builder.append("Show all differences"); builder.nextLine(); builder.appendSeparator("Status"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.add(new JLabel(""), cc.xy(5, builder.getRow())); builder.add(progressBar, cc.xyw(7, builder.getRow(), 5)); setLayout(new BorderLayout()); add(builder.getPanel()); } |
outputTextPane.setDocument(output); } | f.add(new CompareDMPanel()); f.pack(); f.setVisible(true); }; | public void run() { outputTextPane.setDocument(output); } |
txw.commit(); | public void exportPhoto( File file, int width, int height ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are no instances, nothing can be exported log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { log.warn( "Export: reading image " + original.getImageFile() ); origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); AffineTransform xform = photovault.image. ImageXform.getFittingXform( origWidth, origHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage exportImage = atOp.filter( origImage, null ); // Try to determine the file type based on extension String ftype = "jpg"; String imageFname = file.getName(); int extIndex = imageFname.lastIndexOf( "." ) + 1; if ( extIndex > 0 ) { ftype = imageFname.substring( extIndex ); } try { // Find a writer for that file extensions ImageWriter writer = null; Iterator iter = ImageIO.getImageWritersByFormatName( ftype ); if (iter.hasNext()) writer = (ImageWriter)iter.next(); if (writer != null) { ImageOutputStream ios = null; try { // Prepare output file ios = ImageIO.createImageOutputStream( file ); writer.setOutput(ios); // Set some parameters ImageWriteParam param = writer.getDefaultWriteParam(); // if bi has type ARGB and alpha is false, we have // to tell the writer to not use the alpha // channel: this is especially needed for jpeg // files where imageio seems to produce wrong jpeg // files right now... if (exportImage.getType() == BufferedImage.TYPE_INT_ARGB ) { // this is not so obvious: create a new // ColorModel without OPAQUE transparency and // no alpha channel. ColorModel cm = new ComponentColorModel(exportImage.getColorModel().getColorSpace(), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); // tell the writer to only use the first 3 bands (skip alpha) int[] bands = {0, 1, 2}; param.setSourceBands(bands); // although the java documentation says that // SampleModel can be null, an exception is // thrown in that case therefore a 1*1 // SampleModel that is compatible to cm is // created: param.setDestinationType(new ImageTypeSpecifier(cm, cm.createCompatibleSampleModel(1, 1))); } // Write the image writer.write(null, new IIOImage(exportImage, null, null), param); // Cleanup ios.flush(); } finally { if (ios != null) ios.close(); writer.dispose(); } } } catch ( IOException e ) { log.warn( "Error writing exported image: " + e.getMessage() ); txw.abort(); return; } } |
|
if (messenger == null) { throw new JellyException("No JMS Connection could be found!" ); } | public void doTag(XMLOutput output) throws Exception { ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class ); if ( messengerTag == null ) { throw new JellyException("<jms:destination> tag must be within a <jms:connection> or <jms:send> or <jms:receive> tag"); } Messenger messenger = messengerTag.getConnection(); String subject = (name != null) ? name : getBodyText(); Destination destination = messenger.getDestination( subject ); if ( var != null ) { context.setVariable( var, destination ); } else { MessageOperationTag tag = (MessageOperationTag) findAncestorWithClass( MessageOperationTag.class ); if ( tag == null ) { throw new JellyException("<jms:destination> tag must be within a <jms:send> or <jms:receive> tag or the 'var' attribute should be specified"); } tag.setDestination( destination ); } } |
|
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { // evaluate body as it may contain a <destination> tag getBody().run(context, output); Destination destination = getDestination(); if ( destination == null ) { throw new JellyException( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" ); } Message message = null; if ( timeout > 0 ) { message = getConnection().receive( destination, timeout ); } else if ( timeout == 0 ) { message = getConnection().receiveNoWait( destination ); } else { message = getConnection().receive( destination ); } onMessage( message ); } |
registerTag("file", FileTag.class); | public CoreTagLibrary() { registerTag("jelly", JellyTag.class); // core tags registerTag("out", ExprTag.class); registerTag("forEach", ForEachTag.class); registerTag("set", SetTag.class); // conditional tags registerTag("if", IfTag.class); registerTag("choose", ChooseTag.class); registerTag("when", WhenTag.class); registerTag("otherwise", OtherwiseTag.class); // other tags registerTag("include", IncludeTag.class); registerTag("import", ImportTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("new", NewTag.class); registerTag("whitespace", WhitespaceTag.class); registerTag("thread", ThreadTag.class); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.