bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
private MarkerResult checkMarker(int loc)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; int missing=0, founderHetCount=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0, haploid = 0; Hashtable founderGenoCount = new Hashtable(); Hashtable kidgeno = new Hashtable(); int[] founderHomCount = new int[5]; Vector mendels = new Vector(); int[] count = new int[5]; for(int i=0;i<5;i++) { founderHomCount[i] =0; count[i]=0; } //loop through each family, check data for marker loc Enumeration famList = pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); //if haploid, check for male hets if(Chromosome.getDataChrom().equals("chrx") && currentInd.getGender()==1){ if(allele1 != allele2) { currentInd.zeroOutMarker(loc); pedFile.setHaploidHets(true); } } //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //do mendel check int momAllele1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,0); int momAllele2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,1); int dadAllele1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,0); int dadAllele2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,1); if(Chromosome.getDataChrom().equals("chrx")){ if(currentInd.getGender() == 1) { if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0)){ //this is an x chrom for a male, so the only thing we need to check is if //allele1 matches either momallele1 or momallele2 if(allele1 != momAllele1 && allele1 != momAllele2) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else { //if gender is anything except 1 we assume female if(momAllele1 == momAllele2) { //mom hom and dad matches mom if(dadAllele1 == momAllele1) { //kid must be hom same allele if(allele1 != momAllele1 || allele2 != momAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } }else { //kid must be het if(allele1 == allele2 ){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else{ //mom het,so only need to check that at least one allele matches dad if(allele1 != dadAllele1 && allele2 != dadAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } } }else{ //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } } //end mendel check } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getZeroed(loc)){ allele1 = 0; allele2 = 0; }else{ allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); } String familyID = currentInd.getFamilyID(); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has no parents -- i.e. is a founder if(!currentFamily.hasAncestor(currentInd.getIndividualID())){ //set founderGenoCount if(founderGenoCount.containsKey(familyID)){ int value = ((Integer)founderGenoCount.get(familyID)).intValue() +1; founderGenoCount.put(familyID, new Integer(value)); }else{ founderGenoCount.put(familyID, new Integer(1)); } if (allele1 != 9){ //value of 9 means an 'h' allele for haps files... count[allele1]++; } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 != allele2 || allele1 == 9 || allele2 == 9) { founderHetCount++; }else{ founderHomCount[allele1]++; } if(allele2 != 9){ count[allele2]++; } } }else{ if(kidgeno.containsKey(familyID)){ int value = ((Integer)kidgeno.get(familyID)).intValue() +1; kidgeno.put(familyID, new Integer(value)); } else{ kidgeno.put(familyID, new Integer(1)); } } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 == allele2) { hom++; }else { het++; } }else{ haploid++; } } //missing data else missing++; } currentFamily.setMendErrs(mendErrNum); } double obsHET = getObsHET(het, hom); double freqStuff[] = null; try{ freqStuff = getFreqStuff(count); }catch (PedFileException pfe){ throw new PedFileException("More than two alleles at marker " + (loc+1)); } double preHET = freqStuff[0]; double maf = freqStuff[1]; String minorAllele, majorAllele; if (freqStuff[2] == 1){ minorAllele = "A"; }else if (freqStuff[2] == 2){ minorAllele = "C"; }else if (freqStuff[2] == 3){ minorAllele = "G"; }else{ minorAllele = "T"; } if (freqStuff[3] == 1){ majorAllele = "A"; }else if (freqStuff[3] == 2){ majorAllele = "C"; }else if (freqStuff[3] == 3){ majorAllele = "G"; }else{ majorAllele = "T"; } //HW p value double pvalue = getPValue(founderHomCount, founderHetCount); //geno percent double genopct = getGenoPercent(het, hom, haploid, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(pedFile.getFamList(), founderGenoCount, kidgeno); //rating int rating = this.getRating(genopct, pvalue, mendErrNum,maf); if (mendErrNum > 0 && !pedFile.getMendelsExist()){ pedFile.setMendelsExist(true); } result.setObsHet(obsHET); result.setPredHet(preHET); result.setMAF(maf); result.setMinorAllele(minorAllele); result.setMajorAllele(majorAllele); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setMendelErrors(mendels); return result; }
|
private MarkerResult checkMarker(int loc)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; int missing=0, founderHetCount=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0, haploid = 0; Hashtable founderGenoCount = new Hashtable(); Hashtable kidgeno = new Hashtable(); int[] founderHomCount = new int[5]; Vector mendels = new Vector(); int[] count = new int[5]; for(int i=0;i<5;i++) { founderHomCount[i] =0; count[i]=0; } //loop through each family, check data for marker loc Enumeration famList = pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); //if haploid, check for male hets if(Chromosome.getDataChrom().equals("chrx") && currentInd.getGender()==1){ if(allele1 != allele2) { currentInd.zeroOutMarker(loc); pedFile.setHaploidHets(true); } } //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //do mendel check int momAllele1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,0); int momAllele2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,1); int dadAllele1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,0); int dadAllele2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,1); if(Chromosome.getDataChrom().equals("chrx")){ if(currentInd.getGender() == 1) { if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0)){ //this is an x chrom for a male, so the only thing we need to check is if //allele1 matches either momallele1 or momallele2 if(allele1 != momAllele1 && allele1 != momAllele2) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else { //if gender is anything except 1 we assume female if(momAllele1 == momAllele2) { //mom hom and dad matches mom if(dadAllele1 == momAllele1) { //kid must be hom same allele if(allele1 != momAllele1 || allele2 != momAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } }else { //kid must be het if(allele1 == allele2 ){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else{ //mom het,so only need to check that at least one allele matches dad if(allele1 != dadAllele1 && allele2 != dadAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } } }else{ //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } } //end mendel check } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getZeroed(loc)){ allele1 = 0; allele2 = 0; }else{ allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); } String familyID = currentInd.getFamilyID(); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has no parents -- i.e. is a founder if(!currentFamily.hasAncestor(currentInd.getIndividualID())){ //set founderGenoCount if(founderGenoCount.containsKey(familyID)){ int value = ((Integer)founderGenoCount.get(familyID)).intValue() +1; founderGenoCount.put(familyID, new Integer(value)); }else{ founderGenoCount.put(familyID, new Integer(1)); } if (allele1 != 9){ //value of 9 means an 'h' allele for haps files... count[allele1]++; } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 != allele2 || allele1 == 9 || allele2 == 9) { founderHetCount++; }else{ founderHomCount[allele1]++; } if(allele2 != 9){ count[allele2]++; } } }else{ if(kidgeno.containsKey(familyID)){ int value = ((Integer)kidgeno.get(familyID)).intValue() +1; kidgeno.put(familyID, new Integer(value)); } else{ kidgeno.put(familyID, new Integer(1)); } } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 == allele2) { hom++; }else { het++; } }else{ haploid++; } } //missing data else missing++; } currentFamily.setMendErrs(mendErrNum); } double obsHET = getObsHET(het, hom); double freqStuff[] = null; try{ freqStuff = getFreqStuff(count); }catch (PedFileException pfe){ throw new PedFileException("More than two alleles at marker " + (loc+1)); } double preHET = freqStuff[0]; double maf = freqStuff[1]; String minorAllele, majorAllele; if (freqStuff[2] == 1){ minorAllele = "A"; }else if (freqStuff[2] == 2){ minorAllele = "C"; }else if (freqStuff[2] == 3){ minorAllele = "G"; }else{ minorAllele = "T"; } if (freqStuff[3] == 1){ majorAllele = "A"; }else if (freqStuff[3] == 2){ majorAllele = "C"; }else if (freqStuff[3] == 3){ majorAllele = "G"; }else{ majorAllele = "T"; } //HW p value double pvalue = getPValue(founderHomCount, founderHetCount); //geno percent double genopct = getGenoPercent(het, hom, haploid, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(pedFile.getFamList(), founderGenoCount, kidgeno); //rating int rating = this.getRating(genopct, pvalue, mendErrNum,maf); if (mendErrNum > 0 && !pedFile.getMendelsExist()){ pedFile.setMendelsExist(true); } result.setObsHet(obsHET); result.setPredHet(preHET); result.setMAF(maf); result.setMinorAllele(minorAllele); result.setMajorAllele(majorAllele); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setMendelErrors(mendels); return result; }
| 1,112,620
|
private MarkerResult checkMarker(int loc)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; int missing=0, founderHetCount=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0, haploid = 0; Hashtable founderGenoCount = new Hashtable(); Hashtable kidgeno = new Hashtable(); int[] founderHomCount = new int[5]; Vector mendels = new Vector(); int[] count = new int[5]; for(int i=0;i<5;i++) { founderHomCount[i] =0; count[i]=0; } //loop through each family, check data for marker loc Enumeration famList = pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); //if haploid, check for male hets if(Chromosome.getDataChrom().equals("chrx") && currentInd.getGender()==1){ if(allele1 != allele2) { currentInd.zeroOutMarker(loc); pedFile.setHaploidHets(true); } } //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //do mendel check int momAllele1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,0); int momAllele2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,1); int dadAllele1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,0); int dadAllele2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,1); if(Chromosome.getDataChrom().equals("chrx")){ if(currentInd.getGender() == 1) { if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0)){ //this is an x chrom for a male, so the only thing we need to check is if //allele1 matches either momallele1 or momallele2 if(allele1 != momAllele1 && allele1 != momAllele2) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else { //if gender is anything except 1 we assume female if(momAllele1 == momAllele2) { //mom hom and dad matches mom if(dadAllele1 == momAllele1) { //kid must be hom same allele if(allele1 != momAllele1 || allele2 != momAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } }else { //kid must be het if(allele1 == allele2 ){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else{ //mom het,so only need to check that at least one allele matches dad if(allele1 != dadAllele1 && allele2 != dadAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } } }else{ //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } } //end mendel check } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getZeroed(loc)){ allele1 = 0; allele2 = 0; }else{ allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); } String familyID = currentInd.getFamilyID(); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has no parents -- i.e. is a founder if(!currentFamily.hasAncestor(currentInd.getIndividualID())){ //set founderGenoCount if(founderGenoCount.containsKey(familyID)){ int value = ((Integer)founderGenoCount.get(familyID)).intValue() +1; founderGenoCount.put(familyID, new Integer(value)); }else{ founderGenoCount.put(familyID, new Integer(1)); } if (allele1 != 9){ //value of 9 means an 'h' allele for haps files... count[allele1]++; } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 != allele2 || allele1 == 9 || allele2 == 9) { founderHetCount++; }else{ founderHomCount[allele1]++; } if(allele2 != 9){ count[allele2]++; } } }else{ if(kidgeno.containsKey(familyID)){ int value = ((Integer)kidgeno.get(familyID)).intValue() +1; kidgeno.put(familyID, new Integer(value)); } else{ kidgeno.put(familyID, new Integer(1)); } } if (!Chromosome.getDataChrom().equals("chrx") || currentInd.getGender() != 1) { if(allele1 == allele2) { hom++; }else { het++; } }else{ haploid++; } } //missing data else missing++; } currentFamily.setMendErrs(mendErrNum); } double obsHET = getObsHET(het, hom); double freqStuff[] = null; try{ freqStuff = getFreqStuff(count); }catch (PedFileException pfe){ throw new PedFileException("More than two alleles at marker " + (loc+1)); } double preHET = freqStuff[0]; double maf = freqStuff[1]; String minorAllele, majorAllele; if (freqStuff[2] == 1){ minorAllele = "A"; }else if (freqStuff[2] == 2){ minorAllele = "C"; }else if (freqStuff[2] == 3){ minorAllele = "G"; }else{ minorAllele = "T"; } if (freqStuff[3] == 1){ majorAllele = "A"; }else if (freqStuff[3] == 2){ majorAllele = "C"; }else if (freqStuff[3] == 3){ majorAllele = "G"; }else{ majorAllele = "T"; } //HW p value double pvalue = getPValue(founderHomCount, founderHetCount); //geno percent double genopct = getGenoPercent(het, hom, haploid, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(pedFile.getFamList(), founderGenoCount, kidgeno); //rating int rating = this.getRating(genopct, pvalue, mendErrNum,maf); if (mendErrNum > 0 && !pedFile.getMendelsExist()){ pedFile.setMendelsExist(true); } result.setObsHet(obsHET); result.setPredHet(preHET); result.setMAF(maf); result.setMinorAllele(minorAllele); result.setMajorAllele(majorAllele); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setMendelErrors(mendels); return result; }
|
private MarkerResult checkMarker(int loc)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; int missing=0, founderHetCount=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0, haploid = 0; Hashtable founderGenoCount = new Hashtable(); Hashtable kidgeno = new Hashtable(); int[] founderHomCount = new int[5]; Vector mendels = new Vector(); int[] count = new int[5]; for(int i=0;i<5;i++) { founderHomCount[i] =0; count[i]=0; } //loop through each family, check data for marker loc Enumeration famList = pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); //if haploid, check for male hets if(Chromosome.getDataChrom().equals("chrx") && currentInd.getGender()==1){ if(allele1 != allele2) { currentInd.zeroOutMarker(loc); pedFile.setHaploidHets(true); } } //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //do mendel check int momAllele1 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,0); int momAllele2 = (currentFamily.getMember(currentInd.getMomID())).getAllele(loc,1); int dadAllele1 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,0); int dadAllele2 = (currentFamily.getMember(currentInd.getDadID())).getAllele(loc,1); if(Chromosome.getDataChrom().equals("chrx")){ if(currentInd.getGender() == 1) { if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0)){ //this is an x chrom for a male, so the only thing we need to check is if //allele1 matches either momallele1 or momallele2 if(allele1 != momAllele1 && allele1 != momAllele2) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else { //if gender is anything except 1 we assume female if(momAllele1 == momAllele2) { //mom hom and dad matches mom if(dadAllele1 == momAllele1) { //kid must be hom same allele if(allele1 != momAllele1 || allele2 != momAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } }else { //kid must be het if(allele1 == allele2 ){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } }else{ //mom het,so only need to check that at least one allele matches dad if(allele1 != dadAllele1 && allele2 != dadAllele2){ mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } } }else{ //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; MendelError mend = new MendelError(currentInd.getFamilyID(), currentInd.getIndividualID()); mendels.add(mend); currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } } //end mendel check } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getZeroed(loc)){ allele1 = 0; allele2 = 0; }else{ allele1 = currentInd.getAllele(loc,0); allele2 = currentInd.getAllele(loc,1); } String familyID = currentInd.getFamilyID(); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has no parents -- i.e. is a founder if(!currentFamily.hasAncestor(currentInd.getIndividualID())){ //set founderGenoCount if(founderGenoCount.containsKey(familyID)){ int value = ((Integer)founderGenoCount.get(familyID)).intValue() +1; founderGenoCount.put(familyID, new Integer(value)); }else{ founderGenoCount.put(familyID, new Integer(1)); } if (allele1 != 9){ //value of 9 means an 'h' allele for haps files... count[allele1]++; } if (!Chromosome.getDataChrom().equalsIgnoreCase("chrx") || currentInd.getGender() != 1) { if(allele1 != allele2 || allele1 == 9 || allele2 == 9) { founderHetCount++; }else{ founderHomCount[allele1]++; } if(allele2 != 9){ count[allele2]++; } } }else{ if(kidgeno.containsKey(familyID)){ int value = ((Integer)kidgeno.get(familyID)).intValue() +1; kidgeno.put(familyID, new Integer(value)); } else{ kidgeno.put(familyID, new Integer(1)); } } if (!Chromosome.getDataChrom().equalsIgnoreCase("chrx") || currentInd.getGender() != 1) { if(allele1 == allele2) { hom++; }else { het++; } }else{ haploid++; } } //missing data else missing++; } currentFamily.setMendErrs(mendErrNum); } double obsHET = getObsHET(het, hom); double freqStuff[] = null; try{ freqStuff = getFreqStuff(count); }catch (PedFileException pfe){ throw new PedFileException("More than two alleles at marker " + (loc+1)); } double preHET = freqStuff[0]; double maf = freqStuff[1]; String minorAllele, majorAllele; if (freqStuff[2] == 1){ minorAllele = "A"; }else if (freqStuff[2] == 2){ minorAllele = "C"; }else if (freqStuff[2] == 3){ minorAllele = "G"; }else{ minorAllele = "T"; } if (freqStuff[3] == 1){ majorAllele = "A"; }else if (freqStuff[3] == 2){ majorAllele = "C"; }else if (freqStuff[3] == 3){ majorAllele = "G"; }else{ majorAllele = "T"; } //HW p value double pvalue = getPValue(founderHomCount, founderHetCount); //geno percent double genopct = getGenoPercent(het, hom, haploid, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(pedFile.getFamList(), founderGenoCount, kidgeno); //rating int rating = this.getRating(genopct, pvalue, mendErrNum,maf); if (mendErrNum > 0 && !pedFile.getMendelsExist()){ pedFile.setMendelsExist(true); } result.setObsHet(obsHET); result.setPredHet(preHET); result.setMAF(maf); result.setMinorAllele(minorAllele); result.setMajorAllele(majorAllele); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setMendelErrors(mendels); return result; }
| 1,112,621
|
protected void createUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tabPane = new JTabbedPane(); add( tabPane, BorderLayout.CENTER ); // General pane JPanel generalPane = new JPanel(); tabPane.addTab( "General", generalPane ); // Create the fields & their labels // Photographer field JLabel photographerLabel = new JLabel( "Photographer" ); photographerField = new JTextField( 30 ); photographerDoc = photographerField.getDocument(); photographerDoc.addDocumentListener( this ); photographerDoc.putProperty( FIELD_NAME, PhotoInfoController.PHOTOGRAPHER ); // Shooting date field JLabel shootingDayLabel = new JLabel( "Shooting date" ); DateFormat df = DateFormat.getDateInstance(); DateFormatter shootingDayFormatter = new DateFormatter( df ); shootingDayField = new JFormattedTextField( df ); shootingDayField.setColumns( 10 ); shootingDayField.setValue( new Date( )); shootingDayField.addPropertyChangeListener( this ); shootingDayField.putClientProperty( FIELD_NAME, PhotoInfoController.SHOOTING_DATE ); // Shooting place field JLabel shootingPlaceLabel = new JLabel( "Shooting place" ); shootingPlaceField = new JTextField( 30 ); shootingPlaceDoc = shootingPlaceField.getDocument(); shootingPlaceDoc.addDocumentListener( this ); shootingPlaceDoc.putProperty( FIELD_NAME, PhotoInfoController.SHOOTING_PLACE ); // Description text JLabel descLabel = new JLabel( "Description" ); descriptionTextArea = new JTextArea( 5, 40 ); descriptionTextArea.setLineWrap( true ); descriptionTextArea.setWrapStyleWord( true ); JScrollPane descScrollPane = new JScrollPane( descriptionTextArea ); descScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); Border descBorder = BorderFactory.createEtchedBorder( EtchedBorder.LOWERED ); descBorder = BorderFactory.createTitledBorder( descBorder, "Description" ); descScrollPane.setBorder( descBorder ); descriptionDoc = descriptionTextArea.getDocument(); descriptionDoc.putProperty( FIELD_NAME, PhotoInfoController.DESCRIPTION ); descriptionDoc.addDocumentListener( this ); // Save button JButton saveBtn = new JButton( "Save" ); saveBtn.setActionCommand( "save" ); saveBtn.addActionListener( this ); // Discard button JButton discardBtn = new JButton( "Discard" ); discardBtn.setActionCommand( "discard" ); discardBtn.addActionListener( this ); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); generalPane.setLayout( layout ); JLabel[] labels = { photographerLabel, shootingDayLabel, shootingPlaceLabel }; JTextField[] fields = { photographerField, shootingDayField, shootingPlaceField }; addLabelTextRows( labels, fields, layout, generalPane ); generalPane.add( descScrollPane ); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints( descScrollPane, c ); c = new GridBagConstraints(); c.gridwidth = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridy = GridBagConstraints.RELATIVE; c.gridy = GridBagConstraints.RELATIVE; createTechDataUI(); // Create a pane for the buttols JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(saveBtn); add( buttonPane, BorderLayout.SOUTH ); }
|
protected void createUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tabPane = new JTabbedPane(); add( tabPane, BorderLayout.CENTER ); // General pane JPanel generalPane = new JPanel(); tabPane.addTab( "General", generalPane ); // Create the fields & their labels // Photographer field JLabel photographerLabel = new JLabel( "Photographer" ); photographerField = new JTextField( 30 ); photographerDoc = photographerField.getDocument(); photographerDoc.addDocumentListener( this ); photographerDoc.putProperty( FIELD_NAME, PhotoInfoController.PHOTOGRAPHER ); // Shooting date field JLabel shootingDayLabel = new JLabel( "Shooting date" ); DateFormat df = DateFormat.getDateInstance(); DateFormatter shootingDayFormatter = new DateFormatter( df ); shootingDayField = new JFormattedTextField( df ); shootingDayField.setColumns( 10 ); shootingDayField.setValue( new Date( )); shootingDayField.addPropertyChangeListener( this ); shootingDayField.putClientProperty( FIELD_NAME, PhotoInfoController.SHOOTING_DATE ); // Shooting place field JLabel shootingPlaceLabel = new JLabel( "Shooting place" ); shootingPlaceField = new JTextField( 30 ); shootingPlaceDoc = shootingPlaceField.getDocument(); shootingPlaceDoc.addDocumentListener( this ); shootingPlaceDoc.putProperty( FIELD_NAME, PhotoInfoController.SHOOTING_PLACE ); // Description text JLabel descLabel = new JLabel( "Description" ); descriptionTextArea = new JTextArea( 5, 40 ); descriptionTextArea.setLineWrap( true ); descriptionTextArea.setWrapStyleWord( true ); JScrollPane descScrollPane = new JScrollPane( descriptionTextArea ); descScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); Border descBorder = BorderFactory.createEtchedBorder( EtchedBorder.LOWERED ); descBorder = BorderFactory.createTitledBorder( descBorder, "Description" ); descScrollPane.setBorder( descBorder ); descriptionDoc = descriptionTextArea.getDocument(); descriptionDoc.putProperty( FIELD_NAME, PhotoInfoController.DESCRIPTION ); descriptionDoc.addDocumentListener( this ); // Save button JButton saveBtn = new JButton( "Save" ); saveBtn.setActionCommand( "save" ); saveBtn.addActionListener( this ); // Discard button JButton discardBtn = new JButton( "Discard" ); discardBtn.setActionCommand( "discard" ); discardBtn.addActionListener( this ); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); generalPane.setLayout( layout ); JLabel[] labels = { photographerLabel, shootingDayLabel, shootingPlaceLabel }; JTextField[] fields = { photographerField, shootingDayField, shootingPlaceField }; addLabelTextRows( labels, fields, layout, generalPane ); generalPane.add( descScrollPane ); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints( descScrollPane, c ); c = new GridBagConstraints(); c.gridwidth = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridy = GridBagConstraints.RELATIVE; c.gridy = GridBagConstraints.RELATIVE; createTechDataUI(); // Create a pane for the buttols JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(saveBtn); }
| 1,112,622
|
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); String text = getBodyText(); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { Object[] args = { text }; method.invoke(task, args); } task.perform(); }
|
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { Object[] args = { text }; method.invoke(task, args); } task.perform(); }
| 1,112,623
|
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); String text = getBodyText(); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { Object[] args = { text }; method.invoke(task, args); } task.perform(); }
|
public void doTag(XMLOutput output) throws Exception { Task task = getTask(); String text = getBodyText(); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { Object[] args = { text } else { getBody().run(context, output); }; method.invoke(task, args); } else { getBody().run(context, output); } task.perform(); } else { getBody().run(context, output); }
| 1,112,624
|
public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } return task; }
|
public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } return task; }
| 1,112,625
|
public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } return task; }
|
public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } return this.task; }
| 1,112,626
|
public void setTask(Task task) { this.task = task; setDynaBean( new ConvertingWrapDynaBean(task) ); }
|
public void setTask(Task task) { this.task = task; setDynaBean( new ConvertingWrapDynaBean( this.task ) ); }
| 1,112,627
|
public ServerConnection getServerConnection(ApplicationConfig config) throws ConnectionFailedException { try { /* Create an RMI connector client */ HashMap env = new HashMap(); String[] credentials = new String[] {config.getUsername(), config.getPassword()}; env.put("jmx.remote.credentials", credentials); JMXServiceURL url = new JMXServiceURL(config.getURL()); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); return new JSR160ServerConnection(mbsc); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
|
public ServerConnection getServerConnection(ApplicationConfig config) throws ConnectionFailedException { try { /* Create an RMI connector client */ HashMap env = new HashMap(); String[] credentials = new String[] {config.getUsername(), config.getPassword()}; env.put("jmx.remote.credentials", credentials); JMXServiceURL url = new JMXServiceURL(config.getURL()); JMXConnector jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); return new JSR160ServerConnection(mbsc); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
| 1,112,628
|
public void testDatabaseInsert()throws ArchitectException { // setup a playpen like database SQLDatabase db = new SQLDatabase(); UndoManager undoManager = new UndoManager(db); db.setIgnoreReset(true); SQLTable table1 = new SQLTable(db,"table1","remark1","TABLE",true); SQLTable table2 = new SQLTable(db,"table2","remark2","TABLE",true); SQLTable table3 = new SQLTable(db,"table3","remark3","TABLE",true); SQLTable table4 = new SQLTable(db,"table4","remark4","TABLE",true); db.addChild(table1); db.addChild(table2); db.addChild(table3); db.addChild(table4); db.removeChild(2); undoManager.undo(); assertEquals("There should be 4 children",4,db.getChildCount()); assertEquals("The first table is in the wrong position",table1,db.getChild(0)); assertEquals("The Second table is in the wrong position",table2,db.getChild(1)); assertEquals("The Third table is in the wrong position",table3,db.getChild(2)); assertEquals("The Fourth table is in the wrong position",table4,db.getChild(3)); undoManager.redo(); assertEquals("There should be 3 children",3,db.getChildCount()); assertEquals("The first table is in the wrong position",table1,db.getChild(0)); assertEquals("The Second table is in the wrong position",table2,db.getChild(1)); assertEquals("The Third table is in the wrong position",table4,db.getChild(2)); }
|
public void testDatabaseInsert()throws ArchitectException { // setup a playpen like database SQLDatabase db = new SQLDatabase(); UndoManager undoManager = new UndoManager(db); db.setPlayPenDatabase(true); SQLTable table1 = new SQLTable(db,"table1","remark1","TABLE",true); SQLTable table2 = new SQLTable(db,"table2","remark2","TABLE",true); SQLTable table3 = new SQLTable(db,"table3","remark3","TABLE",true); SQLTable table4 = new SQLTable(db,"table4","remark4","TABLE",true); db.addChild(table1); db.addChild(table2); db.addChild(table3); db.addChild(table4); db.removeChild(2); undoManager.undo(); assertEquals("There should be 4 children",4,db.getChildCount()); assertEquals("The first table is in the wrong position",table1,db.getChild(0)); assertEquals("The Second table is in the wrong position",table2,db.getChild(1)); assertEquals("The Third table is in the wrong position",table3,db.getChild(2)); assertEquals("The Fourth table is in the wrong position",table4,db.getChild(3)); undoManager.redo(); assertEquals("There should be 3 children",3,db.getChildCount()); assertEquals("The first table is in the wrong position",table1,db.getChild(0)); assertEquals("The Second table is in the wrong position",table2,db.getChild(1)); assertEquals("The Third table is in the wrong position",table4,db.getChild(2)); }
| 1,112,629
|
public void testPhotoAddition() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } PhotoFolder folder = null; // Create a folder for the photo try { folder = PhotoFolder.create( "Top", null ); folder.addPhoto( photo ); assertEquals( "Photo not visible in folders' photo count", folder.getPhotoCount(), 1 ); } finally { // Clean up the test folder PhotoFolder parent = folder.getParentFolder(); parent.removeSubfolder( folder ); } }
|
public void testPhotoAddition() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } PhotoFolder folder = null; // Create a folder for the photo try { folder = PhotoFolder.create( "PhotoAdditionTest", PhotoFolder.getRoot() ); folder.addPhoto( photo ); assertEquals( "Photo not visible in folders' photo count", folder.getPhotoCount(), 1 ); } finally { // Clean up the test folder PhotoFolder parent = folder.getParentFolder(); parent.removeSubfolder( folder ); } }
| 1,112,630
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"Top\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 0 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 0 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
| 1,112,631
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"Top\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 0 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"Top\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 1 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
| 1,112,632
|
public void setUp() { // Create several photos with different shooting dates // Add them to a collection so that they are easy to delete afterwards Calendar cal = Calendar.getInstance(); photos = new Vector(); uids = new Vector(); cal.set( 2002, 11, 23 ); makePhoto( cal, "Katsokaa kun Lassi ui" ); cal.set( 2002, 11, 24 ); makePhoto( cal, "Lassille kuuluu hyv" ); makePhoto( cal, "" ); cal.set( 2002, 11, 25 ); makePhoto( cal, "" ); folder = PhotoFolder.create( "QueryTest", PhotoFolder.getRoot() ); subfolder = PhotoFolder.create( "QueryTest subfolder", folder ); folder.addPhoto( (PhotoInfo)photos.get(0) ); subfolder.addPhoto( (PhotoInfo)photos.get(3) ); folder.addPhoto( (PhotoInfo)photos.get(2) ); }
|
public void setUp() { // Create several photos with different shooting dates // Add them to a collection so that they are easy to delete afterwards Calendar cal = Calendar.getInstance(); photos = new Vector(); uids = new Vector(); cal.set( 2002, 11, 23 ); makePhoto( cal, "Katsokaa kun Lassi ui" ); cal.set( 2002, 11, 24 ); makePhoto( cal, "Lassille kuuluu hyvaa" ); makePhoto( cal, "" ); cal.set( 2002, 11, 25 ); makePhoto( cal, "" ); folder = PhotoFolder.create( "QueryTest", PhotoFolder.getRoot() ); subfolder = PhotoFolder.create( "QueryTest subfolder", folder ); folder.addPhoto( (PhotoInfo)photos.get(0) ); subfolder.addPhoto( (PhotoInfo)photos.get(3) ); folder.addPhoto( (PhotoInfo)photos.get(2) ); }
| 1,112,633
|
protected void fireDbChildrenRemoved(int[] oldIndices, List oldChildren) { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbChildrenRemoved event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent (this, oldIndices, (SQLObject[]) oldChildren.toArray(new SQLObject[oldChildren.size()]), isSecondaryChangeMode()); synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { ((SQLObjectListener) it.next()).dbChildrenRemoved(e); } } }
|
protected void fireDbChildrenRemoved(int[] oldIndices, List oldChildren) { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbChildrenRemoved event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent (this, oldIndices, (SQLObject[]) oldChildren.toArray(new SQLObject[oldChildren.size()]), isSecondaryChangeMode()); synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { ((SQLObjectListener) it.next()).dbChildrenRemoved(e); } } }
| 1,112,634
|
protected void fireDbObjectChanged(String propertyName, Object oldValue, Object newValue) { SQLObjectEvent e = new SQLObjectEvent( this, propertyName, oldValue, newValue, isSecondaryChangeMode()); boolean same = (oldValue == null ? oldValue == newValue : oldValue.equals(newValue)); if (same) { logger.debug("Object changed event aborted, the old value '"+oldValue+"' of " +propertyName+" equals the new value '"+newValue+"'"); return; } if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbObjectChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbObjectChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
|
protected void fireDbObjectChanged(String propertyName, Object oldValue, Object newValue) { SQLObjectEvent e = new SQLObjectEvent( this, propertyName, oldValue, newValue, isSecondaryChangeMode()); boolean same = (oldValue == null ? oldValue == newValue : oldValue.equals(newValue)); if (same) { logger.debug("Object changed event aborted, the old value '"+oldValue+"' of " +propertyName+" equals the new value '"+newValue+"'"); return; } if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbObjectChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbObjectChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
| 1,112,635
|
protected void fireDbObjectChanged(String propertyName, Object oldValue, Object newValue) { SQLObjectEvent e = new SQLObjectEvent( this, propertyName, oldValue, newValue, isSecondaryChangeMode()); boolean same = (oldValue == null ? oldValue == newValue : oldValue.equals(newValue)); if (same) { logger.debug("Object changed event aborted, the old value '"+oldValue+"' of " +propertyName+" equals the new value '"+newValue+"'"); return; } if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbObjectChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbObjectChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
|
protected void fireDbObjectChanged(String propertyName, Object oldValue, Object newValue) { SQLObjectEvent e = new SQLObjectEvent( this, propertyName, oldValue, newValue, isSecondaryChangeMode()); boolean same = (oldValue == null ? oldValue == newValue : oldValue.equals(newValue)); if (same) { logger.debug("Object changed event aborted, the old value '"+oldValue+"' of " +propertyName+" equals the new value '"+newValue+"'"); return; } if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbObjectChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; listeners[i].dbObjectChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
| 1,112,636
|
public void fireDbStructureChanged() { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbStructureChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent( this, null, isSecondaryChangeMode()); int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbStructureChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
|
public void fireDbStructureChanged() { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbStructureChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent( this, null, isSecondaryChangeMode()); int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbStructureChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
| 1,112,637
|
public void fireDbStructureChanged() { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbStructureChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent( this, null, isSecondaryChangeMode()); int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; ((SQLObjectListener) it.next()).dbStructureChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
|
public void fireDbStructureChanged() { if (logger.isDebugEnabled()) { logger.debug(getClass().getName()+" "+toString()+": " + "firing dbStructureChanged event " + "(secondary = "+isSecondaryChangeMode()+")"); } SQLObjectEvent e = new SQLObjectEvent( this, null, isSecondaryChangeMode()); int count = 0; synchronized(sqlObjectListeners) { Iterator it = sqlObjectListeners.iterator(); while (it.hasNext()) { count++; listeners[i].dbStructureChanged(e); } } if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners."); }
| 1,112,638
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { Iterator it = undoEventListeners.iterator(); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { UndoCompoundEventListener[] listeners = sqlObjectListeners.toArray(new UndoCompoundEventListener[0]); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
| 1,112,639
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { Iterator it = undoEventListeners.iterator(); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { Iterator it = undoEventListeners.iterator(); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
| 1,112,640
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { Iterator it = undoEventListeners.iterator(); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
|
protected void fireUndoCompoundEvent(UndoCompoundEvent e) { Iterator it = undoEventListeners.iterator(); if (e.getType().isStartEvent()) { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditStart(e); } } else { while (it.hasNext()) { ((UndoCompoundEventListener) it.next()).compoundEditEnd(e); } } }
| 1,112,641
|
protected SAXException createSAXException(String message, Exception e) { log.warn("Underlying exception: " + e); e.printStackTrace(); if (locator != null) { String error = "Error at (" + locator.getLineNumber() + ", " + locator.getColumnNumber() + ": " + message; if (e != null) { return new SAXParseException(error, locator, e); } else { return new SAXParseException(error, locator); } } log.error("No Locator!"); if (e != null) { return new SAXException(message, e); } else { return new SAXException(message); } }
|
protected SAXException createSAXException(String message, Exception e) { log.warn("Underlying exception: " + e); e.printStackTrace(); if (locator != null) { String error = "Error at (" + locator.getLineNumber() + ", " + locator.getColumnNumber() + "): " + message; if (e != null) { return new SAXParseException(error, locator, e); } else { return new SAXParseException(error, locator); } } log.error("No Locator!"); if (e != null) { return new SAXException(message, e); } else { return new SAXException(message); } }
| 1,112,642
|
public boolean evaluateAsBoolean(JellyContext context) { Object value = evaluateAsValue(context); if ( value instanceof Boolean ) { Boolean b = (Boolean) value; return b.booleanValue(); } else if ( value instanceof String ) { // return Boolean.getBoolean( (String) value ); String str = (String) value; if ( str.equals( "on" ) || str.equals( "yes" ) || str.equals( "1" ) || str.equals( "true" ) ) { return true; } else { return false; } } return false; }
|
public boolean evaluateAsBoolean(JellyContext context) { Object value = evaluateRecurse(context); if ( value instanceof Boolean ) { Boolean b = (Boolean) value; return b.booleanValue(); } else if ( value instanceof String ) { // return Boolean.getBoolean( (String) value ); String str = (String) value; if ( str.equals( "on" ) || str.equals( "yes" ) || str.equals( "1" ) || str.equals( "true" ) ) { return true; } else { return false; } } return false; }
| 1,112,644
|
public Iterator evaluateAsIterator(JellyContext context) { Object value = evaluateAsValue(context); if ( value == null ) { return EMPTY_ITERATOR; } else if ( value instanceof Iterator ) { return (Iterator) value; } else if ( value instanceof List ) { List list = (List) value; return list.iterator(); } else if ( value instanceof Map ) { Map map = (Map) value; return map.entrySet().iterator(); } else if ( value.getClass().isArray() ) { return new ArrayIterator( value ); } else if ( value instanceof Enumeration ) { return new EnumerationIterator((Enumeration ) value); } else if ( value instanceof Collection ) { Collection collection = (Collection) value; return collection.iterator(); } else { // XXX: should we return single iterator? return new SingletonIterator( value ); } }
|
public Iterator evaluateAsIterator(JellyContext context) { Object value = evaluateRecurse(context); if ( value == null ) { return EMPTY_ITERATOR; } else if ( value instanceof Iterator ) { return (Iterator) value; } else if ( value instanceof List ) { List list = (List) value; return list.iterator(); } else if ( value instanceof Map ) { Map map = (Map) value; return map.entrySet().iterator(); } else if ( value.getClass().isArray() ) { return new ArrayIterator( value ); } else if ( value instanceof Enumeration ) { return new EnumerationIterator((Enumeration ) value); } else if ( value instanceof Collection ) { Collection collection = (Collection) value; return collection.iterator(); } else { // XXX: should we return single iterator? return new SingletonIterator( value ); } }
| 1,112,645
|
public String evaluateAsString(JellyContext context) { Object value = evaluateAsValue(context); // sometimes when Jelly is used inside Maven the value // of an expression can actually be an expression. // e.g. ${foo.bar} can lookup "foo.bar" in a Maven context // which could actually be an expression if ( value != null ) { return value.toString(); } return null; }
|
public String evaluateAsString(JellyContext context) { Object value = evaluateRecurse(context); // sometimes when Jelly is used inside Maven the value // of an expression can actually be an expression. // e.g. ${foo.bar} can lookup "foo.bar" in a Maven context // which could actually be an expression if ( value != null ) { return value.toString(); } return null; }
| 1,112,646
|
public static int getMimePartSize(MimeMultipart parts, String mimeType) { if (parts != null) { try { for (int i = 0; i < parts.getCount(); i++) { BodyPart bodyPart = parts.getBodyPart(i); if (bodyPart.getContentType().startsWith(mimeType)) { return bodyPart.getSize(); } } } catch (MessagingException e) { log.info("failed to process body parts.", e); } } return 0; }
|
public static int getMimePartSize(MimeMultipart parts, String mimeType) { if (parts != null) { try { for (int i = 0; i < parts.getCount(); i++) { BodyPart bodyPart = parts.getBodyPart(i); if (bodyPart.getContentType().startsWith(mimeType)) { try { Object content = bodyPart.getContent(); if (content instanceof InputStream) { ByteArrayOutputStream os = new ByteArrayOutputStream(); IOUtil.copy(((InputStream) content), os); return os.size(); } else if (content instanceof String) { return ((String) content).length(); } else { throw new IllegalStateException("Unsupported content: "+content.getClass().toString()); } } catch (IOException e) { throw new IllegalStateException("Unexpected IOException in getContent()"); } } } } catch (MessagingException e) { log.info("failed to process body parts.", e); } } return 0; }
| 1,112,647
|
public void initSingleColumnSize(int colIndex) { TableUtils.fitColumnWidth(table, colIndex); }
|
public void initSingleColumnSize(int colIndex) { TableUtils.fitColumnWidth(table, colIndex, 0); }
| 1,112,648
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { int exitValue = 0; String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
| 1,112,649
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
| 1,112,650
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
| 1,112,651
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
| 1,112,652
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ if (headless){ System.out.println(errorMsg); }else{ JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, errorMsg, null, JOptionPane.ERROR_MESSAGE); } exitValue = -1; } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
| 1,112,653
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { if (headless){ System.out.println("Error:\nUnable to launch Haploview.\n"+e.getMessage()); }else{ JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.\n"+e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } } System.exit(0); }
| 1,112,654
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(0); }
|
public static void main(String[] args) { JFrame jf = new JFrame(); String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); System.out.println(ver); String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx650m -classpath " + jarfile; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); int c; boolean dead = false; StringBuffer errorMsg = new StringBuffer(); InputStream es = child.getErrorStream(); InputStream is = child.getInputStream(); //while the child is alive we wait for error messages while ((c=es.read())!=-1) { errorMsg.append((char)c); if (!dead){ child.destroy(); dead = true; } } //if the child has exited without throwing an error (which should've been caught and dealt //with above) we read all the accumulated msgs to stdout and print them... while ((c=is.read())!=-1){ System.out.print((char)c); } if (dead){ JOptionPane.showMessageDialog(jf, "Fatal Error:\n" + errorMsg, null, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.", null, JOptionPane.ERROR_MESSAGE); } System.exit(exitValue); }
| 1,112,655
|
public void doTag(XMLOutput output) throws Exception { for (int i = 0, size = whenTags.length; i < size; i++) { TagScript script = whenTags[i]; script.run(context, output); WhenTag tag = (WhenTag) script.getTag(); if (tag.getValue()) { return; } } if (otherwiseTag != null) { otherwiseTag.run(context, output); } }
|
public void doTag(XMLOutput output) throws Exception { for (int i = 0, size = whenTags.length; i < size; i++) { TagScript script = whenTags[i]; script.run(context, output); WhenTag tag = (WhenTag) script.getTag(); if (tag.getValue()) { return; } } if (otherwiseTag != null) { otherwiseTag.run(context, output); } }
| 1,112,656
|
public void doTag(XMLOutput output) throws Exception { try { conn = getConnection(); } catch (SQLException e) { throw new JellyException(sql + ": " + e.getMessage(), e); } /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ String sqlStatement = null; if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } int result = 0; try { PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); result = ps.executeUpdate(); if (var != null) { context.setVariable(var, new Integer(result)); } } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { // Not much we can do } } parameters = null; conn = null; } }
|
public void doTag(XMLOutput output) throws Exception { try { conn = getConnection(); } catch (SQLException e) { throw new JellyException(sql + ": " + e.getMessage(), e); } /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ String sqlStatement = null; if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } int result = 0; try { PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); result = ps.executeUpdate(); if (var != null) { context.setVariable(var, new Integer(result)); } } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { // Not much we can do } } parameters = null; conn = null; } }
| 1,112,657
|
protected void setUp() throws Exception { super.setUp(); pp = ArchitectFrame.getMainInstance().getProject().getPlayPen(); SQLTable t1 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t1); pp.addTablePane(new TablePane(t1, pp), new Point(0,0)); SQLTable t2 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t2); pp.addTablePane(new TablePane(t2, pp), new Point(0,0)); SQLRelationship sqlrel = new SQLRelationship(); sqlrel.attachRelationship(t1, t2, false); rel = new Relationship(pp, sqlrel); }
|
protected void setUp() throws Exception { super.setUp(); pp = ArchitectFrame.getMainInstance().getProject().getPlayPen(); SQLTable t1 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t1); pp.addTablePane(tp1 = new TablePane(t1, pp), new Point(0,0)); SQLTable t2 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t2); pp.addTablePane(new TablePane(t2, pp), new Point(0,0)); SQLRelationship sqlrel = new SQLRelationship(); sqlrel.attachRelationship(t1, t2, false); rel = new Relationship(pp, sqlrel); }
| 1,112,658
|
protected void setUp() throws Exception { super.setUp(); pp = ArchitectFrame.getMainInstance().getProject().getPlayPen(); SQLTable t1 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t1); pp.addTablePane(new TablePane(t1, pp), new Point(0,0)); SQLTable t2 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t2); pp.addTablePane(new TablePane(t2, pp), new Point(0,0)); SQLRelationship sqlrel = new SQLRelationship(); sqlrel.attachRelationship(t1, t2, false); rel = new Relationship(pp, sqlrel); }
|
protected void setUp() throws Exception { super.setUp(); pp = ArchitectFrame.getMainInstance().getProject().getPlayPen(); SQLTable t1 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t1); pp.addTablePane(new TablePane(t1, pp), new Point(0,0)); SQLTable t2 = new SQLTable(pp.getDatabase(), true); pp.getDatabase().addChild(t2); pp.addTablePane(tp2 = new TablePane(t2, pp), new Point(0,0)); SQLRelationship sqlrel = new SQLRelationship(); sqlrel.attachRelationship(t1, t2, false); rel = new Relationship(pp, sqlrel); }
| 1,112,659
|
public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; } tx = odmg.newTransaction(); tx.begin(); DList folders = null; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"subfolderTest\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } rootFolder = (PhotoFolder) folders.get(0); model = new PhotoFolderTreeModel(); model.setRoot( rootFolder ); }
|
public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; } tx = odmg.newTransaction(); tx.begin(); DList folders = null; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"subfolderTest\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } rootFolder = (PhotoFolder) folders.get(0); model = new PhotoFolderTreeModel(); model.setRoot( rootFolder ); }
| 1,112,661
|
public void setTags(TaggerController t) { tc = t; removeAll(); setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); Vector colNames = new Vector(); Vector tableData = new Vector(); colNames.add("Allele"); colNames.add("Test"); colNames.add("r\u00b2"); for (int i = 0; i < Chromosome.getSize(); i++){ Vector v = t.getMarkerTagDetails(i); tableData.add(v); } BasicTableModel btm = new BasicTableModel(colNames, tableData); markerTable = new JTable(btm); GreyedOutRenderer gor = new GreyedOutRenderer(); markerTable.setDefaultRenderer(String.class,gor); JScrollPane tableScroller = new JScrollPane(markerTable); tags = t.getResults(); forceIncluded = new Vector(); Vector fi = t.getForceIncludeds(); for (int i = 0; i < fi.size(); i++){ forceIncluded.add(((edu.mit.wi.tagger.SNP)fi.get(i)).getName()); } DefaultListModel tagListModel = new DefaultListModel(); for(int i=0;i<tags.size();i++){ TagSequence ts = (TagSequence)tags.get(i); tagListModel.addElement(ts.getName()); } tagList = new JList(tagListModel); tagList.setCellRenderer(new TagListRenderer()); tagList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tagList.setSelectedIndex(0); tagList.addListSelectionListener(this); tagList.setPreferredSize(new Dimension(tagList.getPreferredSize().width + 10, tagList.getPreferredSize().height)); JScrollPane listScrollPane = new JScrollPane(tagList); JPanel topListPanel = new JPanel(); topListPanel.setLayout(new BoxLayout(topListPanel,BoxLayout.Y_AXIS)); JLabel tagLabel = new JLabel("Tests"); Font defaultFont = tagLabel.getFont(); //make the word 'tests' nice and big. tagLabel.setFont(new Font(defaultFont.getName(),Font.BOLD,(int)(defaultFont.getSize()*1.5))); tagLabel.setAlignmentX(Component.CENTER_ALIGNMENT); topListPanel.add(tagLabel); topListPanel.add(Box.createRigidArea(new Dimension(0,10))); topListPanel.add(listScrollPane); if (forceIncluded.size() > 0){ //let them know why some are in bold JLabel forceLabel = new JLabel("(forced-in markers shown in bold)"); forceLabel.setAlignmentX(Component.CENTER_ALIGNMENT); topListPanel.add(forceLabel); } DefaultListModel taggedListModel = new DefaultListModel(); taggedList = new JList(taggedListModel); taggedList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tagList.setSelectedIndex(0); tagList.addListSelectionListener(this); JScrollPane taggedListScrollPane = new JScrollPane(taggedList); JPanel bottomListPanel = new JPanel(); bottomListPanel.setLayout(new BoxLayout(bottomListPanel, BoxLayout.Y_AXIS)); bottomListPanel.add(new JLabel("Alleles captured by Current Selection")); bottomListPanel.add(taggedListScrollPane); JPanel listsPanel = new JPanel(); listsPanel.setLayout(new BoxLayout(listsPanel,BoxLayout.Y_AXIS)); listsPanel.add(topListPanel); listsPanel.add(Box.createRigidArea(new Dimension(0,10))); listsPanel.add(bottomListPanel); listsPanel.add(Box.createRigidArea(new Dimension(0,10))); JLabel capLabel = new JLabel("Captured " + t.getTaggedSoFar() + " of " + Chromosome.getSize() + " alleles with mean r\u00b2 of " + Util.roundDouble(t.getMeanRSq(),3)); listsPanel.add(capLabel); listsPanel.add(new JLabel(t.getFracOver8() + " percent of captured alleles with r\u00b2 > 0.8")); JLabel useLabel = new JLabel("Using " +t.getNumTagSNPs() + " SNPs in " + t.getResults().size() + " tests."); listsPanel.add(useLabel); if(t.getUntaggableCount() > 0) { String cantTag = "Unable to capture " + t.getUntaggableCount() + " alleles (shown in red)."; JLabel cantTagLabel = new JLabel(cantTag); listsPanel.add(cantTagLabel); } listsPanel.add(Box.createRigidArea(new Dimension(0,10))); JButton dumpTestsButton = new JButton("Dump Tests File"); dumpTestsButton.setActionCommand("dump"); dumpTestsButton.addActionListener(this); listsPanel.add(dumpTestsButton); listsPanel.add(Box.createRigidArea(new Dimension(0,5))); add(listsPanel); add(Box.createRigidArea(new Dimension(5,0))); add(new JSeparator(JSeparator.VERTICAL)); add(Box.createRigidArea(new Dimension(5,0))); add(tableScroller); refresh(); }
|
public void setTags(TaggerController t) { tc = t; removeAll(); setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); Vector colNames = new Vector(); Vector tableData = new Vector(); colNames.add("Allele"); colNames.add("Test"); colNames.add("r\u00b2"); for (int i = 0; i < Chromosome.getSize(); i++){ Vector v = t.getMarkerTagDetails(i); tableData.add(v); } BasicTableModel btm = new BasicTableModel(colNames, tableData); markerTable = new JTable(btm); GreyedOutRenderer gor = new GreyedOutRenderer(); markerTable.setDefaultRenderer(String.class,gor); JScrollPane tableScroller = new JScrollPane(markerTable); tags = t.getResults(); forceIncluded = new Vector(); Vector fi = t.getForceIncludeds(); for (int i = 0; i < fi.size(); i++){ forceIncluded.add(((edu.mit.wi.tagger.SNP)fi.get(i)).getName()); } DefaultListModel tagListModel = new DefaultListModel(); for(int i=0;i<tags.size();i++){ TagSequence ts = (TagSequence)tags.get(i); tagListModel.addElement(ts.getName()); } tagList = new JList(tagListModel); tagList.setCellRenderer(new TagListRenderer()); tagList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tagList.setSelectedIndex(0); tagList.addListSelectionListener(this); tagList.setPreferredSize(new Dimension(tagList.getPreferredSize().width + 10, tagList.getPreferredSize().height)); JScrollPane listScrollPane = new JScrollPane(tagList); JPanel topListPanel = new JPanel(); topListPanel.setLayout(new BoxLayout(topListPanel,BoxLayout.Y_AXIS)); JLabel tagLabel = new JLabel("Tests"); Font defaultFont = tagLabel.getFont(); //make the word 'tests' nice and big. tagLabel.setFont(new Font(defaultFont.getName(),Font.BOLD,(int)(defaultFont.getSize()*1.5))); tagLabel.setAlignmentX(Component.CENTER_ALIGNMENT); topListPanel.add(tagLabel); topListPanel.add(Box.createRigidArea(new Dimension(0,10))); topListPanel.add(listScrollPane); if (forceIncluded.size() > 0){ //let them know why some are in bold JLabel forceLabel = new JLabel("(forced-in markers shown in bold)"); forceLabel.setAlignmentX(Component.CENTER_ALIGNMENT); topListPanel.add(forceLabel); } DefaultListModel taggedListModel = new DefaultListModel(); taggedList = new JList(taggedListModel); taggedList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tagList.setSelectedIndex(0); tagList.addListSelectionListener(this); JScrollPane taggedListScrollPane = new JScrollPane(taggedList); JPanel bottomListPanel = new JPanel(); bottomListPanel.setLayout(new BoxLayout(bottomListPanel, BoxLayout.Y_AXIS)); bottomListPanel.add(new JLabel("Alleles captured by Current Selection")); bottomListPanel.add(taggedListScrollPane); JPanel listsPanel = new JPanel(); listsPanel.setLayout(new BoxLayout(listsPanel,BoxLayout.Y_AXIS)); listsPanel.add(topListPanel); listsPanel.add(Box.createRigidArea(new Dimension(0,10))); listsPanel.add(bottomListPanel); listsPanel.add(Box.createRigidArea(new Dimension(0,10))); JLabel capLabel = new JLabel("Captured " + t.getTaggedSoFar() + " of " + Chromosome.getSize() + " alleles with mean r\u00b2 of " + Util.roundDouble(t.getMeanRSq(),3)); listsPanel.add(capLabel); listsPanel.add(new JLabel(t.getFracOver8() + " percent of captured alleles with r\u00b2 > 0.8")); JLabel useLabel = new JLabel("Using " +t.getNumTagSNPs() + " SNPs in " + t.getResults().size() + " tests."); listsPanel.add(useLabel); if(t.getUntaggableCount() > 0) { String cantTag = "Unable to capture " + t.getUntaggableCount() + " alleles (shown in red)."; JLabel cantTagLabel = new JLabel(cantTag); listsPanel.add(cantTagLabel); } listsPanel.add(Box.createRigidArea(new Dimension(0,10))); JButton dumpTestsButton = new JButton("Dump Tests File"); dumpTestsButton.setActionCommand("dump"); dumpTestsButton.addActionListener(this); JButton dumpTagsButton = new JButton("Dump Tags File"); dumpTagsButton.setActionCommand("dump tags"); dumpTagsButton.addActionListener(this); JPanel listsButtonPanel = new JPanel(); listsButtonPanel.add(dumpTestsButton); listsButtonPanel.add(dumpTagsButton); listsPanel.add(listsButtonPanel); listsPanel.add(Box.createRigidArea(new Dimension(0,5))); add(listsPanel); add(Box.createRigidArea(new Dimension(5,0))); add(new JSeparator(JSeparator.VERTICAL)); add(Box.createRigidArea(new Dimension(5,0))); add(tableScroller); refresh(); }
| 1,112,663
|
public BrowserWindow() { super( "Photovault Browser"); SwingUtilities.invokeLater(new java.lang.Runnable() { public void run() { createUI(); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); }
|
public BrowserWindow() { super( "Photovault Browser"); SwingUtilities.invokeLater(new java.lang.Runnable() { public void run() { createUI(); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); }
| 1,112,664
|
public void actionPerformed( ActionEvent e ) { BrowserWindow br = new BrowserWindow(); // br.setVisible( true ); }
|
public void actionPerformed( ActionEvent e ) { importFile(); // br.setVisible( true ); }
| 1,112,666
|
public void actionPerformed( ActionEvent e ) { importFile(); }
|
public void actionPerformed( ActionEvent e ) { System.exit( 0 ); }
| 1,112,667
|
public synchronized void setupDialog() { logger.debug("running setupDialog()"); if (plexp == null) { throw new NullPointerException("setupDialog: plexp was null"); } // always refresh Target Database (it might have changed) plexp.setTargetDataSource(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getDataSource()); // Cannot use ArchitectPanelBuilder here yet because // of the progressbar. d = new JDialog(ArchitectFrame.getMainInstance(), "Export ETL Transactions to PL Repository"); // set export defaults if necessary if (plexp.getFolderName() == null || plexp.getFolderName().trim().length() == 0) { plexp.setFolderName(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_FOLDER")); } if (plexp.getJobId() == null || plexp.getJobId().trim().length() == 0) { plexp.setJobId(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_JOB")); } JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plPanel.setPLExport(plexp); plp.add(plPanel, BorderLayout.CENTER); // make an intermediate JPanel JPanel bottomPanel = new JPanel(new GridLayout(1,2,25,0)); // 25 pixel hgap JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = playpen.getDatabase().getTables(); List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) JList warnings = new JList(targetDBWarnings.toArray()); JPanel cp = new JPanel(new BorderLayout()); cp.add(new JLabel("<html>The target database schema is not identical to your Architect schema.<br><br>Here are the differences:</html>"), BorderLayout.NORTH); cp.add(new JScrollPane(warnings), BorderLayout.CENTER); cp.add(new JLabel("Do you want to continue anyway?"), BorderLayout.SOUTH); int choice = JOptionPane.showConfirmDialog(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); d.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); // stick in the progress bar here... JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); plCreateTxProgressBar = new JProgressBar(); plCreateTxProgressBar.setStringPainted(true); progressPanel.add(plCreateTxProgressBar); plCreateTxLabel = new JLabel ("Exporting PL Transactions..."); progressPanel.add(plCreateTxLabel); // figure out how much space this needs before setting // child components to be invisible progressPanel.setPreferredSize(progressPanel.getPreferredSize()); plCreateTxProgressBar.setVisible(false); plCreateTxLabel.setVisible(false); bottomPanel.add(progressPanel); // left side, left justified bottomPanel.add(buttonPanel); // right side, right justified plp.add(bottomPanel, BorderLayout.SOUTH); d.setContentPane(plp); // experiment with preferred size crap: d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); }
|
public synchronized void setupDialog() { logger.debug("running setupDialog()"); if (plexp == null) { throw new NullPointerException("setupDialog: plexp was null"); } // always refresh Target Database (it might have changed) plexp.setTargetDataSource(ArchitectFrame.getMainInstance().getProject().getTargetDatabase().getDataSource()); // Cannot use ArchitectPanelBuilder here yet because // of the progressbar. d = new JDialog(ArchitectFrame.getMainInstance(), "Export ETL Transactions to PL Repository"); // set export defaults if necessary if (plexp.getFolderName() == null || plexp.getFolderName().trim().length() == 0) { plexp.setFolderName(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_FOLDER")); } if (plexp.getJobId() == null || plexp.getJobId().trim().length() == 0) { plexp.setJobId(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_JOB")); } JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plPanel.setPLExport(plexp); plp.add(plPanel, BorderLayout.CENTER); // make an intermediate JPanel JPanel bottomPanel = new JPanel(new GridLayout(1,2,25,0)); // 25 pixel hgap JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (!plPanel.applyChanges()) { return; } try { List targetTables = playpen.getDatabase().getTables(); List targetDBWarnings = listMissingTargetTables(targetTables); if (!targetDBWarnings.isEmpty()) { // modal dialog (hold things up until the user says YES or NO) JList warnings = new JList(targetDBWarnings.toArray()); JPanel cp = new JPanel(new BorderLayout()); cp.add(new JLabel("<html>The target database schema is not identical to your Architect schema.<br><br>Here are the differences:</html>"), BorderLayout.NORTH); cp.add(new JScrollPane(warnings), BorderLayout.CENTER); cp.add(new JLabel("Do you want to continue anyway?"), BorderLayout.SOUTH); int choice = JOptionPane.showConfirmDialog(architectFrame, cp, "Target Database Structure Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); return; } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame,"Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans",arex); return; } // got this far, so it's ok to run the PL Export thread ExportTxProcess etp = new ExportTxProcess(plexp,d, plCreateTxProgressBar,plCreateTxLabel); new Thread(etp).start(); } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); d.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton(cancelAction); buttonPanel.add(cancelButton); // stick in the progress bar here... JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); plCreateTxProgressBar = new JProgressBar(); plCreateTxProgressBar.setStringPainted(true); progressPanel.add(plCreateTxProgressBar); plCreateTxLabel = new JLabel ("Exporting PL Transactions..."); progressPanel.add(plCreateTxLabel); // figure out how much space this needs before setting // child components to be invisible progressPanel.setPreferredSize(progressPanel.getPreferredSize()); plCreateTxProgressBar.setVisible(false); plCreateTxLabel.setVisible(false); bottomPanel.add(progressPanel); // left side, left justified bottomPanel.add(buttonPanel); // right side, right justified plp.add(bottomPanel, BorderLayout.SOUTH); d.setContentPane(plp); // experiment with preferred size crap: d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); }
| 1,112,669
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(ASSOC_TRIO); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
| 1,112,670
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(ASSOC_CC); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
| 1,112,671
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(ASSOC_NONE); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
| 1,112,672
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
|
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(RAW_DATA)){ load(PED); }else if (command.equals(PHASED_DATA)){ load(HAPS); }else if (command.equals(HAPMAP_DATA)){ load(HMP); }else if (command.equals(BROWSE_GENO)){ browse(GENO); }else if (command.equals(BROWSE_INFO)){ browse(INFO); }else if (command.equals("OK")){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ Options.setAssocTest(1); } else { Options.setAssocTest(2); } }else{ Options.setAssocTest(0); } if (maxComparisonDistField.getText().equals("")){ Options.setMaxDistance(0); }else{ Options.setMaxDistance(Integer.parseInt(maxComparisonDistField.getText())); } String[] returnStrings = {genoFileField.getText(), infoFileField.getText()}; if (returnStrings[1].equals("")) returnStrings[1] = null; //if a dataset was previously loaded during this session, discard the display panes for it. if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); caller.dPrimeDisplay = null; } if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); caller.hapDisplay = null; } caller.readGenotypes(returnStrings, fileType); this.dispose(); }else if (command.equals("Cancel")){ this.dispose(); }else if (command.equals("tdt")){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
| 1,112,673
|
protected void initTree() { folderNodes = new HashMap(); topNode = null; if ( model == null ) { return; } // Add all photos in the model to folder tree for ( int n = 0; n < model.length; n++ ) { addPhotoToTree( (PhotoInfo) model[n] ); } treeModel.nodeStructureChanged(topNode); }
|
protected void initTree() { folderNodes = new HashMap(); topNode = null; if ( model == null ) { return; } // Add all photos in the model to folder tree for ( int n = 0; n < model.length; n++ ) { if ( model[n] != null ) { addPhotoToTree( (PhotoInfo) model[n] ); } } treeModel.nodeStructureChanged(topNode); }
| 1,112,674
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD FOREIGN KEY "); print(r.getName()); print(" ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD CONSTRAINT "); print(r.getName()); print(" ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
| 1,112,675
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD FOREIGN KEY "); print(r.getName()); print(" ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
|
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" ADD FOREIGN KEY "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" ) REFERENCES "); printQualified(r.getPkTable().getPhysicalName()); print(" FOREIGN KEY ( "); colNameMap = new HashMap<String, SQLColumn> (); firstColumn = true; for (ColumnMapping cm :r.getMapping()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if(firstColumn) { firstColumn = false; print(getPhysicalName(colNameMap,c)); } else { print(", "+getPhysicalName(colNameMap,c)); } colNameMap.put(c.getName(),c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); }
| 1,112,676
|
private String columnDefinition(SQLColumn c, Map colNameMap) throws ArchitectDiffException { StringBuffer def = new StringBuffer(); getPhysicalName(colNameMap,c); // also adds generated physical name to the map GenericTypeDescriptor td = (GenericTypeDescriptor) typeMap.get(new Integer(c.getType())); if (td == null) { td = (GenericTypeDescriptor) typeMap.get(getDefaultType()); //better be non-null! GenericTypeDescriptor oldType = new GenericTypeDescriptor (c.getSourceDataTypeName(), c.getType(), c.getPrecision(), null, null, c.getNullable(), false, false); oldType.determineScaleAndPrecision(); warnings.add(new TypeMapWarning(c, "Unknown Target Type", oldType, td)); } def.append(c.getPhysicalName()); def.append(" "); def.append(td.getName()); if (td.getHasPrecision()) { def.append("("+c.getPrecision()); if (td.getHasScale()) { def.append(","+c.getScale()); } def.append(")"); } if (c.isDefinitelyNullable()) { if (! td.isNullable()) { throw new UnsupportedOperationException ("The data type "+td.getName()+" is not nullable on the target database platform."); } def.append(" NULL"); } else { def.append(" NOT NULL"); } return def.toString(); }
|
protected String columnDefinition(SQLColumn c, Map colNameMap) throws ArchitectDiffException { StringBuffer def = new StringBuffer(); getPhysicalName(colNameMap,c); // also adds generated physical name to the map GenericTypeDescriptor td = (GenericTypeDescriptor) typeMap.get(new Integer(c.getType())); if (td == null) { td = (GenericTypeDescriptor) typeMap.get(getDefaultType()); //better be non-null! GenericTypeDescriptor oldType = new GenericTypeDescriptor (c.getSourceDataTypeName(), c.getType(), c.getPrecision(), null, null, c.getNullable(), false, false); oldType.determineScaleAndPrecision(); warnings.add(new TypeMapWarning(c, "Unknown Target Type", oldType, td)); } def.append(c.getPhysicalName()); def.append(" "); def.append(td.getName()); if (td.getHasPrecision()) { def.append("("+c.getPrecision()); if (td.getHasScale()) { def.append(","+c.getScale()); } def.append(")"); } if (c.isDefinitelyNullable()) { if (! td.isNullable()) { throw new UnsupportedOperationException ("The data type "+td.getName()+" is not nullable on the target database platform."); } def.append(" NULL"); } else { def.append(" NOT NULL"); } return def.toString(); }
| 1,112,677
|
public void dropRelationship(SQLRelationship r) { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" DROP FOREIGN KEY "); print(r.getName()); endStatement(DDLStatement.StatementType.DROP, r); }
|
public void dropRelationship(SQLRelationship r) { print("\n ALTER TABLE "); printQualified(r.getFkTable().getPhysicalName()); print(" DROP CONSTRAINT "); print(r.getName()); endStatement(DDLStatement.StatementType.DROP, r); }
| 1,112,678
|
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newContext, output ); }
|
public void run(JellyContext context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newContext, output ); }
| 1,112,680
|
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newContext, output ); }
|
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes JellyContext newJellyContext = context.newJellyContext( attributes ); getTemplate().run( newContext, output ); }
| 1,112,681
|
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newContext, output ); }
|
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); attributes.put( "org.apache.commons.jelly.body", getBody() ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newJellyContext, output ); }
| 1,112,682
|
static public void init() { // Determine the property file name String propFname = System.getProperty( "photovault.propFname", defaultPropFname ); File propFile = new File( propFname ); props = new Properties(); try { InputStream is = new FileInputStream( propFile ); props.load( is ); } catch ( FileNotFoundException e ) { log.error( "Could not find the property file " + propFname ); } catch ( IOException e ) { log.error( "Could not load property file " + propFname + ": " + e ); } }
|
static public void init() { // Determine the property file name String propFname = System.getProperty( "photovault.propFname", defaultPropFname ); log.debug( "Using property file " + propFname ); File propFile = new File( propFname ); props = new Properties(); try { InputStream is = new FileInputStream( propFile ); props.load( is ); } catch ( FileNotFoundException e ) { log.error( "Could not find the property file " + propFname ); } catch ( IOException e ) { log.error( "Could not load property file " + propFname + ": " + e ); } }
| 1,112,683
|
private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; if ( photo != null ) { Thumbnail thumbnail = null; if ( photo.hasThumbnail() ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); // long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000;// log.warn( "Accuracy = " + accuracy );// String dateStr = "";// if ( accuracy > 0 ) {// double accuracyFormatLimits[] = {0, 3, 14, 180};// String accuracyFormatStrings[] = {// "dd.MM.yyyy",// "'wk' w yyyy",// "MMMM yyyy",// "yyyy"// };// // Find the correct format to use// double dblAccuracy = photo.getTimeAccuracy();// String formatStr =accuracyFormatStrings[0];// for ( int i = 1; i < accuracyFormatLimits.length; i++ ) {// if ( dblAccuracy < accuracyFormatLimits[i] ) {// break;// }// formatStr =accuracyFormatStrings[i];// } // // Show the limits of the accuracy range// DateFormat df = new SimpleDateFormat( formatStr );// 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 = lowerStr;// if ( !lowerStr.equals( upperStr ) ) {// dateStr += " - " + upperStr;// }// } else {// DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" );// dateStr = df.format( photo.getShootTime() );// } String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } }
|
private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); // long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000;// log.warn( "Accuracy = " + accuracy );// String dateStr = "";// if ( accuracy > 0 ) {// double accuracyFormatLimits[] = {0, 3, 14, 180};// String accuracyFormatStrings[] = {// "dd.MM.yyyy",// "'wk' w yyyy",// "MMMM yyyy",// "yyyy"// };// // Find the correct format to use// double dblAccuracy = photo.getTimeAccuracy();// String formatStr =accuracyFormatStrings[0];// for ( int i = 1; i < accuracyFormatLimits.length; i++ ) {// if ( dblAccuracy < accuracyFormatLimits[i] ) {// break;// }// formatStr =accuracyFormatStrings[i];// } // // Show the limits of the accuracy range// DateFormat df = new SimpleDateFormat( formatStr );// 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 = lowerStr;// if ( !lowerStr.equals( upperStr ) ) {// dateStr += " - " + upperStr;// }// } else {// DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" );// dateStr = df.format( photo.getShootTime() );// } String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } }
| 1,112,685
|
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); /* * Setting up a clean db for each of the tests */ Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10), t1_c2 numeric(5))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); }
|
protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); /* * Setting up a clean db for each of the tests */ Statement stmt = con.createStatement(); try { stmt.executeUpdate("DROP TABLE REGRESSION_TEST1"); stmt.executeUpdate("DROP TABLE REGRESSION_TEST2"); } catch (SQLException sqle ){ System.out.println("+++ TestSQLDatabase exception should be for dropping a non-existant table"); sqle.printStackTrace(); } stmt.executeUpdate("CREATE TABLE REGRESSION_TEST1 (t1_c1 numeric(10), t1_c2 numeric(5))"); stmt.executeUpdate("CREATE TABLE REGRESSION_TEST2 (t2_c1 char(10))"); stmt.close(); mydb.disconnect(); }
| 1,112,689
|
public void testInherit() throws ArchitectException { SQLTable table1; SQLTable table2; table1 = db.getTableByName("REGRESSION_TEST1"); table2 = db.getTableByName("REGRESSION_TEST2"); table2.inherit(table1); assertEquals("The wrong 1st column was inherited",table2.getColumn(0).toString(),table1.getColumn(0).toString()); assertEquals("The wrong 2nd column was inherited",table2.getColumn(1).toString(),table1.getColumn(1).toString()); assertEquals("The wrong number of columns were inherited",table2.getColumns().size(), 3); try { table2.inherit(table2); } catch (ArchitectException ae) { if ("Cannot inherit from self".equals(ae.getMessage())) { System.out.println("Expected Behaviour is to not be able to inherit from self"); } else { throw ae; } } }
|
public void testInherit() throws ArchitectException { SQLTable table1; SQLTable table2; table1 = db.getTableByName("REGRESSION_TEST1"); table2 = db.getTableByName("REGRESSION_TEST2"); table2.inherit(table1); assertEquals("The wrong 1st column was inherited",table2.getColumn(0).toString(),table1.getColumn(0).toString()); assertEquals("The wrong 2nd column was inherited",table2.getColumn(1).toString(),table1.getColumn(1).toString()); assertEquals("The wrong number of columns were inherited",table2.getColumns().size(), 3); try { table2.inherit(table2); } catch (ArchitectException ae) { if ("Cannot inherit from self".equals(ae.getMessage())) { System.out.println("Expected Behaviour is to not be able to inherit from self"); } else { throw ae; } } }
| 1,112,690
|
public void testInherit() throws ArchitectException { SQLTable table1; SQLTable table2; table1 = db.getTableByName("REGRESSION_TEST1"); table2 = db.getTableByName("REGRESSION_TEST2"); table2.inherit(table1); assertEquals("The wrong 1st column was inherited",table2.getColumn(0).toString(),table1.getColumn(0).toString()); assertEquals("The wrong 2nd column was inherited",table2.getColumn(1).toString(),table1.getColumn(1).toString()); assertEquals("The wrong number of columns were inherited",table2.getColumns().size(), 3); try { table2.inherit(table2); } catch (ArchitectException ae) { if ("Cannot inherit from self".equals(ae.getMessage())) { System.out.println("Expected Behaviour is to not be able to inherit from self"); } else { throw ae; } } }
|
public void testInherit() throws ArchitectException { SQLTable table1; SQLTable table2; table1 = db.getTableByName("REGRESSION_TEST1"); table2 = db.getTableByName("REGRESSION_TEST2"); table2.inherit(table1); assertEquals("The wrong 1st column was inherited",table2.getColumn(0).toString(),table1.getColumn(0).toString()); assertEquals("The wrong 2nd column was inherited",table2.getColumn(1).toString(),table1.getColumn(1).toString()); assertEquals("The wrong number of columns were inherited",table2.getColumns().size(), 3); try { table2.inherit(table2); } catch (ArchitectException ae) { if ("Cannot inherit from self".equals(ae.getMessage())) { System.out.println("Expected Behaviour is to not be able to inherit from self"); } else { throw ae; } } }
| 1,112,691
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
| 1,112,693
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
| 1,112,694
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
|
public void testRemoveColumn() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); col1 = table1.getColumn(0); col2 = table1.getColumn(1); assertEquals("We removed a column when we shouldn't have",table1.getColumns().size(),2); table1.removeColumn(col1); assertEquals("Either 0 or 2+ columns were removed",table1.getColumns().size(),1); assertEquals("The wrong column was removed",col2,table1.getColumn(0)); table1.removeColumn(0); assertEquals("Last Column failed to be removed",table1.getColumns().size(),0); Exception exc = null; try { table1.removeColumn(0); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc = e; } assertNotNull("Should have thrown an exception",exc); }
| 1,112,695
|
public void testRemoveColumnOutBounds() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); Exception exc = null; try { table1.removeColumn(16); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc=e; } assertNotNull("Should have thrown an exception",exc); }
|
public void testRemoveColumnOutBounds() throws ArchitectException { SQLTable table1; SQLColumn col1; SQLColumn col2; table1 = db.getTableByName("REGRESSION_TEST1"); Exception exc = null; try { table1.removeColumn(16); } catch (IndexOutOfBoundsException e) { System.out.println("Method throws proper error"); exc=e; } assertNotNull("Should have thrown an exception",exc); }
| 1,112,697
|
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; 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){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.quietMode) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData, false); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ 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); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(outputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } 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)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } 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()); } }
|
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; 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){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.quietMode) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData, false); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ 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); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(outputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1, false); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } 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)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } 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()); } }
| 1,112,700
|
private File validateOutputFile(String fn){ File f = new File(fn); if (f.canWrite()){ System.out.println("File " + f.getName() + " can not be written."); System.exit(1); } if (f.exists() && !quietMode){ System.out.println("File " + f.getName() + " already exists and will be overwritten."); } return f; }
|
private File validateOutputFile(String fn){ File f = new File(fn); if (f.canWrite()){ System.out.println("File " + f.getName() + " can not be written."); System.exit(1); } if (f.exists() && !quietMode){ System.out.println("File " + f.getName() + " already exists and will be overwritten."); } return f; }
| 1,112,701
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,702
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,703
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,704
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,705
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,706
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,707
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,708
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,709
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,710
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,711
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,712
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,713
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,714
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,715
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
|
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { TableProfileResult tProfile = (TableProfileResult) pm.getResult(col.getParentTable()); ColumnProfileResult cProfile = (ColumnProfileResult) pm.getResult(col); DDLGenerator gddl = DDLUtils.createDDLGenerator( col.getParentTable().getParentDatabase().getDataSource()); DecimalFormat pctFormat = new DecimalFormat("0%"); int rowCount = -1; if ( tProfile != null && tProfile.isError() != true ) { rowCount = tProfile.getRowCount(); } java.util.List<ColumnValueCount> topTen = null; if ( cProfile != null && cProfile.isError() != true ) { topTen = cProfile.getValueCount(); } final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) { String contents; int alignment; if (colNo == 0) { if ( tProfile == null || tProfile.isError() ) { contents = col.getParentTable().getName() + "\nProfiling Error:\n"; if ( tProfile != null && tProfile.getEx() != null ) contents += tProfile.getEx(); } else { contents = col.getParentTable().getName(); } alignment = Element.ALIGN_LEFT; } else if (colNo == 1) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (colNo == 2) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (colNo == 3) { contents = gddl.columnType(col); alignment = Element.ALIGN_LEFT; } else if (colNo == 4) { contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER; } else if (colNo == 5) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; } } else if (colNo == 6) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 7) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 8) { if ( cProfile != null && !cProfile.isError() ) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 9) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMinValue()); if (cProfile.getMinValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue()); if (cProfile.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue()); if (cProfile.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; } else if (cProfile.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) { if ( cProfile != null && !cProfile.isError() && topTen != null ) { Object value = null; StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { value = cvc.getValue(); sb.append(value).append("\n"); } contents = sb.toString(); if (value == null) { alignment = Element.ALIGN_CENTER; } else if (value instanceof Number) { alignment = Element.ALIGN_RIGHT; } else { alignment = Element.ALIGN_LEFT; } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 16) { if ( cProfile != null && !cProfile.isError() ) { StringBuffer sb = new StringBuffer(); for ( ColumnValueCount cvc : topTen ) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column "+colNo); } // update column width to reflect the widest cell widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contents, fsize)); Phrase phr = new Phrase((String) contents, f); PdfPCell cell = new PdfPCell(phr); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); table.addCell(cell); } }
| 1,112,717
|
private static void addHeaderRow(PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException { final String[] headings = new String[] { "Table Name", "Record Count", "Column Name", "Data Type", "Nullable", "Null Count", "% null", "Unique Count", "% unique", "Min Length", "Max Length", "Avg Length", "Min Value", "Max Value", "Avg Value", "Top N Values", "Count" }; int ncols = headings.length; for (int colNo = 0; colNo < ncols; colNo++) { String contents = headings[colNo]; // ensure column width is at least enough for widest word in heading StringTokenizer st = new StringTokenizer(contents); while (st.hasMoreTokens()) { widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint(st.nextToken(), fsize)); } Phrase colTitle = new Phrase(contents, f); PdfPCell cell = new PdfPCell(colTitle); cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP); cell.setBorderWidth(2); cell.setBackgroundColor(new Color(200, 200, 200)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setHeaderRows(1); }
|
private void addHeaderRow(PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException { final String[] headings = new String[] { "Table Name", "Record Count", "Column Name", "Data Type", "Nullable", "Null Count", "% null", "Unique Count", "% unique", "Min Length", "Max Length", "Avg Length", "Min Value", "Max Value", "Avg Value", "Top N Values", "Count" }; int ncols = headings.length; for (int colNo = 0; colNo < ncols; colNo++) { String contents = headings[colNo]; // ensure column width is at least enough for widest word in heading StringTokenizer st = new StringTokenizer(contents); while (st.hasMoreTokens()) { widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint(st.nextToken(), fsize)); } Phrase colTitle = new Phrase(contents, f); PdfPCell cell = new PdfPCell(colTitle); cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP); cell.setBorderWidth(2); cell.setBackgroundColor(new Color(200, 200, 200)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setHeaderRows(1); }
| 1,112,718
|
private static void addHeaderRow(PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException { final String[] headings = new String[] { "Table Name", "Record Count", "Column Name", "Data Type", "Nullable", "Null Count", "% null", "Unique Count", "% unique", "Min Length", "Max Length", "Avg Length", "Min Value", "Max Value", "Avg Value", "Top N Values", "Count" }; int ncols = headings.length; for (int colNo = 0; colNo < ncols; colNo++) { String contents = headings[colNo]; // ensure column width is at least enough for widest word in heading StringTokenizer st = new StringTokenizer(contents); while (st.hasMoreTokens()) { widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint(st.nextToken(), fsize)); } Phrase colTitle = new Phrase(contents, f); PdfPCell cell = new PdfPCell(colTitle); cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP); cell.setBorderWidth(2); cell.setBackgroundColor(new Color(200, 200, 200)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setHeaderRows(1); }
|
private static void addHeaderRow(PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException { final String[] headings = new String[] { "Table Name", "Record Count", "Column Name", "Data Type", "Nullable", "Null Count", "% null", "Unique Count", "% unique", "Min Length", "Max Length", "Avg Length", "Min Value", "Max Value", "Avg Value", "Top N Values", "Count" }; int ncols = headings.length; for (int colNo = 0; colNo < ncols; colNo++) { String contents = headings[colNo]; // ensure column width is at least enough for widest word in heading StringTokenizer st = new StringTokenizer(contents); while (st.hasMoreTokens()) { widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint(st.nextToken(), fsize)); } Phrase colTitle = new Phrase(contents, f); PdfPCell cell = new PdfPCell(colTitle); cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP); cell.setBorderWidth(2); cell.setBackgroundColor(new Color(200, 200, 200)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setHeaderRows(1); }
| 1,112,719
|
private static float calcHeaderHeight(PdfPTable table) { int hrows = table.getHeaderRows(); float height = 0f; for (int i = 0; i < hrows; i++) { height += table.getRowHeight(i); } return height; }
|
private float calcHeaderHeight(PdfPTable table) { int hrows = table.getHeaderRows(); float height = 0f; for (int i = 0; i < hrows; i++) { height += table.getRowHeight(i); } return height; }
| 1,112,720
|
protected static PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable, BaseFont bf, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { logger.debug("Making next table"); PdfPTable table = new PdfPTable(widths.length); table.setWidthPercentage(100f); Font f = new Font(bf, fsize); TableProfileResult tProfile = (TableProfileResult) pm.getResult(sqlTable); addHeaderRow(table, bf, f, fsize, widths); // body rows for (SQLColumn col : sqlTable.getColumns()) { addBodyRow(pm, col, table, bf, f, fsize, widths); } logger.debug("Finished body rows"); table.setWidths(widths); return table; }
|
protected PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable, BaseFont bf, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { logger.debug("Making next table"); PdfPTable table = new PdfPTable(widths.length); table.setWidthPercentage(100f); Font f = new Font(bf, fsize); TableProfileResult tProfile = (TableProfileResult) pm.getResult(sqlTable); addHeaderRow(table, bf, f, fsize, widths); // body rows for (SQLColumn col : sqlTable.getColumns()) { addBodyRow(pm, col, table, bf, f, fsize, widths); } logger.debug("Finished body rows"); table.setWidths(widths); return table; }
| 1,112,721
|
protected static PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable, BaseFont bf, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { logger.debug("Making next table"); PdfPTable table = new PdfPTable(widths.length); table.setWidthPercentage(100f); Font f = new Font(bf, fsize); TableProfileResult tProfile = (TableProfileResult) pm.getResult(sqlTable); addHeaderRow(table, bf, f, fsize, widths); // body rows for (SQLColumn col : sqlTable.getColumns()) { addBodyRow(pm, col, table, bf, f, fsize, widths); } logger.debug("Finished body rows"); table.setWidths(widths); return table; }
|
protected static PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable, BaseFont bf, float fsize, float[] widths) throws DocumentException, IOException, ArchitectException, SQLException, InstantiationException, IllegalAccessException { logger.debug("Making next table"); PdfPTable table = new PdfPTable(widths.length); table.setWidthPercentage(100f); Font f = new Font(bf, fsize); addHeaderRow(table, bf, f, fsize, widths); // body rows for (SQLColumn col : sqlTable.getColumns()) { addBodyRow(pm, col, table, bf, f, fsize, widths); } logger.debug("Finished body rows"); table.setWidths(widths); return table; }
| 1,112,722
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { out = new PrintWriter(new BufferedWriter(new FileWriter(file))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDBCS(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } }
|
public void save(ProgressMonitor pm) throws IOException, ArchitectException { out = new PrintWriter(new BufferedWriter(new FileWriter(file))); objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; progress = 0; this.pm = pm; if (pm != null) { pm.setMinimum(0); int pmMax = countSourceTables((SQLObject) sourceDatabases.getModel().getRoot()) + playPen.getPPComponentCount() * 2; logger.debug("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(500); } try { println("<?xml version=\"1.0\"?>"); println("<architect-project version=\"0.1\">"); indent++; println("<project-name>"+name+"</project-name>"); saveDataSources(); saveSourceDatabases(); saveTargetDatabase(); saveDDLGenerator(); savePlayPen(); indent--; println("</architect-project>"); setModified(false); } finally { if (out != null) out.close(); out = null; if (pm != null) pm.close(); pm = null; } }
| 1,112,723
|
public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } int count = 0; for (int i = 0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } theData.filteredDPrimeTable = theData.getFilteredTable(); //after editing the filtered marker list, needs to be prodded into //resizing correctly Dimension size = dPrimeDisplay.getSize(); Dimension pref = dPrimeDisplay.getPreferredSize(); Rectangle visRect = dPrimeDisplay.getVisibleRect(); if (size.width != pref.width && pref.width > visRect.width){ ((JViewport)dPrimeDisplay.getParent()).setViewSize(pref); } dPrimeDisplay.colorDPrime(currentScheme); hapDisplay.theData = theData; changeBlocks(currentBlockDef); if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } }
|
public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } int count = 0; for (int i = 0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } theData.filteredDPrimeTable = theData.getFilteredTable(); //after editing the filtered marker list, needs to be prodded into //resizing correctly Dimension size = dPrimeDisplay.getSize(); Dimension pref = dPrimeDisplay.getPreferredSize(); Rectangle visRect = dPrimeDisplay.getVisibleRect(); if (size.width != pref.width && pref.width > visRect.width){ ((JViewport)dPrimeDisplay.getParent()).setViewSize(pref); } dPrimeDisplay.colorDPrime(currentScheme); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } theBlocks.add(thisBlock); } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } }
| 1,112,725
|
public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } blockMenuItems[3].setEnabled(false); analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
|
public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
| 1,112,726
|
public void changeBlocks(int method){ if (method == BLOX_NONE){ blockMenuItems[BLOX_CUSTOM].setSelected(true); } theData.guessBlocks(method); dPrimeDisplay.repaint(); currentBlockDef = method; try{ if (tabs.getSelectedIndex() == VIEW_HAP_NUM){ hapDisplay.getHaps(); } }catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); }
|
public void changeBlocks(int method){ if (method == BLOX_NONE || method == BLOX_CUSTOM){ blockMenuItems[BLOX_CUSTOM].setSelected(true); } theData.guessBlocks(method); dPrimeDisplay.repaint(); currentBlockDef = method; try{ if (tabs.getSelectedIndex() == VIEW_HAP_NUM){ hapDisplay.getHaps(); } }catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); }
| 1,112,727
|
public void changeBlocks(int method){ if (method == BLOX_NONE){ blockMenuItems[BLOX_CUSTOM].setSelected(true); } theData.guessBlocks(method); dPrimeDisplay.repaint(); currentBlockDef = method; try{ if (tabs.getSelectedIndex() == VIEW_HAP_NUM){ hapDisplay.getHaps(); } }catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); }
|
public void changeBlocks(int method){ if (method == BLOX_NONE){ blockMenuItems[BLOX_CUSTOM].setSelected(true); } if (method != BLOX_CUSTOM){ theData.guessBlocks(method); } dPrimeDisplay.repaint(); currentBlockDef = method; try{ if (tabs.getSelectedIndex() == VIEW_HAP_NUM){ hapDisplay.getHaps(); } }catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); }
| 1,112,728
|
void readBlocksFile(File file) { try{ Vector cust = theData.readBlocks(file); theData.guessBlocks(BLOX_CUSTOM, cust); if (dPrimeDisplay != null && tabs.getSelectedIndex() == VIEW_D_NUM){ dPrimeDisplay.repaint(); } }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
|
void readBlocksFile(File file) { try{ Vector cust = theData.readBlocks(file); theData.guessBlocks(BLOX_CUSTOM, cust); if (dPrimeDisplay != null && tabs.getSelectedIndex() == VIEW_D_NUM){ dPrimeDisplay.repaint(); } }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
| 1,112,729
|
public void doTag(final XMLOutput output) throws Exception { this.session = new JellySession( output ); getBody().run(context, output); }
|
public void doTag(final XMLOutput output) throws Exception { this.session = new JellySession( output ); invokeBody(output); }
| 1,112,730
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
| 1,112,731
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
|
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, top + boxSize/2 - boxRadius, left + (2*theBlock[j]) * boxSize/2, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } }
| 1,112,732
|
void createUI() { setLayout(new GridBagLayout()); folderTree = new JTree( ); folderTree.setRootVisible( true ); folderTree.setShowsRootHandles( true ); folderTree.setEditable( false ); JScrollPane scrollPane = new JScrollPane( folderTree ); scrollPane.setPreferredSize( new Dimension( 300, 300 ) ); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridheight = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; add( scrollPane, c ); JButton addFolderBtn = new JButton( "Add to folder..." ); addFolderBtn.setActionCommand( ADD_ALL_TO_FOLDER_CMD ); addFolderBtn.addActionListener( this ); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; add( addFolderBtn, c ); popup = new JPopupMenu(); JMenuItem addAllItem = new JMenuItem( "Add photos" ); addAllItem.addActionListener( this ); addAllItem.setActionCommand( ADD_ALL_TO_THIS_FOLDER_CMD ); JMenuItem removeAllItem = new JMenuItem( "Remove photos" ); removeAllItem.addActionListener( this ); removeAllItem.setActionCommand( REMOVE_ALL_FROM_THIS_FOLDER_CMD ); popup.add( addAllItem ); popup.add( removeAllItem ); MouseListener popupListener = new PopupListener(); folderTree.addMouseListener( popupListener ); }
|
void createUI() { setLayout(new GridBagLayout()); folderTree = new JTree( ); folderTree.setRootVisible( true ); folderTree.setShowsRootHandles( false ); folderTree.setEditable( false ); JScrollPane scrollPane = new JScrollPane( folderTree ); scrollPane.setPreferredSize( new Dimension( 300, 300 ) ); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridheight = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; add( scrollPane, c ); JButton addFolderBtn = new JButton( "Add to folder..." ); addFolderBtn.setActionCommand( ADD_ALL_TO_FOLDER_CMD ); addFolderBtn.addActionListener( this ); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; add( addFolderBtn, c ); popup = new JPopupMenu(); JMenuItem addAllItem = new JMenuItem( "Add photos" ); addAllItem.addActionListener( this ); addAllItem.setActionCommand( ADD_ALL_TO_THIS_FOLDER_CMD ); JMenuItem removeAllItem = new JMenuItem( "Remove photos" ); removeAllItem.addActionListener( this ); removeAllItem.setActionCommand( REMOVE_ALL_FROM_THIS_FOLDER_CMD ); popup.add( addAllItem ); popup.add( removeAllItem ); MouseListener popupListener = new PopupListener(); folderTree.addMouseListener( popupListener ); }
| 1,112,733
|
public void treeNodesInserted( TreeModelEvent e ) { TreePath parentPath = e.getTreePath(); folderTree.expandPath( parentPath ); }
|
public void treeNodesInserted( TreeModelEvent e ) { TreePath parentPath = e.getTreePath(); folderTree.expandPath( parentPath ); }
| 1,112,734
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } popupExists = true; } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); int size = 2; if (Chromosome.getMarker(marker).getExtra() != null) size++; displayStrings = new Vector(); if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getName())); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); popupExists = true; } if (popupExists){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } popupExists = true; } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); int size = 2; if (Chromosome.getMarker(marker).getExtra() != null) size++; displayStrings = new Vector(); if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getName())); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); popupExists = true; } if (popupExists){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
| 1,112,735
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.