rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{
File infoFile = null; if (infoFileName != null){
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()); } }
if (f.canWrite()){ System.out.println("File " + f.getName() + " can not be written."); System.exit(1); }
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; }
protected static void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table,
protected void addBodyRow(ProfileManager pm, SQLColumn col, PdfPTable table,
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); } }
final int ncols = 17; for (int colNo = 0; colNo < ncols; colNo++) {
for (int colNo = 0; colNo < totalColumn; colNo++) {
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); } }
contents = col.isDefinitelyNullable() ? "Y" : "N"; alignment = Element.ALIGN_CENTER;
if ( cProfile != null && !cProfile.isError() ) { if ( col.isDefinitelyNullable() ) { contents = String.valueOf(cProfile.getNullCount()); if (rowCount == 0) { contents += " / N/A"; alignment = Element.ALIGN_CENTER; } else { contents += " / " + pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = "NOT NULL"; } alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error"; alignment = Element.ALIGN_LEFT; }
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); } }
contents = String.valueOf(cProfile.getNullCount()); alignment = Element.ALIGN_RIGHT; } else { contents = "Column Profiling Error";
contents = String.valueOf(cProfile.getDistinctValueCount()); if (rowCount == 0) { contents += " / N/A"; } else { contents += " / " + pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); } alignment = Element.ALIGN_RIGHT; } else { contents = "";
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); } }
if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; }
contents = String.valueOf(cProfile.getMinLength()); alignment = Element.ALIGN_RIGHT;
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); } }
contents = String.valueOf(cProfile.getDistinctValueCount());
contents = String.valueOf(cProfile.getMaxLength());
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); } }
if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(cProfile.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; }
contents = String.valueOf(cProfile.getAvgLength()); alignment = Element.ALIGN_RIGHT;
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); } }
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());
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); } }
} } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getMaxValue());
contents = String.valueOf(cProfile.getMinValue()); } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 10) { if ( cProfile != null && !cProfile.isError() ) {
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); } }
} } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 14) { if ( cProfile != null && !cProfile.isError() ) { contents = String.valueOf(cProfile.getAvgValue());
contents = String.valueOf(cProfile.getMaxValue()); } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 11) { if ( cProfile != null && !cProfile.isError() ) {
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); } }
} } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 15) {
contents = String.valueOf(cProfile.getAvgValue()); } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 12) {
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); } }
Object value = null;
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); } }
value = cvc.getValue(); sb.append(value).append("\n");
sb.append(cvc.getValue()).append("\n");
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); } }
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) {
alignment = Element.ALIGN_LEFT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (colNo == 13) {
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); } }
StringBuffer truncContents = new StringBuffer(contents.length());
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); } }
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);
for (String contentLine : contents.split("\n")) { if (contentLine.length() > maxCharsInTopN) { contentLine = contentLine.substring(0, maxCharsInTopN) + "..."; } widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint((String) contentLine, fsize)); truncContents.append(contentLine).append("\n"); } PdfPCell cell; if ( colNo == 12 || colNo == 13 ) { cell = new PdfPCell(new Paragraph(truncContents.toString(), f)); cell.setNoWrap(true); } else { Phrase phr = new Phrase(truncContents.toString(), f); cell = new PdfPCell(phr); }
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); } }
private static void addHeaderRow(PdfPTable table,
private void addHeaderRow(PdfPTable table,
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); }
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" };
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 float calcHeaderHeight(PdfPTable table) {
private float calcHeaderHeight(PdfPTable table) {
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; }
protected static PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable,
protected PdfPTable makeNextTable(ProfileManager pm, SQLTable sqlTable,
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; }
TableProfileResult tProfile = (TableProfileResult) pm.getResult(sqlTable);
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; }
saveDBCS();
saveDataSources();
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; } }
d.addFactoryCreate("architect-project/project-data-sources/data-source", dbcsFactory); d.addCallMethod("architect-project/project-data-sources/data-source/property", "put", 2); d.addCallParam("architect-project/project-data-sources/data-source/property", 0, "key"); d.addCallParam("architect-project/project-data-sources/data-source/property", 1, "value");
protected Digester setupDigester() { Digester d = new Digester(); d.setValidating(false); d.push(this); // project name d.addCallMethod("architect-project/project-name", "setName", 0); // argument is element body text // source DB connection specs DBCSFactory dbcsFactory = new DBCSFactory(); d.addFactoryCreate("architect-project/project-connection-specs/dbcs", dbcsFactory); d.addSetProperties ("architect-project/project-connection-specs/dbcs", new String[] {"connection-name", "driver-class", "jdbc-url", "user-name", "user-pass", "sequence-number", "single-login"}, new String[] {"displayName", "driverClass", "url", "user", "pass", "seqNo", "singleLogin"}); d.addCallMethod("architect-project/project-connection-specs/dbcs", "setName", 0); // these instances get picked out of the dbcsIdMap by the SQLDatabase factory // source database hierarchy d.addObjectCreate("architect-project/source-databases", LinkedList.class); d.addSetNext("architect-project/source-databases", "setSourceDatabaseList"); SQLDatabaseFactory dbFactory = new SQLDatabaseFactory(); d.addFactoryCreate("architect-project/source-databases/database", dbFactory); d.addSetProperties("architect-project/source-databases/database"); d.addSetNext("architect-project/source-databases/database", "add"); d.addObjectCreate("architect-project/source-databases/database/catalog", SQLCatalog.class); d.addSetProperties("architect-project/source-databases/database/catalog"); d.addSetNext("architect-project/source-databases/database/catalog", "addChild"); d.addObjectCreate("*/schema", SQLSchema.class); d.addSetProperties("*/schema"); d.addSetNext("*/schema", "addChild"); SQLTableFactory tableFactory = new SQLTableFactory(); d.addFactoryCreate("*/table", tableFactory); d.addSetProperties("*/table"); d.addSetNext("*/table", "addChild"); SQLFolderFactory folderFactory = new SQLFolderFactory(); d.addFactoryCreate("*/folder", folderFactory); d.addSetProperties("*/folder"); d.addSetNext("*/folder", "addChild"); SQLColumnFactory columnFactory = new SQLColumnFactory(); d.addFactoryCreate("*/column", columnFactory); d.addSetProperties("*/column"); d.addSetNext("*/column", "addChild"); SQLRelationshipFactory relationshipFactory = new SQLRelationshipFactory(); d.addFactoryCreate("*/relationship", relationshipFactory); d.addSetProperties("*/relationship"); // the factory adds the relationships to the correct PK and FK tables ColumnMappingFactory columnMappingFactory = new ColumnMappingFactory(); d.addFactoryCreate("*/column-mapping", columnMappingFactory); d.addSetProperties("*/column-mapping"); d.addSetNext("*/column-mapping", "addChild"); SQLExceptionFactory exceptionFactory = new SQLExceptionFactory(); d.addFactoryCreate("*/sql-exception", exceptionFactory); d.addSetProperties("*/sql-exception"); d.addSetNext("*/sql-exception", "addChild"); // target database hierarchy d.addFactoryCreate("architect-project/target-database", dbFactory); d.addSetProperties("architect-project/target-database"); d.addSetNext("architect-project/target-database", "setTargetDatabase"); // the play pen TablePaneFactory tablePaneFactory = new TablePaneFactory(); d.addFactoryCreate("architect-project/play-pen/table-pane", tablePaneFactory); // factory will add the tablepanes to the playpen PPRelationshipFactory ppRelationshipFactory = new PPRelationshipFactory(); d.addFactoryCreate("architect-project/play-pen/table-link", ppRelationshipFactory); DDLGeneratorFactory ddlgFactory = new DDLGeneratorFactory(); d.addFactoryCreate("architect-project/ddl-generator", ddlgFactory); d.addSetProperties("architect-project/ddl-generator"); FileFactory fileFactory = new FileFactory(); d.addFactoryCreate("*/file", fileFactory); d.addSetNext("*/file", "setFile"); d.addSetNext("architect-project/ddl-generator", "setDDLGenerator"); return d; }
changeBlocks(currentBlockDef);
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); }
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; } }
blockMenuItems[3].setEnabled(false);
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()); }
if (method == BLOX_NONE){
if (method == BLOX_NONE || method == BLOX_CUSTOM){
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); }
theData.guessBlocks(method);
if (method != BLOX_CUSTOM){ theData.guessBlocks(method); }
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); }
if (dPrimeDisplay != null && tabs.getSelectedIndex() == VIEW_D_NUM){ dPrimeDisplay.repaint(); }
changeBlocks(BLOX_CUSTOM);
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); } }
getBody().run(context, output);
invokeBody(output);
public void doTag(final XMLOutput output) throws Exception { this.session = new JellySession( output ); getBody().run(context, output); }
long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getSize()-1).getPosition();
long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition();
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)); } }
for (int i = 0; i < Chromosome.getSize(); i++) {
for (int i = 0; i < Chromosome.getFilteredSize(); i++) {
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)); } }
folderTree.setShowsRootHandles( true );
folderTree.setShowsRootHandles( false );
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 ); }
TreePath parentPath = e.getTreePath(); folderTree.expandPath( parentPath );
final TreePath parentPath = e.getTreePath(); SwingUtilities.invokeLater(new java.lang.Runnable() { public void run() { folderTree.expandPath( parentPath ); } });
public void treeNodesInserted( TreeModelEvent e ) { TreePath parentPath = e.getTreePath(); folderTree.expandPath( parentPath ); }
g.setFont(boxFont);
g.setFont(popupFont);
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; } } }
g.setFont(popupFont);
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() == 0){ //if there are no valid markers return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel != 0 || Options.getLDColorScheme() == WMF_SCHEME || Options.getLDColorScheme() == RSQ_SCHEME){ printDPrimeValues = false; } else{ printDPrimeValues = true; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null){ g2.drawImage(gBrowseImage, H_BORDER,V_BORDER,this); // not sure if this is an imageObserver, however imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left, top, lineSpan, TRACK_HEIGHT)); g2.setColor(Color.black); g2.drawRect(left,top,(int)lineSpan,TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDPrimeValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
if(description == null) return "";
public String getDescription() { return description; }
if(type.startsWith("[")){
if(type != null && type.startsWith("[")){
protected String getDisplayType(String type){ if(type.startsWith("[")){ /* convert to readable name. e.g. [Ljava.lang.String to java.lang.String[]*/ String arrayBraces = ""; while(type.startsWith("[")){ type = type.substring(1); arrayBraces += "[]"; } type = getArrayDisplayType(type) + arrayBraces; } return type; }
JButton searchButton = new JButton("Search");
JDefaultButton searchButton = new JDefaultButton("Search");
public void showSearchDialog(final PlayPen pp) { // XXX need to convert to an ArchitectPanel before switching // this to use ArchitectPanelBuilder. final JDialog d = new JDialog((Frame) SwingUtilities.getAncestorOfClass(JFrame.class, pp), "Find"); ButtonGroup matchType = new ButtonGroup(); matchType.add(substringMatch = new JRadioButton("Substring")); matchType.add(exactMatch = new JRadioButton("Exact Match")); matchType.add(regexMatch = new JRadioButton("Regex")); JPanel matchTypePanel = new JPanel(new GridLayout(1,3)); matchTypePanel.add(substringMatch); matchTypePanel.add(exactMatch); matchTypePanel.add(regexMatch); substringMatch.setSelected(true); ButtonGroup searchType = new ButtonGroup(); searchType.add(tableSearch = new JRadioButton("Tables")); searchType.add(relationshipSearch = new JRadioButton("Relationships")); searchType.add(columnSearch = new JRadioButton("Columns")); searchType.add(allSearch = new JRadioButton("Anything")); JPanel searchTypePanel = new JPanel(new GridLayout(4,1)); searchTypePanel.add(tableSearch); searchTypePanel.add(relationshipSearch); searchTypePanel.add(columnSearch); searchTypePanel.add(allSearch); allSearch.setSelected(true); caseInsensitive = new JCheckBox("Ignoring case"); caseInsensitive.setSelected(true); searchExpression = new JTextField(); JButton searchButton = new JButton("Search"); // searchButton.setDefaultCapable(true); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { showResults(d, pp); } catch (ArchitectException ex) { ASUtils.showExceptionDialog("Encountered a problem during search", ex); } } }); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { d.setVisible(false); d.dispose(); } }; cancelAction.putValue(Action.NAME, ArchitectPanelBuilder.CANCEL_BUTTON_LABEL); JButton cancelButton = new JButton(cancelAction); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(searchButton); buttonPanel.add(cancelButton); JComponent cp = (JComponent) d.getContentPane(); cp.setLayout(new FormLayout(10, 10)); cp.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); cp.add(new JLabel("Look for")); cp.add(searchTypePanel); cp.add(new JLabel("Named")); cp.add(searchExpression); cp.add(new JLabel("Comparing by")); cp.add(matchTypePanel); cp.add(new JLabel("")); cp.add(caseInsensitive); cp.add(new JLabel("")); cp.add(buttonPanel); d.getRootPane().setDefaultButton(searchButton); d.pack(); d.setLocationRelativeTo(pp); d.setVisible(true); searchExpression.requestFocus(); }
int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploVector = new Vector(); Vector inputHaploTrios = new Vector(); int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= missingLimit){ tooManyMissingInASegmentA = true; } if (missingB >= missingLimit){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { whichVector[i] = 1; whichVector[i+1] =1; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =1; whichVector[i+3]=1; } else { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= missingLimit){ tooManyMissingInASegment = true; } totalMissing += missing; } if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] == 1 || whichVector[i] == 2) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploVector.add(thisHap); } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploVector); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]);
Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] preFiltBlock = (int[])blocks.elementAt(k); int[] theBlock; int[] selectedMarkers = new int[0]; int[] equivClass = new int[0]; if (preFiltBlock.length > 30){ equivClass = new int[preFiltBlock.length]; int classCounter = 0; for (int x = 0; x < preFiltBlock.length; x++){ int marker1 = preFiltBlock[x]; //already been lumped into an equivalency class if (equivClass[x] != 0){ continue; } //start a new equivalency class for this SNP classCounter ++; equivClass[x] = classCounter; for (int y = x+1; y < preFiltBlock.length; y++){ int marker2 = preFiltBlock[y]; if (marker1 > marker2){ int tmp = marker1; marker1 = marker2; marker2 = tmp; } if ( dpTable.getLDStats(marker1,marker2).getRSquared() == 1.0){ //these two SNPs are redundant equivClass[y] = classCounter; } } } //parse equivalency classes selectedMarkers = new int[classCounter]; for (int x = 0; x < selectedMarkers.length; x++){ selectedMarkers[x] = -1; } for (int x = 0; x < classCounter; x++){ double genoPC = 1.0; for (int y = 0; y < equivClass.length; y++){ if (equivClass[y] == x+1){ //int[]tossed = new int[3]; if (percentBadGenotypes[preFiltBlock[y]] < genoPC){ selectedMarkers[x] = preFiltBlock[y]; genoPC = percentBadGenotypes[preFiltBlock[y]]; } } } } theBlock = selectedMarkers; //System.out.println("Block " + k + " " + theBlock.length + "/" + preFiltBlock.length); }else{ theBlock = preFiltBlock; } //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploVector = new Vector(); Vector inputHaploTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploVector (singletons), 2 indicates inputHaploTrios, //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= missingLimit){ tooManyMissingInASegmentA = true; } if (missingB >= missingLimit){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { whichVector[i] = 1; whichVector[i+1] =1; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =1; whichVector[i+3]=1; } else { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= missingLimit){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] == 1 || whichVector[i] == 2) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploVector.add(thisHap); } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploVector); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); //kirby patch EM theEM = new EM(); EMReturn EMresults = theEM.full_em_breakup(input_haplos, 4, block_size, 0,trioCount); int p = 0; Haplotype[] tempArray = new Haplotype[EMresults.numHaplos()]; int[][] returnedHaplos = EMresults.getHaplotypes(); double[] returnedFreqs = EMresults.getFrequencies(); for (int i = 0; i < EMresults.numHaplos(); i++){ int[] genos = new int[returnedHaplos[i].length]; for (int j = 0; j < genos.length; j++){ if (returnedHaplos[i][j] == 1){ genos[j] = Chromosome.getMarker(theBlock[j]).getMajor(); }else{ if (Chromosome.getMarker(theBlock[j]).getMinor() == 0){ genos[j] = 8; }else{ genos[j] = Chromosome.getMarker(theBlock[j]).getMinor(); } } } if (selectedMarkers.length > 0){ //we need to reassemble the haplotypes Hashtable hapsHash = new Hashtable(); //add to hash all the genotypes we phased for (int q = 0; q < genos.length; q++){ hapsHash.put(new Integer(theBlock[q]), new Integer(genos[q])); } //now add all the genotypes we didn't bother phasing, based on //which marker they are identical to for (int q = 0; q < equivClass.length; q++){ int currentClass = equivClass[q]-1; if (selectedMarkers[currentClass] == preFiltBlock[q]){ //we alredy added the phased genotypes above continue; } int indexIntoBlock=0; for (int x = 0; x < theBlock.length; x++){ if (theBlock[x] == selectedMarkers[currentClass]){ indexIntoBlock = x; break; } } //this (somewhat laboriously) reconstructs whether to add the minor or major allele //for markers with MAF close to 0.50 we can't use major/minor alleles to match //'em up 'cause these might change given missing data if (Chromosome.getMarker(selectedMarkers[currentClass]).getMAF() > 0.4){ for (int z = 0; z < chromosomes.size(); z++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(z); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++z); int theGeno = thisChrom.getGenotype(selectedMarkers[currentClass]); int nextGeno = nextChrom.getGenotype(selectedMarkers[currentClass]); if (theGeno == nextGeno && theGeno == genos[indexIntoBlock] && thisChrom.getGenotype(preFiltBlock[q]) != 0){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(thisChrom.getGenotype(preFiltBlock[q]))); } } }else{ if (Chromosome.getMarker(selectedMarkers[currentClass]).getMajor() == genos[indexIntoBlock]){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMajor())); }else{ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMinor())); } } } genos = new int[preFiltBlock.length]; for (int q = 0; q < preFiltBlock.length; q++){ genos[q] = ((Integer)hapsHash.get(new Integer(preFiltBlock[q]))).intValue(); } } double tempPerc = returnedFreqs[i]; if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, preFiltBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; }
EM theEM = new EM(); EMReturn EMresults = theEM.full_em_breakup(input_haplos, 4, block_size, 0,trioCount);
EM theEM = new EM(chromosomes,numTrios); theEM.doEM(theBlock);
Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] preFiltBlock = (int[])blocks.elementAt(k); int[] theBlock; int[] selectedMarkers = new int[0]; int[] equivClass = new int[0]; if (preFiltBlock.length > 30){ equivClass = new int[preFiltBlock.length]; int classCounter = 0; for (int x = 0; x < preFiltBlock.length; x++){ int marker1 = preFiltBlock[x]; //already been lumped into an equivalency class if (equivClass[x] != 0){ continue; } //start a new equivalency class for this SNP classCounter ++; equivClass[x] = classCounter; for (int y = x+1; y < preFiltBlock.length; y++){ int marker2 = preFiltBlock[y]; if (marker1 > marker2){ int tmp = marker1; marker1 = marker2; marker2 = tmp; } if ( dpTable.getLDStats(marker1,marker2).getRSquared() == 1.0){ //these two SNPs are redundant equivClass[y] = classCounter; } } } //parse equivalency classes selectedMarkers = new int[classCounter]; for (int x = 0; x < selectedMarkers.length; x++){ selectedMarkers[x] = -1; } for (int x = 0; x < classCounter; x++){ double genoPC = 1.0; for (int y = 0; y < equivClass.length; y++){ if (equivClass[y] == x+1){ //int[]tossed = new int[3]; if (percentBadGenotypes[preFiltBlock[y]] < genoPC){ selectedMarkers[x] = preFiltBlock[y]; genoPC = percentBadGenotypes[preFiltBlock[y]]; } } } } theBlock = selectedMarkers; //System.out.println("Block " + k + " " + theBlock.length + "/" + preFiltBlock.length); }else{ theBlock = preFiltBlock; } //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploVector = new Vector(); Vector inputHaploTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploVector (singletons), 2 indicates inputHaploTrios, //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= missingLimit){ tooManyMissingInASegmentA = true; } if (missingB >= missingLimit){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { whichVector[i] = 1; whichVector[i+1] =1; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =1; whichVector[i+3]=1; } else { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= missingLimit){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] == 1 || whichVector[i] == 2) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploVector.add(thisHap); } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploVector); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); //kirby patch EM theEM = new EM(); EMReturn EMresults = theEM.full_em_breakup(input_haplos, 4, block_size, 0,trioCount); int p = 0; Haplotype[] tempArray = new Haplotype[EMresults.numHaplos()]; int[][] returnedHaplos = EMresults.getHaplotypes(); double[] returnedFreqs = EMresults.getFrequencies(); for (int i = 0; i < EMresults.numHaplos(); i++){ int[] genos = new int[returnedHaplos[i].length]; for (int j = 0; j < genos.length; j++){ if (returnedHaplos[i][j] == 1){ genos[j] = Chromosome.getMarker(theBlock[j]).getMajor(); }else{ if (Chromosome.getMarker(theBlock[j]).getMinor() == 0){ genos[j] = 8; }else{ genos[j] = Chromosome.getMarker(theBlock[j]).getMinor(); } } } if (selectedMarkers.length > 0){ //we need to reassemble the haplotypes Hashtable hapsHash = new Hashtable(); //add to hash all the genotypes we phased for (int q = 0; q < genos.length; q++){ hapsHash.put(new Integer(theBlock[q]), new Integer(genos[q])); } //now add all the genotypes we didn't bother phasing, based on //which marker they are identical to for (int q = 0; q < equivClass.length; q++){ int currentClass = equivClass[q]-1; if (selectedMarkers[currentClass] == preFiltBlock[q]){ //we alredy added the phased genotypes above continue; } int indexIntoBlock=0; for (int x = 0; x < theBlock.length; x++){ if (theBlock[x] == selectedMarkers[currentClass]){ indexIntoBlock = x; break; } } //this (somewhat laboriously) reconstructs whether to add the minor or major allele //for markers with MAF close to 0.50 we can't use major/minor alleles to match //'em up 'cause these might change given missing data if (Chromosome.getMarker(selectedMarkers[currentClass]).getMAF() > 0.4){ for (int z = 0; z < chromosomes.size(); z++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(z); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++z); int theGeno = thisChrom.getGenotype(selectedMarkers[currentClass]); int nextGeno = nextChrom.getGenotype(selectedMarkers[currentClass]); if (theGeno == nextGeno && theGeno == genos[indexIntoBlock] && thisChrom.getGenotype(preFiltBlock[q]) != 0){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(thisChrom.getGenotype(preFiltBlock[q]))); } } }else{ if (Chromosome.getMarker(selectedMarkers[currentClass]).getMajor() == genos[indexIntoBlock]){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMajor())); }else{ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMinor())); } } } genos = new int[preFiltBlock.length]; for (int q = 0; q < preFiltBlock.length; q++){ genos[q] = ((Integer)hapsHash.get(new Integer(preFiltBlock[q]))).intValue(); } } double tempPerc = returnedFreqs[i]; if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, preFiltBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; }
Haplotype[] tempArray = new Haplotype[EMresults.numHaplos()]; int[][] returnedHaplos = EMresults.getHaplotypes(); double[] returnedFreqs = EMresults.getFrequencies(); for (int i = 0; i < EMresults.numHaplos(); i++){
Haplotype[] tempArray = new Haplotype[theEM.numHaplos()]; int[][] returnedHaplos = theEM.getHaplotypes(); double[] returnedFreqs = theEM.getFrequencies(); for (int i = 0; i < theEM.numHaplos(); i++){
Haplotype[][] generateHaplotypes(Vector blocks, int hapthresh) throws HaploViewException{ //TODO: output indiv hap estimates Haplotype[][] results = new Haplotype[blocks.size()][]; //String raw = new String(); //String currentLine; this.totalBlocks = blocks.size(); this.blocksDone = 0; for (int k = 0; k < blocks.size(); k++){ this.blocksDone++; int[] preFiltBlock = (int[])blocks.elementAt(k); int[] theBlock; int[] selectedMarkers = new int[0]; int[] equivClass = new int[0]; if (preFiltBlock.length > 30){ equivClass = new int[preFiltBlock.length]; int classCounter = 0; for (int x = 0; x < preFiltBlock.length; x++){ int marker1 = preFiltBlock[x]; //already been lumped into an equivalency class if (equivClass[x] != 0){ continue; } //start a new equivalency class for this SNP classCounter ++; equivClass[x] = classCounter; for (int y = x+1; y < preFiltBlock.length; y++){ int marker2 = preFiltBlock[y]; if (marker1 > marker2){ int tmp = marker1; marker1 = marker2; marker2 = tmp; } if ( dpTable.getLDStats(marker1,marker2).getRSquared() == 1.0){ //these two SNPs are redundant equivClass[y] = classCounter; } } } //parse equivalency classes selectedMarkers = new int[classCounter]; for (int x = 0; x < selectedMarkers.length; x++){ selectedMarkers[x] = -1; } for (int x = 0; x < classCounter; x++){ double genoPC = 1.0; for (int y = 0; y < equivClass.length; y++){ if (equivClass[y] == x+1){ //int[]tossed = new int[3]; if (percentBadGenotypes[preFiltBlock[y]] < genoPC){ selectedMarkers[x] = preFiltBlock[y]; genoPC = percentBadGenotypes[preFiltBlock[y]]; } } } } theBlock = selectedMarkers; //System.out.println("Block " + k + " " + theBlock.length + "/" + preFiltBlock.length); }else{ theBlock = preFiltBlock; } //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploVector = new Vector(); Vector inputHaploTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploVector (singletons), 2 indicates inputHaploTrios, //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= missingLimit){ tooManyMissingInASegmentA = true; } if (missingB >= missingLimit){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { whichVector[i] = 1; whichVector[i+1] =1; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =1; whichVector[i+3]=1; } else { whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= missingLimit){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] == 1 || whichVector[i] == 2) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ thisHap[j] = '0'; } } } if(whichVector[i] == 1) { inputHaploVector.add(thisHap); } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); } } } int trioCount = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploVector); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); //kirby patch EM theEM = new EM(); EMReturn EMresults = theEM.full_em_breakup(input_haplos, 4, block_size, 0,trioCount); int p = 0; Haplotype[] tempArray = new Haplotype[EMresults.numHaplos()]; int[][] returnedHaplos = EMresults.getHaplotypes(); double[] returnedFreqs = EMresults.getFrequencies(); for (int i = 0; i < EMresults.numHaplos(); i++){ int[] genos = new int[returnedHaplos[i].length]; for (int j = 0; j < genos.length; j++){ if (returnedHaplos[i][j] == 1){ genos[j] = Chromosome.getMarker(theBlock[j]).getMajor(); }else{ if (Chromosome.getMarker(theBlock[j]).getMinor() == 0){ genos[j] = 8; }else{ genos[j] = Chromosome.getMarker(theBlock[j]).getMinor(); } } } if (selectedMarkers.length > 0){ //we need to reassemble the haplotypes Hashtable hapsHash = new Hashtable(); //add to hash all the genotypes we phased for (int q = 0; q < genos.length; q++){ hapsHash.put(new Integer(theBlock[q]), new Integer(genos[q])); } //now add all the genotypes we didn't bother phasing, based on //which marker they are identical to for (int q = 0; q < equivClass.length; q++){ int currentClass = equivClass[q]-1; if (selectedMarkers[currentClass] == preFiltBlock[q]){ //we alredy added the phased genotypes above continue; } int indexIntoBlock=0; for (int x = 0; x < theBlock.length; x++){ if (theBlock[x] == selectedMarkers[currentClass]){ indexIntoBlock = x; break; } } //this (somewhat laboriously) reconstructs whether to add the minor or major allele //for markers with MAF close to 0.50 we can't use major/minor alleles to match //'em up 'cause these might change given missing data if (Chromosome.getMarker(selectedMarkers[currentClass]).getMAF() > 0.4){ for (int z = 0; z < chromosomes.size(); z++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(z); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++z); int theGeno = thisChrom.getGenotype(selectedMarkers[currentClass]); int nextGeno = nextChrom.getGenotype(selectedMarkers[currentClass]); if (theGeno == nextGeno && theGeno == genos[indexIntoBlock] && thisChrom.getGenotype(preFiltBlock[q]) != 0){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(thisChrom.getGenotype(preFiltBlock[q]))); } } }else{ if (Chromosome.getMarker(selectedMarkers[currentClass]).getMajor() == genos[indexIntoBlock]){ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMajor())); }else{ hapsHash.put(new Integer(preFiltBlock[q]), new Integer(Chromosome.getMarker(preFiltBlock[q]).getMinor())); } } } genos = new int[preFiltBlock.length]; for (int q = 0; q < preFiltBlock.length; q++){ genos[q] = ((Integer)hapsHash.get(new Integer(preFiltBlock[q]))).intValue(); } } double tempPerc = returnedFreqs[i]; if (tempPerc*100 > hapthresh){ tempArray[p] = new Haplotype(genos, tempPerc, preFiltBlock); p++; } } //make the results array only large enough to hold haps //which pass threshold above results[k] = new Haplotype[p]; for (int z = 0; z < p; z++){ results[k][z] = tempArray[z]; } } return results; }
chroms.add(new Chromosome(ped, indiv, genos, infile.getName()));
chroms.add(new Chromosome(ped, indiv, genos, infile.getName(), 0));
void prepareHapsInput(File infile) throws IOException, HaploViewException{ //this method is called to suck in data from a file (its only argument) //of genotypes and sets up the Chromosome objects. String currentLine; Vector chroms = new Vector(); byte[] genos = new byte[0]; String ped, indiv; if(infile.length() < 1){ throw new HaploViewException("Genotype file is empty or does not exist: " + infile.getName()); } //read the file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; int numTokens = 0; boolean even = true; while ((currentLine = in.readLine()) != null){ lineCount++; //each line is expected to be of the format: //ped indiv geno geno geno geno... if (currentLine.length() == 0){ //skip blank lines continue; } even = !even; StringTokenizer st = new StringTokenizer(currentLine); //first two tokens are expected to be ped, indiv if (st.hasMoreTokens()){ ped = st.nextToken(); indiv = st.nextToken(); }else{ throw new HaploViewException("Genotype file error:\nLine " + lineCount + " appears to have fewer than 2 columns."); } //all other tokens are loaded into a vector (they should all be genotypes) genos = new byte[st.countTokens()]; int q = 0; if (numTokens == 0){ numTokens = st.countTokens(); } if (numTokens != st.countTokens()){ throw new HaploViewException("Genotype file error:\nLine " + lineCount + " appears to have an incorrect number of entries"); } while (st.hasMoreTokens()){ String thisGenotype = (String)st.nextElement(); if (thisGenotype.equals("h")) { genos[q] = 9; }else{ try{ genos[q] = Byte.parseByte(thisGenotype); }catch (NumberFormatException nfe){ throw new HaploViewException("Genotype file input error:\ngenotype value \"" + thisGenotype + "\" on line " + lineCount + " not allowed."); } } if (genos[q] < 0 || genos[q] > 9){ throw new HaploViewException("Genotype file input error:\ngenotype value \"" + genos[q] + "\" on line " + lineCount + " not allowed."); } q++; } //a Chromosome is created and added to a vector of chromosomes. //this is what is evetually returned. chroms.add(new Chromosome(ped, indiv, genos, infile.getName())); } if (!even){ //we're missing a line here throw new HaploViewException("Genotype file appears to have an odd number of lines.\n"+ "Each individual is required to have two chromosomes"); } chromosomes = chroms; //initialize realIndex Chromosome.doFilter(genos.length); //wipe clean any existing marker info so we know we're starting clean with a new file Chromosome.markers = null; }
Writer writer = new OutputStreamWriter( new FileOutputStream( name ), encoding );
Writer writer = new OutputStreamWriter( new FileOutputStream( name, doAppend ), encoding );
public void doTag(final XMLOutput output) throws JellyTagException { try { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); context.setVariable(var, writer.toString()); } else { throw new JellyTagException( "This tag must have either the 'name' or the 'var' variables defined" ); } } catch (FileNotFoundException e) { throw new JellyTagException(e); } catch (UnsupportedEncodingException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException("could not write file",e); } }
if (haplos == null){ return null; }
public Haplotype[][] filterHaplos(Haplotype[][] haplos) { Haplotype[][] filteredHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < haplos[i].length; j++){ if (haplos[i][j].getPercentage()*100 > Options.getHaplotypeDisplayThreshold()){ tempVector.add(haplos[i][j]); } } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } return filteredHaplos; }
OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else{ textData.guessBlocks(blockOutputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);
}else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); }
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 textData.linkageToChrom(inputFile, PED); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if ((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds has been ignored: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ HaploData.saveHapAssocToText(haplos, validateOutputFile(fileName + ".HAPASSOC")); } } } 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(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, validateOutputFile(fileName + ".ASSOC")); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, validateOutputFile(fileName + ".ASSOC")); } } 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()); } }
BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG);
BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG);
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 textData.linkageToChrom(inputFile, PED); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if ((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds has been ignored: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ HaploData.saveHapAssocToText(haplos, validateOutputFile(fileName + ".HAPASSOC")); } } } 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(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, validateOutputFile(fileName + ".ASSOC")); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, validateOutputFile(fileName + ".ASSOC")); } } 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()); } }
if (expectedValue == null && expectedValue == null) {
if (expectedValue == null && actualValue == null) {
public void doTag(XMLOutput output) throws Exception { String message = getBodyText(); Object expectedValue = expected.evaluate(context); Object actualValue = actual.evaluate(context); if (expectedValue == null && expectedValue == null) { return; } if (actualValue != null && expectedValue.equals(actualValue)) { return; } String expressions = "\nExpected expression: " + expected + "\nActual expression: " + actual; failNotEquals(message, expectedValue, actualValue, expressions); }
message = "File does not exist."
message = "File does not exist.";
public void doTag(XMLOutput output) throws JellyTagException { String message = getBodyText(); if (message == null || message.length() == 0) { message = "File does not exist." } if (file == null) { fail(message, "file given is null"); } else { if (!file.exists()) { fail(message); } } } /** * The file to be tested. If this file exists, the test will pass. * @param aFile the file to test. */ public void setFile(File aFile) { file = aFile; }
public void setFile(File aFile) { file = aFile; }
public void doTag(XMLOutput output) throws JellyTagException { String message = getBodyText(); if (message == null || message.length() == 0) { message = "File does not exist." } if (file == null) { fail(message, "file given is null"); } else { if (!file.exists()) { fail(message); } } } /** * The file to be tested. If this file exists, the test will pass. * @param aFile the file to test. */ public void setFile(File aFile) { file = aFile; }
DateFormat df = new SimpleDateFormat( dateFormatStr );
DateFormat df = getDateFormat();
public FuzzyDate parse(String strDate) { DateFormat df = new SimpleDateFormat( dateFormatStr ); FuzzyDate fd = null; try { Date d = df.parse( strDate ); if ( d != null ) { Date midpoint = new Date( d.getTime() + getFuzzyPeriodLength(d) / 2 ); fd = new FuzzyDate( midpoint, ((float)(getFuzzyPeriodLength(d))) / (2*FuzzyDate.MILLIS_IN_DAY) ); } } catch ( ParseException e ) { log.warn( "ParseException: " + e.getMessage() ); } return fd; }
fd = new FuzzyDate( midpoint, ((float)(getFuzzyPeriodLength(d))) / (2*FuzzyDate.MILLIS_IN_DAY) );
fd = new FuzzyDate( midpoint, 0.5 * getFloatFuzzyPeriodLength( d ) );
public FuzzyDate parse(String strDate) { DateFormat df = new SimpleDateFormat( dateFormatStr ); FuzzyDate fd = null; try { Date d = df.parse( strDate ); if ( d != null ) { Date midpoint = new Date( d.getTime() + getFuzzyPeriodLength(d) / 2 ); fd = new FuzzyDate( midpoint, ((float)(getFuzzyPeriodLength(d))) / (2*FuzzyDate.MILLIS_IN_DAY) ); } } catch ( ParseException e ) { log.warn( "ParseException: " + e.getMessage() ); } return fd; }
iter = foldersNotFound.iterator(); while ( iter.hasNext() ) { PhotoFolder subfolder = (PhotoFolder)iter.next(); subfolder.delete(); }
void indexDirectory( File dir, PhotoFolder folder, int startPercent, int endPercent ) { /** Maintain information how many instances for the photos that were previously added to the folder is found */ HashMap photoInstanceCounts = new HashMap(); if ( folder != null ) { for ( int n = 0; n < folder.getPhotoCount(); n++ ) { photoInstanceCounts.put( folder.getPhoto( n ), new Integer( 0 ) ); } } File files[] = dir.listFiles(); // Count the files int fileCount = 0; int subdirCount = 0; for ( int n = 0; n < files.length; n++ ) { if ( files[n].isDirectory() ) { subdirCount++; } else { fileCount++; } } ProgressCalculator c = new ProgressCalculator( startPercent, endPercent, fileCount, subdirCount ); int nFile = 0; int nDir = 0; for ( int n = 0; n < files.length; n++ ) { File f = files[n]; if ( f.isDirectory() ) { // Create the matching folder PhotoFolder subfolder = null; if ( folder != null ) { subfolder = findSubfolderByName( folder, f.getName() ); if ( subfolder == null ) { subfolder = PhotoFolder.create( f.getName(), folder ); newFolderCount++; } } /* Calclate the start & end percentages to use when indexing this directory. Formula goes so that we estimate that to index current dirctory completely we must index files in subDirCount+1 directories (all subdirs + current directory). So we divide endPercent - startPercent into this many steps) */ int subdirStart = c.getProgress(); nDir++; c.setProcessedSubdirs( nDir ); int subdirEnd = c.getProgress(); indexDirectory( f, subfolder, subdirStart, subdirEnd ); percentComplete = c.getProgress(); } else { if ( f.canRead() ) { currentEvent = new ExtVolIndexerEvent( this ); PhotoInfo p = indexFile( f ); if ( p != null ) { if ( photoInstanceCounts.containsKey( p ) ) { // The photo is already in this folder int refCount = ((Integer)photoInstanceCounts.get( p ) ).intValue(); photoInstanceCounts.remove( p ); photoInstanceCounts.put( p, new Integer( refCount+1 )); } else { // The photo is not yet in this folder folder.addPhoto( p ); photoInstanceCounts.put( p, new Integer( 1 )); } } nFile++; c.setProcessedFiles( nFile ); percentComplete = c.getProgress(); notifyListeners( currentEvent ); } } } /* Check if some of the photos that were in folder before were not found in this directory */ Iterator iter = photoInstanceCounts.keySet().iterator(); while ( iter.hasNext() ) { PhotoInfo p = (PhotoInfo ) iter.next(); int refCount = ((Integer)photoInstanceCounts.get( p )).intValue(); if ( refCount == 0 ) { folder.removePhoto( p ); } } }
Object title = attributes.remove("title"); if (title != null) { getWindow().getShell().setText((String)title); }
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { Map attributes = getAttributes(); Object parent = attributes.remove("parent"); if (parent != null) { if (parent instanceof Shell) { this.parent = (Shell) parent; } else { throw new JellyTagException( "The parent attribute is not a Shell, it is of type: " + parent.getClass().getName() + " value: " + parent); } } super.doTag(output); }
return new JSR160ServerConnection(jmxc);
return new JSR160ServerConnection(jmxc, jmxc.getMBeanServerConnection());
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); return new JSR160ServerConnection(jmxc); } catch (Throwable e) { throw new ConnectionFailedException(e); } }
Font bigguns = new Font("Default", Font.BOLD, 14);
Font bigguns = new Font("Default", Font.PLAIN, 14);
public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.BOLD, 14); JLabel announceLabel = new JLabel("A newer version of Haploview is available: " + uc.getNewVersion()); announceLabel.setAlignmentX(Component.CENTER_ALIGNMENT); announceLabel.setFont(bigguns); JLabel urlLabel = new JLabel("http://www.broad.mit.edu/mpg/haploview/"); urlLabel.setFont(bigguns); urlLabel.setAlignmentX(Component.CENTER_ALIGNMENT); JScrollPane changeScroller = null; try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://18.157.34.100:8080/hapchanges.html")); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(150,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } contents.add(announceLabel); contents.add(urlLabel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(changeScroller); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); }
changeScroller.setPreferredSize(new Dimension(150,150));
changeScroller.setPreferredSize(new Dimension(250,150));
public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.BOLD, 14); JLabel announceLabel = new JLabel("A newer version of Haploview is available: " + uc.getNewVersion()); announceLabel.setAlignmentX(Component.CENTER_ALIGNMENT); announceLabel.setFont(bigguns); JLabel urlLabel = new JLabel("http://www.broad.mit.edu/mpg/haploview/"); urlLabel.setFont(bigguns); urlLabel.setAlignmentX(Component.CENTER_ALIGNMENT); JScrollPane changeScroller = null; try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://18.157.34.100:8080/hapchanges.html")); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(150,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } contents.add(announceLabel); contents.add(urlLabel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(changeScroller); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); }
contents.add(changeScroller);
JPanel scrollHolder = new JPanel(); scrollHolder.add(changeScroller); contents.add(scrollHolder);
public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.BOLD, 14); JLabel announceLabel = new JLabel("A newer version of Haploview is available: " + uc.getNewVersion()); announceLabel.setAlignmentX(Component.CENTER_ALIGNMENT); announceLabel.setFont(bigguns); JLabel urlLabel = new JLabel("http://www.broad.mit.edu/mpg/haploview/"); urlLabel.setFont(bigguns); urlLabel.setAlignmentX(Component.CENTER_ALIGNMENT); JScrollPane changeScroller = null; try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://18.157.34.100:8080/hapchanges.html")); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(150,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } contents.add(announceLabel); contents.add(urlLabel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(changeScroller); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); }
public void run(Context context, XMLOutput output) throws Exception { output.startElement( uri, localName, qname, attributes ); getBody().run(context, output); output.endElement( uri, localName, qname ); }
public void run(JellyContext context, XMLOutput output) throws Exception { output.startElement(uri, localName, qname, attributes); getBody().run(context, output); output.endElement(uri, localName, qname); }
public void run(Context context, XMLOutput output) throws Exception { output.startElement( uri, localName, qname, attributes ); getBody().run(context, output); output.endElement( uri, localName, qname ); }
int index = attributes.getIndex( "", name ); if ( index > 0 ) { attributes.removeAttribute( index ); } if ( value != null ) { attributes.addAttribute( "", name, name, "CDATA", value.toString() ); } }
int index = attributes.getIndex("", name); if (index >= 0) { attributes.removeAttribute(index); } if (value != null) { attributes.addAttribute("", name, name, "CDATA", value.toString()); } }
public void setAttribute(String name, Object value) { // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### - Tag attributes should allow for namespace aware int index = attributes.getIndex( "", name ); if ( index > 0 ) { attributes.removeAttribute( index ); } // treat null values as no attribute if ( value != null ) { attributes.addAttribute( "", name, name, "CDATA", value.toString() ); } }
if (fileType == HAPS){ caller.readPhasedGenotypes(returnStrings); }else if (fileType == PED){ caller.readPedGenotypes(returnStrings, PED); }else if (fileType == DCC){ caller.readPedGenotypes(returnStrings, DCC); }
caller.readGenotypes(returnStrings, fileType);
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command==RAW_DATA){ load(PED); }else if (command == PHASED_DATA){ load(HAPS); }else if (command == HAPMAP_DATA){ load(DCC); }else if (command == BROWSE_GENO){ browse(GENO); }else if (command == BROWSE_INFO){ browse(INFO); }else if (command == "OK"){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ caller.assocTest = 1; } else { caller.assocTest = 2; } }else{ caller.assocTest = 0; } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (fileType == HAPS){ caller.readPhasedGenotypes(returnStrings); }else if (fileType == PED){ caller.readPedGenotypes(returnStrings, PED); }else if (fileType == DCC){ caller.readPedGenotypes(returnStrings, DCC); } if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); } this.dispose(); }else if (command == "Cancel"){ this.dispose(); }else if (command == "tdt"){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } }
if ( value.length() > maxLength ) {
if ( value != null && value.length() > maxLength ) {
void checkStringProperty( String propertyName, String value, int maxLength ) throws IllegalArgumentException { if ( value.length() > maxLength ) { throw new IllegalArgumentException( propertyName + " cannot be longer than " + maxLength + " characters" ); } }
* Populates the schema dropdown box from the schema * parent that doStuff() populated. * @throws ArchitectException
* Populates the schema dropdown box from the schema * parent that doStuff() populated. * * @throws ArchitectException
public void cleanup() throws ArchitectException { setCleanupExceptionMessage("Could not populate catalog dropdown!"); catalogDropdown.removeAllItems(); catalogDropdown.setEnabled(false); // This is either a database, a catalog, or null depending on how db is structured SQLObject schemaParent; if (db.isCatalogContainer()) { for (SQLObject item : (List<SQLObject>) db.getChildren()) { catalogDropdown.addItem(item); } // check if we need to do schemas SQLCatalog cat = (SQLCatalog) catalogDropdown.getSelectedItem(); if (cat == null) { // there are no catalogs (database is completely empty) schemaParent = null; catalogDropdown.setEnabled(false); } else if (cat.isSchemaContainer()) { // there are schemas in this catalog schemaParent = cat; catalogDropdown.setEnabled(true); } else { // there are catalogs, but they don't contain schemas schemaParent = null; catalogDropdown.setEnabled(true); } } else if (db.isSchemaContainer()) { schemaParent = db; catalogDropdown.setEnabled(false); } else { // database contains tables directly schemaParent = null; catalogDropdown.setEnabled(false); } schemaDropdown.removeAllItems(); schemaDropdown.setEnabled(false); if (schemaParent == null) { startCompareAction.setEnabled(isStartable()); } else { // need a final reference to this so we can use it in the inner class final SQLObject finalSchemaParent = schemaParent; new Thread(new Populator() { @Override public void doStuff() throws Exception { ListerProgressBarUpdater progressBarUpdater = new ListerProgressBarUpdater(progressBar, this); new javax.swing.Timer(100, progressBarUpdater).start(); // this populates the schema parent (populate is not visible here) finalSchemaParent.getChildren(); } /** * Populates the schema dropdown box from the schema * parent that doStuff() populated. * @throws ArchitectException */ @Override public void cleanup() throws ArchitectException { setCleanupExceptionMessage("Could not populate schema dropdown!"); for (SQLObject item : (List<SQLObject>) finalSchemaParent.getChildren()) { schemaDropdown.addItem(item); } if (schemaDropdown.getItemCount() > 0) { schemaDropdown.setEnabled(true); } startCompareAction.setEnabled(isStartable()); } }).start(); } }
} else if (englishButton.isSelected()) {
} else if (englishButton.isSelected()) { int objectCount = 0;
public void actionPerformed(ActionEvent e) { startCompareAction.setEnabled(false); CompareDMFrame cf = null; try { SQLObject left = source.getObjectToCompare(); if (left.getChildType() == SQLTable.class) { sourceTables = left.getChildren(); } else { sourceTables = new ArrayList(); } SQLObject right = target.getObjectToCompare(); if (right.getChildType() == SQLTable.class) { targetTables = right.getChildren(); } else { targetTables = new ArrayList(); } // XXX: should do most or all of this work in a worker thread Map<DiffType, AttributeSet> styles = new HashMap<DiffType, AttributeSet>(); { SimpleAttributeSet att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.green); styles.put(DiffType.LEFTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.red); styles.put(DiffType.RIGHTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.black); styles.put(DiffType.SAME, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.orange); styles.put(DiffType.MODIFIED, att); } CompareSQL sourceComp = new CompareSQL(sourceTables, targetTables); List<DiffChunk<SQLObject>> diff = sourceComp.generateTableDiffs(); CompareSQL targetComp = new CompareSQL(targetTables, sourceTables); List<DiffChunk<SQLObject>> diff1 = targetComp.generateTableDiffs(); DefaultStyledDocument sourceDoc = new DefaultStyledDocument(); DefaultStyledDocument targetDoc = new DefaultStyledDocument(); if (sqlButton.isSelected()) { throw new UnsupportedOperationException( "We don't support DDL generation yet"); } else if (englishButton.isSelected()) { for (DiffChunk<SQLObject> chunk : diff) { sourceDoc.insertString( sourceDoc.getLength(), chunk.getData().toString()+"\n", styles.get(chunk.getType())); } for (DiffChunk<SQLObject> chunk1 : diff1) { targetDoc.insertString( targetDoc.getLength(), chunk1.getData().toString()+"\n", styles.get(chunk1.getType())); } } else { throw new IllegalStateException( "Don't know what type of output to make"); } // get the title string for the compareDMFrame String compMethod = null; if (sqlButton.isSelected()) { compMethod = "SQL"; } else { compMethod = OUTPUT_ENGLISH; } String titleString = "Comparing " +left.getName() + " to " + right.getName() + " using " + compMethod; cf = new CompareDMFrame( sourceDoc, targetDoc, titleString, source.getDatabase()); cf.pack(); cf.setVisible(true); } catch (ArchitectDiffException ex) { JOptionPane.showMessageDialog( CompareDMPanel.this, "Could not perform the diff:\n"+ex.getMessage(), "Diff Error", JOptionPane.ERROR_MESSAGE); logger.error("Couldn't do diff", ex); } catch (ArchitectException exp) { ASUtils.showExceptionDialog( "StartCompareAction failed", exp); logger.error("StartCompareAction failed", exp); } catch (FileNotFoundException ex) { ASUtils.showExceptionDialog("Your file could not be found.", ex); logger.error("File could not be found.", ex); } catch (IOException ex) { ASUtils.showExceptionDialog("Could not read file", ex); logger.error("Could not read file", ex); } catch (BadLocationException ex) { ASUtils.showExceptionDialog("Could not create document for results", ex); logger.error("Could not create document for results", ex); } catch (Exception ex) { ASUtils.showExceptionDialog("Unxepected Exception!", ex); logger.error("Unxepected Exception!", ex); } finally { this.setEnabled(isStartable()); } }
sourceDoc.insertString( sourceDoc.getLength(), chunk.getData().toString()+"\n",
if (chunk.getData() instanceof SQLRelationship) { if ( objectCount > 0 ) sourceDoc.insertString(sourceDoc.getLength(), "\n", styles.get(chunk.getType())); SQLRelationship rel = (SQLRelationship) chunk .getData(); sourceDoc.insertString(sourceDoc.getLength(), chunk .getData().toString() + "\n " + rel.getFkTable().getName() + "(" + rel.printKeyColumns(rel.FKCOLUMN) + ")\n refers to " + rel.getPkTable().getName() + "(" + rel.printKeyColumns(rel.PKCOLUMN) + ")", styles.get(chunk.getType())); } else if (chunk.getData() instanceof SQLColumn) { sourceDoc.insertString(sourceDoc.getLength(), " " + chunk.getData().toString(), styles .get(chunk.getType())); } else { if ( objectCount > 0 ) sourceDoc.insertString(sourceDoc.getLength(), "\n", styles.get(chunk.getType())); sourceDoc.insertString(sourceDoc.getLength(), chunk .getData().toString(), styles.get(chunk .getType())); } sourceDoc.insertString(sourceDoc.getLength(), "\n",
public void actionPerformed(ActionEvent e) { startCompareAction.setEnabled(false); CompareDMFrame cf = null; try { SQLObject left = source.getObjectToCompare(); if (left.getChildType() == SQLTable.class) { sourceTables = left.getChildren(); } else { sourceTables = new ArrayList(); } SQLObject right = target.getObjectToCompare(); if (right.getChildType() == SQLTable.class) { targetTables = right.getChildren(); } else { targetTables = new ArrayList(); } // XXX: should do most or all of this work in a worker thread Map<DiffType, AttributeSet> styles = new HashMap<DiffType, AttributeSet>(); { SimpleAttributeSet att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.green); styles.put(DiffType.LEFTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.red); styles.put(DiffType.RIGHTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.black); styles.put(DiffType.SAME, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.orange); styles.put(DiffType.MODIFIED, att); } CompareSQL sourceComp = new CompareSQL(sourceTables, targetTables); List<DiffChunk<SQLObject>> diff = sourceComp.generateTableDiffs(); CompareSQL targetComp = new CompareSQL(targetTables, sourceTables); List<DiffChunk<SQLObject>> diff1 = targetComp.generateTableDiffs(); DefaultStyledDocument sourceDoc = new DefaultStyledDocument(); DefaultStyledDocument targetDoc = new DefaultStyledDocument(); if (sqlButton.isSelected()) { throw new UnsupportedOperationException( "We don't support DDL generation yet"); } else if (englishButton.isSelected()) { for (DiffChunk<SQLObject> chunk : diff) { sourceDoc.insertString( sourceDoc.getLength(), chunk.getData().toString()+"\n", styles.get(chunk.getType())); } for (DiffChunk<SQLObject> chunk1 : diff1) { targetDoc.insertString( targetDoc.getLength(), chunk1.getData().toString()+"\n", styles.get(chunk1.getType())); } } else { throw new IllegalStateException( "Don't know what type of output to make"); } // get the title string for the compareDMFrame String compMethod = null; if (sqlButton.isSelected()) { compMethod = "SQL"; } else { compMethod = OUTPUT_ENGLISH; } String titleString = "Comparing " +left.getName() + " to " + right.getName() + " using " + compMethod; cf = new CompareDMFrame( sourceDoc, targetDoc, titleString, source.getDatabase()); cf.pack(); cf.setVisible(true); } catch (ArchitectDiffException ex) { JOptionPane.showMessageDialog( CompareDMPanel.this, "Could not perform the diff:\n"+ex.getMessage(), "Diff Error", JOptionPane.ERROR_MESSAGE); logger.error("Couldn't do diff", ex); } catch (ArchitectException exp) { ASUtils.showExceptionDialog( "StartCompareAction failed", exp); logger.error("StartCompareAction failed", exp); } catch (FileNotFoundException ex) { ASUtils.showExceptionDialog("Your file could not be found.", ex); logger.error("File could not be found.", ex); } catch (IOException ex) { ASUtils.showExceptionDialog("Could not read file", ex); logger.error("Could not read file", ex); } catch (BadLocationException ex) { ASUtils.showExceptionDialog("Could not create document for results", ex); logger.error("Could not create document for results", ex); } catch (Exception ex) { ASUtils.showExceptionDialog("Unxepected Exception!", ex); logger.error("Unxepected Exception!", ex); } finally { this.setEnabled(isStartable()); } }
targetDoc.insertString( targetDoc.getLength(), chunk1.getData().toString()+"\n",
if (chunk1.getData() instanceof SQLRelationship) { if ( objectCount > 0 ) targetDoc.insertString(targetDoc.getLength(), "\n", styles.get(chunk1.getType())); SQLRelationship rel = (SQLRelationship) chunk1 .getData(); targetDoc.insertString(targetDoc.getLength(), chunk1 .getData().toString() + "\n " + rel.getFkTable().getName() + "(" + rel.printKeyColumns(rel.FKCOLUMN) + ")\n refers to " + rel.getPkTable().getName() + "(" + rel.printKeyColumns(rel.PKCOLUMN) + ")", styles.get(chunk1.getType())); } else if (chunk1.getData() instanceof SQLColumn) { targetDoc.insertString(targetDoc.getLength(), " " + chunk1.getData().toString(), styles .get(chunk1.getType())); } else { if ( objectCount > 0 ) targetDoc.insertString(targetDoc.getLength(), "\n", styles.get(chunk1.getType())); targetDoc.insertString(targetDoc.getLength(), chunk1 .getData().toString(), styles.get(chunk1 .getType())); } targetDoc.insertString(targetDoc.getLength(), "\n",
public void actionPerformed(ActionEvent e) { startCompareAction.setEnabled(false); CompareDMFrame cf = null; try { SQLObject left = source.getObjectToCompare(); if (left.getChildType() == SQLTable.class) { sourceTables = left.getChildren(); } else { sourceTables = new ArrayList(); } SQLObject right = target.getObjectToCompare(); if (right.getChildType() == SQLTable.class) { targetTables = right.getChildren(); } else { targetTables = new ArrayList(); } // XXX: should do most or all of this work in a worker thread Map<DiffType, AttributeSet> styles = new HashMap<DiffType, AttributeSet>(); { SimpleAttributeSet att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.green); styles.put(DiffType.LEFTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.red); styles.put(DiffType.RIGHTONLY, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.black); styles.put(DiffType.SAME, att); att = new SimpleAttributeSet(); StyleConstants.setForeground(att, Color.orange); styles.put(DiffType.MODIFIED, att); } CompareSQL sourceComp = new CompareSQL(sourceTables, targetTables); List<DiffChunk<SQLObject>> diff = sourceComp.generateTableDiffs(); CompareSQL targetComp = new CompareSQL(targetTables, sourceTables); List<DiffChunk<SQLObject>> diff1 = targetComp.generateTableDiffs(); DefaultStyledDocument sourceDoc = new DefaultStyledDocument(); DefaultStyledDocument targetDoc = new DefaultStyledDocument(); if (sqlButton.isSelected()) { throw new UnsupportedOperationException( "We don't support DDL generation yet"); } else if (englishButton.isSelected()) { for (DiffChunk<SQLObject> chunk : diff) { sourceDoc.insertString( sourceDoc.getLength(), chunk.getData().toString()+"\n", styles.get(chunk.getType())); } for (DiffChunk<SQLObject> chunk1 : diff1) { targetDoc.insertString( targetDoc.getLength(), chunk1.getData().toString()+"\n", styles.get(chunk1.getType())); } } else { throw new IllegalStateException( "Don't know what type of output to make"); } // get the title string for the compareDMFrame String compMethod = null; if (sqlButton.isSelected()) { compMethod = "SQL"; } else { compMethod = OUTPUT_ENGLISH; } String titleString = "Comparing " +left.getName() + " to " + right.getName() + " using " + compMethod; cf = new CompareDMFrame( sourceDoc, targetDoc, titleString, source.getDatabase()); cf.pack(); cf.setVisible(true); } catch (ArchitectDiffException ex) { JOptionPane.showMessageDialog( CompareDMPanel.this, "Could not perform the diff:\n"+ex.getMessage(), "Diff Error", JOptionPane.ERROR_MESSAGE); logger.error("Couldn't do diff", ex); } catch (ArchitectException exp) { ASUtils.showExceptionDialog( "StartCompareAction failed", exp); logger.error("StartCompareAction failed", exp); } catch (FileNotFoundException ex) { ASUtils.showExceptionDialog("Your file could not be found.", ex); logger.error("File could not be found.", ex); } catch (IOException ex) { ASUtils.showExceptionDialog("Could not read file", ex); logger.error("Could not read file", ex); } catch (BadLocationException ex) { ASUtils.showExceptionDialog("Could not create document for results", ex); logger.error("Could not create document for results", ex); } catch (Exception ex) { ASUtils.showExceptionDialog("Unxepected Exception!", ex); logger.error("Unxepected Exception!", ex); } finally { this.setEnabled(isStartable()); } }
ApplicationConfigManager.checkAppNameAlreadyPresent(data.getName());
public ApplicationConfigData addApplication(ServiceContext context, ApplicationConfigData data){ AccessController.checkAccess(context, ACLConstants.ACL_ADD_APPLICATIONS); /* do the operation */ String appId = ApplicationConfig.getNextApplicationId(); Integer port = data.getPort(); ApplicationConfig config = ApplicationConfigFactory.create(appId, data.getName(), data.getType(), data.getHost(), port, data.getURL(), data.getUsername(), data.getPassword(), null); ApplicationConfigManager.addApplication(config); data.setApplicationId(appId); /* log the operation */ UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application "+ "\""+config.getName()+"\""); return data; }
getBody().run(context, output);
invokeBody(output);
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } getBody().run(context, output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } } }
PhotoCollectionTransferHandler.setLastImportTarget( folder );
public void drop(DropTargetDropEvent e) { hoverTimer.stop(); // Prevent hover timer from doing an unwanted expandPath or collapsePath if (!isDropAcceptable(e)) { e.rejectDrop(); return; } e.acceptDrop(e.getDropAction()); Transferable transferable = e.getTransferable(); DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++ ) { DataFlavor flavor = flavors[i]; if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) { try { Point pt = e.getLocation(); TreePath pathTarget = tree.getClosestPathForLocation(pt.x, pt.y); PhotoFolder folder = (PhotoFolder) pathTarget.getLastPathComponent(); PhotoInfo[] photos = (PhotoInfo[])transferable.getTransferData(photoInfoFlavor); for ( int n = 0; n < photos.length; n++ ) { folder.addPhoto( photos[n] ); } break; // No need to check remaining flavors } catch (UnsupportedFlavorException ufe) { System.out.println(ufe); e.dropComplete(false); return; } catch (IOException ioe) { System.out.println(ioe); e.dropComplete(false); return; } } } e.dropComplete(true); }
System.out.println(first + " " + last + " " + numStrong);
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; numInGroup = 0; } return stringVec2intVec(blocks); }
numStrong = 0; numRec = 0; numInGroup = 0;
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; numInGroup = 0; } return stringVec2intVec(blocks); }
ODMG.initODMG( "harri", "", db );
try { ODMG.initODMG( "harri", "", db ); } catch (PhotovaultException ex) { fail( ex.getMessage() ); }
public void testCreateDB() { File confFile = null; File dbDir = null; // Create an empty configuration file & volume directory try { confFile = File.createTempFile( "photovault_settings_", ".xml" ); confFile.delete(); dbDir = File.createTempFile( "photovault_test_volume", "" ); dbDir.delete(); dbDir.mkdir(); } catch (IOException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } System.setProperty( "photovault.configfile", confFile.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = new PVDatabase(); db.setInstanceType( PVDatabase.TYPE_EMBEDDED ); db.setEmbeddedDirectory( dbDir );// Volume vol = new Volume( "testvolume", dbDir.getAbsolutePath() );// db.addVolume( vol ); settings.addDatabase( db ); settings.saveConfig(); db.createDatabase( "harri", "" ); // Verify that the database can be used by importing a file ODMG.initODMG( "harri", "", db ); File photoFile = new File( "testfiles/test1.jpg" ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB(photoFile); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } photo.setPhotographer( "test" ); try { PhotoInfo photo2 = PhotoInfo.retrievePhotoInfo( photo.getUid() ); Thumbnail thumb = photo2.getThumbnail(); this.assertFalse( "Default thumbnail returned", thumb == Thumbnail.getDefaultThumbnail() ); } catch (PhotoNotFoundException ex) { fail( "Photo not found in database" ); } }
jPanel1 = new javax.swing.JPanel();
splashPane = new javax.swing.JPanel();
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
org.jdesktop.layout.GroupLayout splashPaneLayout = new org.jdesktop.layout.GroupLayout(splashPane); splashPane.setLayout(splashPaneLayout); splashPaneLayout.setHorizontalGroup( splashPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
splashPaneLayout.setVerticalGroup( splashPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
copyrightPane.addTab("Photovault", jPanel1);
copyrightPane.addTab("Photovault", splashPane);
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
.addContainerGap(260, Short.MAX_VALUE))
.addContainerGap(231, Short.MAX_VALUE))
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
.addContainerGap(162, Short.MAX_VALUE))
.addContainerGap(157, Short.MAX_VALUE))
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
private void initComponents() { copyrightPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); splashLabel = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); svnrevLabel = new javax.swing.JLabel(); svnbranchLabel = new javax.swing.JLabel(); buildTimeLabel = new javax.swing.JLabel(); builderLabel = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); copyrightTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Photovault"); setResizable(false); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); copyrightPane.setOpaque(true); copyrightPane.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { copyrightPaneAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); splashLabel.setText("jLabel1"); splashLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Photovault", jPanel1); jLabel1.setText("Version:"); jLabel2.setText("SVN revision:"); jLabel3.setText("SVN branch:"); jLabel4.setText("Build time:"); jLabel5.setText("Built by:"); versionLabel.setText("jLabel6"); svnrevLabel.setText("jLabel6"); svnbranchLabel.setText("jLabel6"); buildTimeLabel.setText("jLabel6"); builderLabel.setText("jLabel6"); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(37, 37, 37) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel5) .add(jLabel4) .add(jLabel3) .add(jLabel2) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(versionLabel) .add(svnrevLabel) .add(svnbranchLabel) .add(buildTimeLabel) .add(builderLabel)) .addContainerGap(260, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(versionLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(svnrevLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3) .add(svnbranchLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(buildTimeLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5) .add(builderLabel)) .addContainerGap(162, Short.MAX_VALUE)) ); copyrightPane.addTab("Version info", jPanel2); copyrightTextPane.setEditable(false); jScrollPane1.setViewportView(copyrightTextPane); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) ); copyrightPane.addTab("Copyright", jPanel3); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(copyrightPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents
versionLabel.setText( prop.getProperty( "build.version", "unknown" ) );
String version = prop.getProperty( "build.version", "unknown" ); String versionTag = prop.getProperty( "build.version_tag", "unknown" ); versionLabel.setText( version + " (" + versionTag + ")" );
void setupInfo() { URL buildPropertyURL = AboutDlg.class.getClassLoader().getResource( "buildinfo.properties"); Properties prop = new Properties(); try { InputStream is = buildPropertyURL.openStream(); prop.load( is ); } catch (IOException e ) { // Cannot read the properties for some reason. // Do nothing, use the default values instead. } svnrevLabel.setText( prop.getProperty( "svn.revision", "unknown" ) ); svnbranchLabel.setText( prop.getProperty( "svn.info.url", "unknown" ) ); buildTimeLabel.setText( prop.getProperty( "build.time", "unknown" ) ); builderLabel.setText( prop.getProperty( "build.user", "unknown" ) ); versionLabel.setText( prop.getProperty( "build.version", "unknown" ) ); builderLabel.setText( prop.getProperty( "build.user", "unknown" ) ); // Set up the splash screen image URL splashImageURL = AboutDlg.class.getClassLoader().getResource( "splash.jpg" ); Icon splash = new ImageIcon( splashImageURL ); splashLabel.setIcon( splash ); splashLabel.setText( null ); // Set the copyright text URL copyrightTextURL = AboutDlg.class.getClassLoader().getResource( "copyright.html" ); try { copyrightTextPane.setPage( copyrightTextURL ); } catch ( IOException e ) {} }
table1.changeColumnIndex(table1.getColumnIndex(c1), 2);
table1.changeColumnIndex(table1.getColumnIndex(c1), 2, false);
public void testFireDbChildrenInserted() throws Exception { SQLTable table1 = db.getTableByName("REGRESSION_TEST1"); SQLColumn c1 = table1.getColumn(0); Folder folder = table1.getColumnsFolder(); TestSQLObjectListener test1 = new TestSQLObjectListener(); folder.addSQLObjectListener(test1); TestSQLObjectListener test2 = new TestSQLObjectListener(); folder.addSQLObjectListener(test2); assertEquals(test1.getInsertedCount(), 0); assertEquals(test1.getRemovedCount(), 0); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 0); assertEquals(test2.getRemovedCount(), 0); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); SQLColumn tmpCol = new SQLColumn(); table1.addColumn(tmpCol); table1.changeColumnIndex(table1.getColumnIndex(c1), 2); assertEquals(test1.getInsertedCount(), 2); assertEquals(test1.getRemovedCount(), 1); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 2); assertEquals(test2.getRemovedCount(), 1); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); folder.removeSQLObjectListener(test1); table1.changeColumnIndex(table1.getColumnIndex(c1), 1); assertEquals(test1.getInsertedCount(), 2); assertEquals(test1.getRemovedCount(), 1); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 3); assertEquals(test2.getRemovedCount(), 2); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); table1.removeColumn(tmpCol); assertEquals(test2.getInsertedCount(), 3); assertEquals(test2.getRemovedCount(), 3); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); }
table1.changeColumnIndex(table1.getColumnIndex(c1), 1);
table1.changeColumnIndex(table1.getColumnIndex(c1), 1, false);
public void testFireDbChildrenInserted() throws Exception { SQLTable table1 = db.getTableByName("REGRESSION_TEST1"); SQLColumn c1 = table1.getColumn(0); Folder folder = table1.getColumnsFolder(); TestSQLObjectListener test1 = new TestSQLObjectListener(); folder.addSQLObjectListener(test1); TestSQLObjectListener test2 = new TestSQLObjectListener(); folder.addSQLObjectListener(test2); assertEquals(test1.getInsertedCount(), 0); assertEquals(test1.getRemovedCount(), 0); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 0); assertEquals(test2.getRemovedCount(), 0); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); SQLColumn tmpCol = new SQLColumn(); table1.addColumn(tmpCol); table1.changeColumnIndex(table1.getColumnIndex(c1), 2); assertEquals(test1.getInsertedCount(), 2); assertEquals(test1.getRemovedCount(), 1); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 2); assertEquals(test2.getRemovedCount(), 1); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); folder.removeSQLObjectListener(test1); table1.changeColumnIndex(table1.getColumnIndex(c1), 1); assertEquals(test1.getInsertedCount(), 2); assertEquals(test1.getRemovedCount(), 1); assertEquals(test1.getChangedCount(), 0); assertEquals(test1.getStructureChangedCount(), 0); assertEquals(test2.getInsertedCount(), 3); assertEquals(test2.getRemovedCount(), 2); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); table1.removeColumn(tmpCol); assertEquals(test2.getInsertedCount(), 3); assertEquals(test2.getRemovedCount(), 3); assertEquals(test2.getChangedCount(), 0); assertEquals(test2.getStructureChangedCount(), 0); }
for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).removeSQLObjectListener(tableListModel);
for (int i = 0; i < model.getColumnsFolder().getChildCount(); i++) { model.getColumnsFolder().getChild(i).removeSQLObjectListener(tableListModel);
protected void cleanup() { try { for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).removeSQLObjectListener(tableListModel); } } catch (ArchitectException e) { logger.error("Caught exception removing treemodel from column listener list"); } model.removeSQLObjectListener(tableListModel); }
model.removeSQLObjectListener(tableListModel);
model.getColumnsFolder().removeSQLObjectListener(tableListModel);
protected void cleanup() { try { for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).removeSQLObjectListener(tableListModel); } } catch (ArchitectException e) { logger.error("Caught exception removing treemodel from column listener list"); } model.removeSQLObjectListener(tableListModel); }
boolean addToPK = false; int pkSize = getPkSize(); if (getColumns().size() > 0 && pos < pkSize) { addToPK = true; normalizePrimaryKey(); for (int i = pos; i < pkSize; i++) { ((SQLColumn) getColumns().get(i)).primaryKeySeq = new Integer(i + 1); } } col.setParent(null); if (addToPK) { col.nullable = DatabaseMetaData.columnNoNulls; col.primaryKeySeq = new Integer(pos); } else { col.primaryKeySeq = null;
if (isMagicEnabled()) { boolean addToPK = false; int pkSize = getPkSize(); if (getColumns().size() > 0 && pos < pkSize) { addToPK = true; normalizePrimaryKey(); for (int i = pos; i < pkSize; i++) { ((SQLColumn) getColumns().get(i)).primaryKeySeq = new Integer(i + 1); } } col.setParent(null); if (addToPK) { col.nullable = DatabaseMetaData.columnNoNulls; col.primaryKeySeq = new Integer(pos); } else { col.primaryKeySeq = null; }
private void addColumnImpl(int pos, SQLColumn col) throws ArchitectException { if (getColumnIndex(col) != -1) { col.addReference(); return; } boolean addToPK = false; int pkSize = getPkSize(); if (getColumns().size() > 0 && pos < pkSize) { addToPK = true; normalizePrimaryKey(); for (int i = pos; i < pkSize; i++) { ((SQLColumn) getColumns().get(i)).primaryKeySeq = new Integer(i + 1); } } col.setParent(null); if (addToPK) { col.nullable = DatabaseMetaData.columnNoNulls; col.primaryKeySeq = new Integer(pos); } else { col.primaryKeySeq = null; } columnsFolder.addChild(pos, col); }
SQLColumn col = (SQLColumn) columnsFolder.children.remove(oldIdx); columnsFolder.fireDbChildRemoved(oldIdx, col); columnsFolder.children.add(newIdx, col); if (putInPK) { col.primaryKeySeq = new Integer(1); } else { col.primaryKeySeq = null; } normalizePrimaryKey(); columnsFolder.fireDbChildInserted(newIdx, col);
try { startCompoundEdit("Changing column index"); SQLColumn col = (SQLColumn) columnsFolder.children.get(oldIdx); Integer oldPkSeq = col.primaryKeySeq; Integer interimPkSeq; if (putInPK) { interimPkSeq = new Integer(1); } else { interimPkSeq = null; } col.primaryKeySeq = interimPkSeq; col.fireDbObjectChanged("primaryKeySeq", oldPkSeq, interimPkSeq); columnsFolder.children.remove(oldIdx); columnsFolder.fireDbChildRemoved(oldIdx, col); columnsFolder.children.add(newIdx, col); columnsFolder.fireDbChildInserted(newIdx, col); normalizePrimaryKey(); } finally { endCompoundEdit("Changing column index"); }
public void changeColumnIndex(int oldIdx, int newIdx, boolean putInPK) throws ArchitectException { // remove and add the column directly, then manually fire the event. // This is necessary because the relationships prevent deletion of locked keys. SQLColumn col = (SQLColumn) columnsFolder.children.remove(oldIdx); columnsFolder.fireDbChildRemoved(oldIdx, col); columnsFolder.children.add(newIdx, col); if (putInPK) { col.primaryKeySeq = new Integer(1); // will get sane value when normalized } else { col.primaryKeySeq = null; } normalizePrimaryKey(); columnsFolder.fireDbChildInserted(newIdx, col); }
String oldName = getName(); try { startCompoundEdit("Table Name Change"); super.setName(argName); if (primaryKeyName == null || primaryKeyName.equals("") || primaryKeyName.equals(oldName+"_pk")) { setPrimaryKeyName( getName()+"_pk"); } } finally { endCompoundEdit("Ending table name compound edit"); }
if (!isMagicEnabled()) { super.setName(argName); } else try { String oldName = getName(); startCompoundEdit("Table Name Change"); super.setName(argName); if (primaryKeyName == null || primaryKeyName.equals("") || primaryKeyName.equals(oldName+"_pk")) { setPrimaryKeyName( getName()+"_pk"); } } finally { endCompoundEdit("Ending table name compound edit"); }
public void setName(String argName) { String oldName = getName(); try { startCompoundEdit("Table Name Change"); super.setName(argName); if (primaryKeyName == null || primaryKeyName.equals("") || primaryKeyName.equals(oldName+"_pk")) { setPrimaryKeyName( getName()+"_pk"); } } finally { endCompoundEdit("Ending table name compound edit"); } }
if (l == null) throw new NullPointerException("You can't add a null listener");
public void addSQLObjectListener(SQLObjectListener l) { if (getSQLObjectListeners().contains(l)) { if (logger.isDebugEnabled()) { logger.debug("NOT Adding duplicate listener "+l+" to SQLObject "+this); } return; } getSQLObjectListeners().add(l); }
for(Enumeration enum=request.getAttributeNames(); enum.hasMoreElements();){ String attribute = (String)enum.nextElement();
for(Enumeration en=request.getAttributeNames(); en.hasMoreElements();){ String attribute = (String)en.nextElement();
private ActionForward handleDebugMode(HttpServletRequest request, HttpServletResponse response, ActionForward resultForward) throws IOException { if("true".equals(request.getParameter("debug.xml"))){ response.setContentType("text/xml"); XMLEncoder encoder = new XMLEncoder(response.getOutputStream()); for(Enumeration enum=request.getAttributeNames(); enum.hasMoreElements();){ String attribute = (String)enum.nextElement(); Object attrValue = request.getAttribute(attribute); encoder.writeObject(attribute); encoder.writeObject(attrValue); } encoder.writeObject(request); encoder.close(); resultForward = null; }
return resultForward; }
private ActionForward handleDebugMode(HttpServletRequest request, HttpServletResponse response, ActionForward resultForward) throws IOException { if("true".equals(request.getParameter("debug.xml"))){ response.setContentType("text/xml"); XMLEncoder encoder = new XMLEncoder(response.getOutputStream()); for(Enumeration enum=request.getAttributeNames(); enum.hasMoreElements();){ String attribute = (String)enum.nextElement(); Object attrValue = request.getAttribute(attribute); encoder.writeObject(attribute); encoder.writeObject(attrValue); } encoder.writeObject(request); encoder.close(); resultForward = null; }
try { Collection selectedPhotos = view.getSelection(); if ( selectedPhotos.size() > 1 ) { int n = JOptionPane.showConfirmDialog( parentFrame, "You have selected " + selectedPhotos.size() + " photos\n" + "Are you sure that you want to\ndisplay all of them at once?", "Open multiple photos", JOptionPane.YES_NO_OPTION ); if ( n != JOptionPane.YES_OPTION ) { return;
Collection selectedPhotos = view.getSelection(); if ( selectedPhotos.size() > 1 ) { int n = JOptionPane.showConfirmDialog( parentFrame, "You have selected " + selectedPhotos.size() + " photos\n" + "Are you sure that you want to\ndisplay all of them at once?", "Open multiple photos", JOptionPane.YES_NO_OPTION ); if ( n != JOptionPane.YES_OPTION ) { return; } } Cursor oldCursor = c.getCursor(); c.setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Iterator iter = selectedPhotos.iterator(); JAIPhotoViewer viewer = null; while ( iter.hasNext() ) { try { viewer = null; PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); final JAIPhotoViewer pv = viewer; frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { pv.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } catch ( Throwable e ) { log.warn( "Error while trying to show a photo: " + e ); e.printStackTrace(); if ( viewer != null ) { viewer.setPhoto( null );
public void actionPerformed( ActionEvent ev ) { Frame parentFrame = null; Container c = view.getTopLevelAncestor(); if ( c instanceof Frame ) { parentFrame = (Frame) c; } try { Collection selectedPhotos = view.getSelection(); if ( selectedPhotos.size() > 1 ) { // If user wants to open many photos at once ask for confirmation // Try to find the frame in which this component is in int n = JOptionPane.showConfirmDialog( parentFrame, "You have selected " + selectedPhotos.size() + " photos\n" + "Are you sure that you want to\ndisplay all of them at once?", "Open multiple photos", JOptionPane.YES_NO_OPTION ); if ( n != JOptionPane.YES_OPTION ) { return; } } Cursor oldCursor = c.getCursor(); c.setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Iterator iter = selectedPhotos.iterator(); while ( iter.hasNext() ) { PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); final JAIPhotoViewer viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); // This is a WAR for a memory management problem. For // some reason the frame and objects owned by it seem // not to be garbage collected. So we free the large // image buffers to avoid massive memory leak. frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } c.setCursor( oldCursor ); } catch ( Throwable e ) { System.err.println( "Out of memory error" ); log.warn( e ); e.printStackTrace(); } }
Cursor oldCursor = c.getCursor(); c.setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Iterator iter = selectedPhotos.iterator(); while ( iter.hasNext() ) { PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); final JAIPhotoViewer viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } c.setCursor( oldCursor ); } catch ( Throwable e ) { System.err.println( "Out of memory error" ); log.warn( e ); e.printStackTrace(); }
c.setCursor( oldCursor );
public void actionPerformed( ActionEvent ev ) { Frame parentFrame = null; Container c = view.getTopLevelAncestor(); if ( c instanceof Frame ) { parentFrame = (Frame) c; } try { Collection selectedPhotos = view.getSelection(); if ( selectedPhotos.size() > 1 ) { // If user wants to open many photos at once ask for confirmation // Try to find the frame in which this component is in int n = JOptionPane.showConfirmDialog( parentFrame, "You have selected " + selectedPhotos.size() + " photos\n" + "Are you sure that you want to\ndisplay all of them at once?", "Open multiple photos", JOptionPane.YES_NO_OPTION ); if ( n != JOptionPane.YES_OPTION ) { return; } } Cursor oldCursor = c.getCursor(); c.setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Iterator iter = selectedPhotos.iterator(); while ( iter.hasNext() ) { PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); final JAIPhotoViewer viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); // This is a WAR for a memory management problem. For // some reason the frame and objects owned by it seem // not to be garbage collected. So we free the large // image buffers to avoid massive memory leak. frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } c.setCursor( oldCursor ); } catch ( Throwable e ) { System.err.println( "Out of memory error" ); log.warn( e ); e.printStackTrace(); } }
viewer.setPhoto( null ); }
pv.setPhoto( null ); }
public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); }
headingJLabel.setBackground(new Color(117, 138, 155));
headingJLabel.setBackground(new Color(117, 138, 155, 255));
void addHeading(final String headingText) { if(null == headingJLabel) { headingJLabel = LabelFactory.create(headingText, UIConstants.DefaultFontBold); headingJLabel.setBackground(new Color(117, 138, 155)); headingJLabel.setForeground(Color.WHITE); headingJLabel.setIcon(getHeadingIcon()); headingJLabel.setOpaque(true); } // h: 24 px // x indent: 29 px final GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.gridx = 0; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; avatar.add(headingJLabel, c.clone()); }
private Fixture(final ArtifactModel aModel, final JabberId closedBy,
private Fixture(final ContainerModel cModel, final JabberId closedBy,
private Fixture(final ArtifactModel aModel, final JabberId closedBy, final Calendar closedOn, final InternalContainerModel cInternalModel, final Long containerId, final Integer eTeamSize) { this.aModel = aModel; this.closedBy = closedBy; this.closedOn = closedOn; this.cInternalModel = cInternalModel; this.containerId = containerId; this.eTeamSize = eTeamSize; }
this.aModel = aModel;
this.cModel = cModel;
private Fixture(final ArtifactModel aModel, final JabberId closedBy, final Calendar closedOn, final InternalContainerModel cInternalModel, final Long containerId, final Integer eTeamSize) { this.aModel = aModel; this.closedBy = closedBy; this.closedOn = closedOn; this.cInternalModel = cInternalModel; this.containerId = containerId; this.eTeamSize = eTeamSize; }
datum = new Fixture(aModel, jUnitX.getJabberId(), currentDateTime(),
datum = new Fixture(cModel, jUnitX.getJabberId(), currentDateTime(),
protected void setUp() throws Exception { super.setUp(); login(); final ContainerModel cModel = getContainerModel(); final ArtifactModel aModel = getArtifactModel(); final ModelTestUser jUnitX = ModelTestUser.getX(); final Container container = createContainer(NAME); final Document document = addDocument(container, getInputFiles()[0]); addTeam(container); modifyDocument(document); cModel.publish(container.getId()); aModel.sendKey(container.getId(), jUnitX.getJabberId()); datum = new Fixture(aModel, jUnitX.getJabberId(), currentDateTime(), getInternalContainerModel(), container.getId(), aModel.readTeam(container.getId()).size()); }
aModel.readTeam(container.getId()).size());
cModel.readTeam(container.getId()).size());
protected void setUp() throws Exception { super.setUp(); login(); final ContainerModel cModel = getContainerModel(); final ArtifactModel aModel = getArtifactModel(); final ModelTestUser jUnitX = ModelTestUser.getX(); final Container container = createContainer(NAME); final Document document = addDocument(container, getInputFiles()[0]); addTeam(container); modifyDocument(document); cModel.publish(container.getId()); aModel.sendKey(container.getId(), jUnitX.getJabberId()); datum = new Fixture(aModel, jUnitX.getJabberId(), currentDateTime(), getInternalContainerModel(), container.getId(), aModel.readTeam(container.getId()).size()); }
Set<User> team;
List<User> team;
public void testHandleClose() { Set<User> team; try { datum.cInternalModel.handleClose(datum.containerId, datum.closedBy, datum.closedOn); } catch(final ParityException px) { fail(createFailMessage(px)); } final Container container = datum.cInternalModel.read(datum.containerId); assertNotNull(NAME, container); assertEquals(NAME + " [CONTAINER STATE DOES NOT MATCH EXPECTATION]", container.getState(), ArtifactState.CLOSED); team = datum.aModel.readTeam(datum.containerId); assertNotNull(NAME, team); assertEquals(NAME + " [TEAM SIZE DOES NOT MATCH EXPECTATION]", datum.eTeamSize.intValue(), team.size()); }