rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
int colNo = table.convertColumnIndexToModel(i); column = table.getColumnModel().getColumn(colNo); | column = table.getColumnModel().getColumn(i); | public void initColumnSizes(JTable table) { AbstractTableModel model = (AbstractTableModel)table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); for (int i = 0; i < model.getColumnCount(); i++) { int colNo = table.convertColumnIndexToModel(i); column = table.getColumnModel().getColumn(colNo); cellWidth = 0; comp = headerRenderer.getTableCellRendererComponent( null, column.getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; for (int j = 0; j < table.getRowCount(); j++) { comp = table.getDefaultRenderer(model.getColumnClass(colNo)). getTableCellRendererComponent( table, table.getValueAt(j,colNo), false, false, j, colNo); cellWidth = Math.max(cellWidth, comp.getPreferredSize().width); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } |
null, column.getHeaderValue(), | table, column.getHeaderValue(), | public void initColumnSizes(JTable table) { AbstractTableModel model = (AbstractTableModel)table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); for (int i = 0; i < model.getColumnCount(); i++) { int colNo = table.convertColumnIndexToModel(i); column = table.getColumnModel().getColumn(colNo); cellWidth = 0; comp = headerRenderer.getTableCellRendererComponent( null, column.getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; for (int j = 0; j < table.getRowCount(); j++) { comp = table.getDefaultRenderer(model.getColumnClass(colNo)). getTableCellRendererComponent( table, table.getValueAt(j,colNo), false, false, j, colNo); cellWidth = Math.max(cellWidth, comp.getPreferredSize().width); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } |
comp = table.getDefaultRenderer(model.getColumnClass(colNo)). | comp = table.getDefaultRenderer(model.getColumnClass(i)). | public void initColumnSizes(JTable table) { AbstractTableModel model = (AbstractTableModel)table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); for (int i = 0; i < model.getColumnCount(); i++) { int colNo = table.convertColumnIndexToModel(i); column = table.getColumnModel().getColumn(colNo); cellWidth = 0; comp = headerRenderer.getTableCellRendererComponent( null, column.getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; for (int j = 0; j < table.getRowCount(); j++) { comp = table.getDefaultRenderer(model.getColumnClass(colNo)). getTableCellRendererComponent( table, table.getValueAt(j,colNo), false, false, j, colNo); cellWidth = Math.max(cellWidth, comp.getPreferredSize().width); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } |
table, table.getValueAt(j,colNo), false, false, j, colNo); | table, table.getValueAt(j,i), false, false, j, i); | public void initColumnSizes(JTable table) { AbstractTableModel model = (AbstractTableModel)table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); for (int i = 0; i < model.getColumnCount(); i++) { int colNo = table.convertColumnIndexToModel(i); column = table.getColumnModel().getColumn(colNo); cellWidth = 0; comp = headerRenderer.getTableCellRendererComponent( null, column.getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; for (int j = 0; j < table.getRowCount(); j++) { comp = table.getDefaultRenderer(model.getColumnClass(colNo)). getTableCellRendererComponent( table, table.getValueAt(j,colNo), false, false, j, colNo); cellWidth = Math.max(cellWidth, comp.getPreferredSize().width); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } |
this.pm = pm; | public ProfilePanel(ProfileManager pm) { this.pm = pm; displayPanel = new ProfileGraphPanel(this, 0,pm); setup(); } |
|
public void linkageToChrom(boolean[] markerResults, PedFile pedFile, String[][] hmInfo) throws IllegalArgumentException, HaploViewException, PedFileException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ if((currentFamily.getNumMembers() == 1 && assocTest == 0) || assocTest == 2){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1,currentInd.getAffectedStatus()==2)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus()==2)); numSingletons++; }else{ if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0")) && (currentInd.getAffectedStatus() == 2 || assocTest == 0)){ numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { if (dad1 == 0 && mom1 == 0) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), dadTb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), dadUb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), momTb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), momUb,currentInd.getAffectedStatus()==2,kidMissing)); numTrios++; } } } } int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0,hmInfo); }catch(HaploViewException e){ }catch(IOException e){ } | public void linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ this.linkageToChrom(infile, type, false); | public void linkageToChrom(boolean[] markerResults, PedFile pedFile, String[][] hmInfo) throws IllegalArgumentException, HaploViewException, PedFileException{ if(markerResults == null){ throw new IllegalArgumentException(); } Vector indList = pedFile.getOrder(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); for(int x=0; x < indList.size(); x++){ String[] indAndFamID = (String[])indList.elementAt(x); currentFamily = pedFile.getFamily(indAndFamID[0]); currentInd = currentFamily.getMember(indAndFamID[1]); if(currentInd.getIsTyped()){ //singleton //if only one indiv in fam AND no assoc test OR this is case control (assocTest=2) if((currentFamily.getNumMembers() == 1 && assocTest == 0) || assocTest == 2){ numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == thisMarker[1]){ chrom1[i] = thisMarker[0]; chrom2[i] = thisMarker[1]; }else{ chrom1[i] = 5; chrom2[i] = 5; } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1,currentInd.getAffectedStatus()==2)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus()==2)); numSingletons++; }else{ //trio //if indiv has both parents AND is affected OR no assoc test if (!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0")) && (currentInd.getAffectedStatus() == 2 || assocTest == 0)){ numMarkers = currentInd.getNumMarkers(); byte[] dadTb = new byte[numMarkers]; byte[] dadUb = new byte[numMarkers]; byte[] momTb = new byte[numMarkers]; byte[] momUb = new byte[numMarkers]; boolean[] kidMissing = new boolean[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getMomID())).getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; thisMarker = (currentFamily.getMember(currentInd.getDadID())).getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; if (kid1 == 0 || kid2 == 0) { kidMissing[i] = true; //kid missing if (dad1 == dad2) { dadTb[i] = dad1; dadUb[i] = dad1; } else { dadTb[i] = 5; dadUb[i] = 5; } if (mom1 == mom2) { momTb[i] = mom1; momUb[i] = mom1; } else { momTb[i] = 5; momUb[i] = 5; } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadTb[i] = kid1; dadUb[i] = 0; } else if (dad1 == kid1) { dadTb[i] = dad1; dadUb[i] = dad2; } else { dadTb[i] = dad2; dadUb[i] = dad1; } if (mom1 == 0) { momTb[i] = kid1; momUb[i] = 0; } else if (mom1 == kid1) { momTb[i] = mom1; momUb[i] = mom2; } else { momTb[i] = mom2; momUb[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadTb[i] = 0; dadUb[i] = 0; momTb[i] = 5; momUb[i] = 5; } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 0; momUb[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momTb[i] = mom1; momUb[i] = mom1; dadUb[i] = 0; if (kid1 == mom1) { dadTb[i] = kid2; } else { dadTb[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadTb[i] = dad1; dadUb[i] = dad1; momUb[i] = 0; if (kid1 == dad1) { momTb[i] = kid2; } else { momTb[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadTb[i] = dad1; dadUb[i] = dad2; if (kid1 == dad1) { momTb[i] = kid2; momUb[i] = kid1; } else { momTb[i] = kid1; momUb[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momTb[i] = mom1; momUb[i] = mom2; if (kid1 == mom1) { dadTb[i] = kid2; dadUb[i] = kid1; } else { dadTb[i] = kid1; dadUb[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadTb[i] = dad1; dadUb[i] = dad1; momTb[i] = mom1; momUb[i] = mom1; } else { //everybody het dadTb[i] = 5; dadUb[i] = 5; momTb[i] = 5; momUb[i] = 5; } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), dadTb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), dadUb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), momTb,currentInd.getAffectedStatus()==2,kidMissing)); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(), momUb,currentInd.getAffectedStatus()==2,kidMissing)); numTrios++; } } } } //set up the indexing to take into account skipped markers. Need //to loop through twice because first time we just count number of //unskipped markers int count = 0; for (int i = 0; i < numMarkers; i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < numMarkers; i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } chromosomes = chrom; try{ prepareMarkerInput(null,0,hmInfo); }catch(HaploViewException e){ }catch(IOException e){ } } |
int numGaps = filteredDPrimeTable.length; double prev = 0; for (int gap = 0; gap < numGaps; gap++){ for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (gap-x < 0 || gap+y >= numGaps){ continue; } LODSum += filteredDPrimeTable[gap-x][gap+y].getLOD(); | for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (i-x < 0 || i+y >= filteredDPrimeTable.length){ continue; | public void saveDprimeToText(File dumpDprimeFile) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\tT-int\n"); long dist; for (int i = 0; i < filteredDPrimeTable.length; i++){ for (int j = 0; j < filteredDPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ if(filteredDPrimeTable[i][j] != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //this belongs somewhere else really... //these are adjacent markers so we'll put in the t-int stat for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (i-x < 0 || i+y >= filteredDPrimeTable.length){ continue; } LODSum += filteredDPrimeTable[i-x][i+y].getLOD(); } } tInt = String.valueOf(roundDouble(LODSum)); } dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + filteredDPrimeTable[i][j].toString() + "\t" + dist + "\t" + tInt +"\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tT-int\n"); for (int i = 0; i < filteredDPrimeTable.length; i++){ for (int j = 0; j < filteredDPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ if(filteredDPrimeTable[i][j] != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //this belongs somewhere else really... //these are adjacent markers so we'll put in the t-int stat int numGaps = filteredDPrimeTable.length; double prev = 0; for (int gap = 0; gap < numGaps; gap++){ for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (gap-x < 0 || gap+y >= numGaps){ continue; } LODSum += filteredDPrimeTable[gap-x][gap+y].getLOD(); } } } tInt = String.valueOf(roundDouble(LODSum)); } saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + filteredDPrimeTable[i][j] + "\t" + tInt + "\n"); } } } } } saveDprimeWriter.close(); } |
LODSum += filteredDPrimeTable[i-x][i+y].getLOD(); | public void saveDprimeToText(File dumpDprimeFile) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); if (infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\tT-int\n"); long dist; for (int i = 0; i < filteredDPrimeTable.length; i++){ for (int j = 0; j < filteredDPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ if(filteredDPrimeTable[i][j] != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //this belongs somewhere else really... //these are adjacent markers so we'll put in the t-int stat for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (i-x < 0 || i+y >= filteredDPrimeTable.length){ continue; } LODSum += filteredDPrimeTable[i-x][i+y].getLOD(); } } tInt = String.valueOf(roundDouble(LODSum)); } dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + filteredDPrimeTable[i][j].toString() + "\t" + dist + "\t" + tInt +"\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tT-int\n"); for (int i = 0; i < filteredDPrimeTable.length; i++){ for (int j = 0; j < filteredDPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ if(filteredDPrimeTable[i][j] != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //this belongs somewhere else really... //these are adjacent markers so we'll put in the t-int stat int numGaps = filteredDPrimeTable.length; double prev = 0; for (int gap = 0; gap < numGaps; gap++){ for (int x = 0; x < 5; x++){ for (int y = 1; y < 6; y++){ if (gap-x < 0 || gap+y >= numGaps){ continue; } LODSum += filteredDPrimeTable[gap-x][gap+y].getLOD(); } } } tInt = String.valueOf(roundDouble(LODSum)); } saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + filteredDPrimeTable[i][j] + "\t" + tInt + "\n"); } } } } } saveDprimeWriter.close(); } |
|
hapMapTranslate.put("NA12003.dup", "dup NA12003.dup 0 0 1 1"); | public PedFile(){ //hardcoded hapmap info this.families = new Hashtable(); hapMapTranslate = new Hashtable(90,1); hapMapTranslate.put("NA10846", "1334 NA10846 NA12144 NA12145 1 1" ); hapMapTranslate.put("NA12144", "1334 NA12144 0 0 1 1"); hapMapTranslate.put("NA12145", "1334 NA12145 0 0 2 1"); hapMapTranslate.put("NA10847", "1334 NA10847 NA12146 NA12239 2 1" ); hapMapTranslate.put("NA12146", "1334 NA12146 0 0 1 1"); hapMapTranslate.put("NA12239", "1334 NA12239 0 0 2 1"); hapMapTranslate.put("NA07029", "1340 NA07029 NA06994 NA07000 1 1" ); hapMapTranslate.put("NA06994", "1340 NA06994 0 0 1 1"); hapMapTranslate.put("NA07000", "1340 NA07000 0 0 2 1"); hapMapTranslate.put("NA07019", "1340 NA07019 NA07022 NA07056 2 1" ); hapMapTranslate.put("NA07022", "1340 NA07022 0 0 1 1"); hapMapTranslate.put("NA07056", "1340 NA07056 0 0 2 1"); hapMapTranslate.put("NA07048", "1341 NA07048 NA07034 NA07055 1 1" ); hapMapTranslate.put("NA07034", "1341 NA07034 0 0 1 1"); hapMapTranslate.put("NA07055", "1341 NA07055 0 0 2 1"); hapMapTranslate.put("NA06991", "1341 NA06991 NA06993 NA06985 2 1" ); hapMapTranslate.put("NA06993", "1341 NA06993 0 0 1 1"); hapMapTranslate.put("NA06985", "1341 NA06985 0 0 2 1"); hapMapTranslate.put("NA10851", "1344 NA10851 NA12056 NA12057 1 1" ); hapMapTranslate.put("NA12056", "1344 NA12056 0 0 1 1"); hapMapTranslate.put("NA12057", "1344 NA12057 0 0 2 1"); hapMapTranslate.put("NA07348", "1345 NA07348 NA07357 NA07345 2 1" ); hapMapTranslate.put("NA07357", "1345 NA07357 0 0 1 1"); hapMapTranslate.put("NA07345", "1345 NA07345 0 0 2 1"); hapMapTranslate.put("NA10857", "1346 NA10857 NA12043 NA12044 1 1" ); hapMapTranslate.put("NA12043", "1346 NA12043 0 0 1 1"); hapMapTranslate.put("NA12044", "1346 NA12044 0 0 2 1"); hapMapTranslate.put("NA10859", "1347 NA10859 NA11881 NA11882 2 1" ); hapMapTranslate.put("NA11881", "1347 NA11881 0 0 1 1"); hapMapTranslate.put("NA11882", "1347 NA11882 0 0 2 1"); hapMapTranslate.put("NA10854", "1349 NA10854 NA11839 NA11840 2 1" ); hapMapTranslate.put("NA11839", "1349 NA11839 0 0 1 1"); hapMapTranslate.put("NA11840", "1349 NA11840 0 0 2 1"); hapMapTranslate.put("NA10856", "1350 NA10856 NA11829 NA11830 1 1" ); hapMapTranslate.put("NA11829", "1350 NA11829 0 0 1 1"); hapMapTranslate.put("NA11830", "1350 NA11830 0 0 2 1"); hapMapTranslate.put("NA10855", "1350 NA10855 NA11831 NA11832 2 1" ); hapMapTranslate.put("NA11831", "1350 NA11831 0 0 1 1"); hapMapTranslate.put("NA11832", "1350 NA11832 0 0 2 1"); hapMapTranslate.put("NA12707", "1358 NA12707 NA12716 NA12717 1 1" ); hapMapTranslate.put("NA12716", "1358 NA12716 0 0 1 1"); hapMapTranslate.put("NA12717", "1358 NA12717 0 0 2 1"); hapMapTranslate.put("NA10860", "1362 NA10860 NA11992 NA11993 1 1" ); hapMapTranslate.put("NA11992", "1362 NA11992 0 0 1 1"); hapMapTranslate.put("NA11993", "1362 NA11993 0 0 2 1"); hapMapTranslate.put("NA10861", "1362 NA10861 NA11994 NA11995 2 1" ); hapMapTranslate.put("NA11994", "1362 NA11994 0 0 1 1"); hapMapTranslate.put("NA11995", "1362 NA11995 0 0 2 1"); hapMapTranslate.put("NA10863", "1375 NA10863 NA12264 NA12234 2 1" ); hapMapTranslate.put("NA12264", "1375 NA12264 0 0 1 1"); hapMapTranslate.put("NA12234", "1375 NA12234 0 0 2 1"); hapMapTranslate.put("NA10830", "1408 NA10830 NA12154 NA12236 1 1" ); hapMapTranslate.put("NA12154", "1408 NA12154 0 0 1 1"); hapMapTranslate.put("NA12236", "1408 NA12236 0 0 2 1"); hapMapTranslate.put("NA10831", "1408 NA10831 NA12155 NA12156 2 1" ); hapMapTranslate.put("NA12155", "1408 NA12155 0 0 1 1"); hapMapTranslate.put("NA12156", "1408 NA12156 0 0 2 1"); hapMapTranslate.put("NA10835", "1416 NA10835 NA12248 NA12249 1 1" ); hapMapTranslate.put("NA12248", "1416 NA12248 0 0 1 1"); hapMapTranslate.put("NA12249", "1416 NA12249 0 0 2 1"); hapMapTranslate.put("NA10838", "1420 NA10838 NA12003 NA12004 1 1" ); hapMapTranslate.put("NA12003", "1420 NA12003 0 0 1 1"); hapMapTranslate.put("NA12004", "1420 NA12004 0 0 2 1"); hapMapTranslate.put("NA10839", "1420 NA10839 NA12005 NA12006 2 1" ); hapMapTranslate.put("NA12005", "1420 NA12005 0 0 1 1"); hapMapTranslate.put("NA12006", "1420 NA12006 0 0 2 1"); hapMapTranslate.put("NA12740", "1444 NA12740 NA12750 NA12751 2 1" ); hapMapTranslate.put("NA12750", "1444 NA12750 0 0 1 1"); hapMapTranslate.put("NA12751", "1444 NA12751 0 0 2 1"); hapMapTranslate.put("NA12752", "1447 NA12752 NA12760 NA12761 1 1" ); hapMapTranslate.put("NA12760", "1447 NA12760 0 0 1 1"); hapMapTranslate.put("NA12761", "1447 NA12761 0 0 2 1"); hapMapTranslate.put("NA12753", "1447 NA12753 NA12762 NA12763 2 1" ); hapMapTranslate.put("NA12762", "1447 NA12762 0 0 1 1"); hapMapTranslate.put("NA12763", "1447 NA12763 0 0 2 1"); hapMapTranslate.put("NA12801", "1454 NA12801 NA12812 NA12813 1 1" ); hapMapTranslate.put("NA12812", "1454 NA12812 0 0 1 1"); hapMapTranslate.put("NA12813", "1454 NA12813 0 0 2 1"); hapMapTranslate.put("NA12802", "1454 NA12802 NA12814 NA12815 2 1" ); hapMapTranslate.put("NA12814", "1454 NA12814 0 0 1 1"); hapMapTranslate.put("NA12815", "1454 NA12815 0 0 2 1"); hapMapTranslate.put("NA12864", "1459 NA12864 NA12872 NA12873 1 1" ); hapMapTranslate.put("NA12872", "1459 NA12872 0 0 1 1"); hapMapTranslate.put("NA12873", "1459 NA12873 0 0 2 1"); hapMapTranslate.put("NA12865", "1459 NA12865 NA12874 NA12875 2 1" ); hapMapTranslate.put("NA12874", "1459 NA12874 0 0 1 1"); hapMapTranslate.put("NA12875", "1459 NA12875 0 0 2 1"); hapMapTranslate.put("NA12878", "1463 NA12878 NA12891 NA12892 2 1" ); hapMapTranslate.put("NA12891", "1463 NA12891 0 0 1 1"); hapMapTranslate.put("NA12892", "1463 NA12892 0 0 2 1"); } |
|
return "[TableProfileResult: col: ??; dataType: ??" + | return "[ColumnProfileResult:" + | public String toString() { return "[TableProfileResult: col: ??; dataType: ??" + "; distinctValues: "+distinctValueCount+ "; minLength: "+minLength+ "; maxLength: "+maxLength+ "; avgLength: "+avgLength+ "; minValue: "+minValue+ "; maxValue: "+maxValue+ "; avgValue: "+avgValue+"]"; } |
"; avgValue: "+avgValue+"]"; | "; avgValue: "+avgValue+ "; nullCount: "+getNullCount()+ "]"; | public String toString() { return "[TableProfileResult: col: ??; dataType: ??" + "; distinctValues: "+distinctValueCount+ "; minLength: "+minLength+ "; maxLength: "+maxLength+ "; avgLength: "+avgLength+ "; minValue: "+minValue+ "; maxValue: "+maxValue+ "; avgValue: "+avgValue+"]"; } |
protected abstract void init(Map<String, String> properties); | public void init(Element componentConfig) { id = componentConfig.getAttribute(ID).getValue(); properties = new Properties(componentConfig); init(properties); Element eventElement = componentConfig.getChild("event"); if(eventElement != null){ event = new Event(eventElement); } } | protected abstract void init(Map<String, String> properties); |
protected XMLOutput createXMLOutput() throws Exception { | protected XMLOutput createXMLOutput(Writer writer) throws Exception { | protected XMLOutput createXMLOutput() throws Exception { OutputFormat format = null; if (prettyPrint) { format = OutputFormat.createPrettyPrint(); } else { format = new OutputFormat(); } if ( encoding != null ) { format.setEncoding( encoding ); } if ( omitXmlDeclaration ) { format.setSuppressDeclaration(true); } OutputStream out = new FileOutputStream(name); boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" ); final XMLWriter xmlWriter = (isHtml) ? new HTMLWriter(out, format) : new XMLWriter(out, format); XMLOutput answer = new XMLOutput() { public void close() throws IOException { xmlWriter.close(); } }; answer.setContentHandler(xmlWriter); answer.setLexicalHandler(xmlWriter); return answer; } |
OutputStream out = new FileOutputStream(name); | protected XMLOutput createXMLOutput() throws Exception { OutputFormat format = null; if (prettyPrint) { format = OutputFormat.createPrettyPrint(); } else { format = new OutputFormat(); } if ( encoding != null ) { format.setEncoding( encoding ); } if ( omitXmlDeclaration ) { format.setSuppressDeclaration(true); } OutputStream out = new FileOutputStream(name); boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" ); final XMLWriter xmlWriter = (isHtml) ? new HTMLWriter(out, format) : new XMLWriter(out, format); XMLOutput answer = new XMLOutput() { public void close() throws IOException { xmlWriter.close(); } }; answer.setContentHandler(xmlWriter); answer.setLexicalHandler(xmlWriter); return answer; } |
|
? new HTMLWriter(out, format) : new XMLWriter(out, format); | ? new HTMLWriter(writer, format) : new XMLWriter(writer, format); | protected XMLOutput createXMLOutput() throws Exception { OutputFormat format = null; if (prettyPrint) { format = OutputFormat.createPrettyPrint(); } else { format = new OutputFormat(); } if ( encoding != null ) { format.setEncoding( encoding ); } if ( omitXmlDeclaration ) { format.setSuppressDeclaration(true); } OutputStream out = new FileOutputStream(name); boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" ); final XMLWriter xmlWriter = (isHtml) ? new HTMLWriter(out, format) : new XMLWriter(out, format); XMLOutput answer = new XMLOutput() { public void close() throws IOException { xmlWriter.close(); } }; answer.setContentHandler(xmlWriter); answer.setLexicalHandler(xmlWriter); return answer; } |
if ( name == null ) { throw new MissingAttributeException( "name" ); | if ( name != null ) { Writer writer = new FileWriter(name); writeBody(writer); | public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = createXMLOutput(); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } } |
XMLOutput newOutput = createXMLOutput(); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); | else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); context.setVariable(var, writer.toString()); | public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = createXMLOutput(); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } } |
finally { newOutput.close(); | else { throw new JellyException( "This tag must have either the 'name' or the 'var' variables defined" ); | public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = createXMLOutput(); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } } |
String dbTableName = rs.getString(3); if (dbTableName != null) { if (!dbTableName.equalsIgnoreCase(tableName)) { logger.warn("Got column "+col.getName()+" from "+dbTableName +" in metadata for "+tableName+"; not adding this column."); continue; } } else { logger.warn("Table name not specified in metadata. Continuing anyway..."); } | static void addColumnsToTable(SQLTable addTo, String catalog, String schema, String tableName) throws SQLException, DuplicateColumnException, ArchitectException { Connection con = addTo.parentDatabase.getConnection(); ResultSet rs = null; try { DatabaseMetaData dbmd = con.getMetaData(); logger.debug("SQLColumn.addColumnsToTable: catalog="+catalog+"; schema="+schema+"; tableName="+tableName); rs = dbmd.getColumns(catalog, schema, tableName, "%"); while (rs.next()) { SQLColumn col = new SQLColumn(addTo, rs.getString(4), // col name rs.getInt(5), // data type (from java.sql.Types) rs.getString(6), // native type name rs.getInt(7), // column size rs.getInt(9), // decimal size rs.getInt(11), // nullable rs.getString(12), // remarks rs.getString(13), // default value null, // primaryKeySeq false // isAutoIncrement ); logger.debug("Adding column "+col.getColumnName()); if (addTo.getColumnByName(col.getColumnName(), false) != null) { throw new DuplicateColumnException(addTo, col.getColumnName()); } addTo.columnsFolder.children.add(col); // don't use addTo.columnsFolder.addColumn() (avoids multiple SQLObjectEvents) // XXX: need to find out if column is auto-increment } rs.close(); rs = dbmd.getPrimaryKeys(catalog, schema, tableName); while (rs.next()) { SQLColumn col = addTo.getColumnByName(rs.getString(4), false); col.primaryKeySeq = new Integer(rs.getInt(5)); addTo.setPrimaryKeyName(rs.getString(6)); } rs.close(); rs = null; } finally { if (rs != null) rs.close(); } } |
|
pvd.addDatabase( db1 ); | try { pvd.addDatabase( db1 ); } catch (PhotovaultException ex) { fail( "Exception while registering database: " + ex.getMessage() ); } | public void testDatabaseCollection() { PhotovaultDatabases pvd = new PhotovaultDatabases(); PVDatabase db1 = new PVDatabase(); db1.setName( "test1" ); db1.setDbName( "database1" ); db1.setDbHost( "machine" ); pvd.addDatabase( db1 ); PVDatabase db2 = new PVDatabase(); db2.setName( "test2" ); db2.setDbName( "database2" ); db2.setDbHost( "machine2" ); pvd.addDatabase( db2 ); File f = null; try { f = File.createTempFile( "photovault_settings_", ".xml" ); } catch ( Exception e ) { fail( e.getMessage()); } pvd.save( f ); PhotovaultDatabases pvd2 = PhotovaultDatabases.loadDatabases( f ); } |
pvd.addDatabase( db2 ); | try { pvd.addDatabase( db2 ); } catch (PhotovaultException ex) { fail( "Exception while registering database: " + ex.getMessage() ); } | public void testDatabaseCollection() { PhotovaultDatabases pvd = new PhotovaultDatabases(); PVDatabase db1 = new PVDatabase(); db1.setName( "test1" ); db1.setDbName( "database1" ); db1.setDbHost( "machine" ); pvd.addDatabase( db1 ); PVDatabase db2 = new PVDatabase(); db2.setName( "test2" ); db2.setDbName( "database2" ); db2.setDbHost( "machine2" ); pvd.addDatabase( db2 ); File f = null; try { f = File.createTempFile( "photovault_settings_", ".xml" ); } catch ( Exception e ) { fail( e.getMessage()); } pvd.save( f ); PhotovaultDatabases pvd2 = PhotovaultDatabases.loadDatabases( f ); } |
if ( folders != null ) { Object[] foldersArray = folders.toArray(); for ( int n = 0; n < foldersArray.length; n++ ) { ((PhotoFolder)foldersArray[n]).removePhoto( this ); } } | public void delete() { Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); ODMGXAWrapper txw = new ODMGXAWrapper(); // First delete all instances for ( int i = 0; i < instances.size(); i++ ) { ImageInstance f = (ImageInstance) instances.get( i ); f.delete(); } // Then delete the PhotoInfo itself db.deletePersistent( this ); txw.commit(); } |
|
return null; | return getDefaultThumbnail(); | protected static Thumbnail createThumbnail( PhotoInfo photo, File thumbnailFile ) { Thumbnail thumb = new Thumbnail(); thumb.photo = photo; log.debug( "Creating thumbnail for " + photo.getUid() ); log.debug( " - " + thumbnailFile.getPath() ); try { thumb.image = ImageIO.read( thumbnailFile ); } catch ( IOException e ) { log.warn( "Error reading thumbnail image: " + e.getMessage() ); return null; } return thumb; } |
String thisOne = new String(x + " "); boolean start = false; | Vector do4Gamete(){ Vector blocks = new Vector(); for (int x = 0; x < dPrime.length-1; x++){ String thisOne = new String(x + " "); boolean start = false; for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam == 4){ if (start){ boolean isABlock = true; /** FIX THIS for (int xx = x+1; x < y-1; xx++){ for (int yy = xx+1; yy < y; yy++){ int numGam2=0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam2++; } if(numGam2 == 4){ isABlock = false; } } } **/ if (isABlock){ thisOne += y-1; blocks.add(thisOne); x=y-1; } } break; } start = true; } } return stringVec2intVec(blocks); } |
|
if (numGam == 4){ if (start){ boolean isABlock = true; if (isABlock){ thisOne += y-1; blocks.add(thisOne); x=y-1; | if (numGam > 3){ continue; } Vector addMe = new Vector(); int sep = y - x - 1; addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ strongPairs.add(addMe); }else{ for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; | Vector do4Gamete(){ Vector blocks = new Vector(); for (int x = 0; x < dPrime.length-1; x++){ String thisOne = new String(x + " "); boolean start = false; for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam == 4){ if (start){ boolean isABlock = true; /** FIX THIS for (int xx = x+1; x < y-1; xx++){ for (int yy = xx+1; yy < y; yy++){ int numGam2=0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam2++; } if(numGam2 == 4){ isABlock = false; } } } **/ if (isABlock){ thisOne += y-1; blocks.add(thisOne); x=y-1; } } break; } start = true; } } return stringVec2intVec(blocks); } |
break; | Vector do4Gamete(){ Vector blocks = new Vector(); for (int x = 0; x < dPrime.length-1; x++){ String thisOne = new String(x + " "); boolean start = false; for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam == 4){ if (start){ boolean isABlock = true; /** FIX THIS for (int xx = x+1; x < y-1; xx++){ for (int yy = xx+1; yy < y; yy++){ int numGam2=0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam2++; } if(numGam2 == 4){ isABlock = false; } } } **/ if (isABlock){ thisOne += y-1; blocks.add(thisOne); x=y-1; } } break; } start = true; } } return stringVec2intVec(blocks); } |
|
start = true; | } } boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ boolean isABlock = true; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); if (usedInBlock[first] || usedInBlock[last]) continue; for (int y = first+1; y <= last; y++){ for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam > 3){ isABlock = false; } } } if (isABlock){ if (blocks.size() == 0){ blocks.add(first + " " + last); }else{ 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; } } if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } | Vector do4Gamete(){ Vector blocks = new Vector(); for (int x = 0; x < dPrime.length-1; x++){ String thisOne = new String(x + " "); boolean start = false; for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam == 4){ if (start){ boolean isABlock = true; /** FIX THIS for (int xx = x+1; x < y-1; xx++){ for (int yy = xx+1; yy < y; yy++){ int numGam2=0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam2++; } if(numGam2 == 4){ isABlock = false; } } } **/ if (isABlock){ thisOne += y-1; blocks.add(thisOne); x=y-1; } } break; } start = true; } } return stringVec2intVec(blocks); } |
public void run(Context context, XMLOutput output) throws Exception { | public void run(JellyContext context, XMLOutput output) throws Exception { | public void run(Context context, XMLOutput output) throws Exception { DefineTagLibTag tag = (DefineTagLibTag) findAncestorWithClass(this, DefineTagLibTag.class); if ( tag == null ) { throw new JellyException( "<define:tag> must be inside <define:taglib>" ); } tag.getTagLibrary().registerDynamicTag( getName(), getBody() ); } |
public Object evaluate(Context context) { | public Object evaluate(JellyContext context) { | public Object evaluate(Context context) { this.context = context; xpath.setVariableContext( this ); return xpath; } |
throw new JellyTagException(e); | throw new JellyTagException(inner); | public void doTag(XMLOutput output) throws JellyTagException { // lets find any attributes that are not set and for ( Iterator iter = attributes.values().iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); String name = attribute.getName(); if ( ! setAttributesSet.contains( name ) ) { if ( attribute.isRequired() ) { throw new MissingAttributeException(name); } // lets get the default value Object value = null; Expression expression = attribute.getDefaultValue(); if ( expression != null ) { value = expression.evaluate(context); } // only set non-null values? if ( value != null ) { super.setAttribute(name, value); } } } // If the dynamic bean is itself a tag, let it execute itself if (bean instanceof Tag) { Tag tag = (Tag) bean; tag.setBody(getBody()); tag.setContext(getContext()); tag.setParent(getParent()); ((Tag) bean).doTag(output); return; } invokeBody(output); // export the bean if required if ( var != null ) { context.setVariable(var, bean); } // now, I may invoke the 'execute' method if I have one if ( method != null ) { try { method.invoke( bean, emptyArgs ); } catch (IllegalAccessException e) { methodInvocationException(bean, method, e); } catch (IllegalArgumentException e) { methodInvocationException(bean, method, e); } catch (InvocationTargetException e) { // methodInvocationError(bean, method, e); Throwable inner = e.getTargetException(); throw new JellyTagException(e); } } } |
}else{ useable.addAll(victor); | }else if (victor.size() == 1){ Individual singleton = (Individual) victor.elementAt(0); if (!(singleton.getGenoPC() < 1 - Options.getMissingThreshold())){ useable.addAll(victor); } | public Vector check() throws PedFileException{ //before we perform the check we want to prune out individuals with too much missing data //or trios which contain individuals with too much missing data Iterator fitr = families.values().iterator(); Vector useable = new Vector(); while (fitr.hasNext()){ Family curFam = (Family) fitr.next(); Enumeration indIDEnum = curFam.getMemberList(); Vector victor = new Vector(); while (indIDEnum.hasMoreElements()){ victor.add(curFam.getMember((String) indIDEnum.nextElement())); } if (victor.size() > 1){ PedParser pp = new PedParser(); try { SimpleGraph sg = pp.buildGraph(victor, Options.getMissingThreshold()); Vector indStrings = pp.parsePed(sg); if (indStrings != null){ Iterator sitr = indStrings.iterator(); while (sitr.hasNext()){ useable.add(curFam.getMember((String)sitr.next())); } } }catch (PedigreeException pe){ throw new PedFileException(pe.getMessage() + "\nin family " + curFam.getFamilyName()); } }else{ useable.addAll(victor); } } unrelatedIndividuals = useable; Vector indList = (Vector)allIndividuals.clone(); Individual currentInd; Family currentFamily; //deal with individuals who are missing too much data for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if (currentInd.getGenoPC() < 1 - Options.getMissingThreshold()){ allIndividuals.removeElement(currentInd); axedPeople.add(currentInd); currentInd.setReasonImAxed("% Genotypes: " + new Double(currentInd.getGenoPC()*100).intValue()); currentFamily.removeMember(currentInd.getIndividualID()); if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); } }else if (!useable.contains(currentInd)){ axedPeople.add(currentInd); currentInd.setReasonImAxed("Not a member of maximum unrelated subset."); } } CheckData cd = new CheckData(this); Vector results = cd.check(); this.results = results; return results; } |
AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); | AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); | protected void createThumbnail( Volume volume ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage thumbImage = atOp.filter( origImage, null ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); } |
log.warn( "Loading thumbnail..." ); | protected void createThumbnail( Volume volume ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage thumbImage = atOp.filter( origImage, null ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); } |
|
return Thumbnail.getDefaultThumbnail(); | thumbnail = Thumbnail.getDefaultThumbnail(); | public Thumbnail getThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance return Thumbnail.getDefaultThumbnail(); } return thumbnail; } |
multidprime += (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal)*Math.abs(num/denom); | if (denom != 0){ noDivByZero = true; multidprime += (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal)*Math.abs(num/denom); } | Haplotype[][] generateCrossovers(Haplotype[][] haplos) throws HaploViewException{ Vector crossBlock = new Vector(); double CROSSOVER_THRESHOLD = 0.01; //to what percentage do we want to consider crossings? if (haplos.length == 0) return null; //seed first block with ordering numbers for (int u = 0; u < haplos[0].length; u++){ haplos[0][u].setListOrder(u); } for (int i = 0; i < haplos.length; i++){ haplos[i][0].clearTags(); } multidprimeArray = new double[haplos.length]; //get "tag" SNPS if there is only one block: if (haplos.length==1){ Vector theBestSubset = getBestSubset(haplos[0]); for (int i = 0; i < theBestSubset.size(); i++){ haplos[0][0].addTag(((Integer)theBestSubset.elementAt(i)).intValue()); } } for (int gap = 0; gap < haplos.length - 1; gap++){ //compute crossovers for each inter-block gap Vector preGapSubset = getBestSubset(haplos[gap]); Vector postGapSubset = getBestSubset(haplos[gap+1]); int[] preMarkerID = haplos[gap][0].getMarkers(); //index haplos to markers in whole dataset int[] postMarkerID = haplos[gap+1][0].getMarkers(); crossBlock.clear(); //make a "block" of the markers which id the pre- and post- gap haps for (int i = 0; i < preGapSubset.size(); i++){ crossBlock.add(new Integer(preMarkerID[((Integer)preGapSubset.elementAt(i)).intValue()])); //mark tags haplos[gap][0].addTag(((Integer)preGapSubset.elementAt(i)).intValue()); } for (int i = 0; i < postGapSubset.size(); i++){ crossBlock.add(new Integer(postMarkerID[((Integer)postGapSubset.elementAt(i)).intValue()])); //mark tags haplos[gap+1][0].addTag(((Integer)postGapSubset.elementAt(i)).intValue()); } Vector inputVector = new Vector(); int[] intArray = new int[crossBlock.size()]; for (int i = 0; i < crossBlock.size(); i++){ //input format for hap generating routine intArray[i] = ((Integer)crossBlock.elementAt(i)).intValue(); } inputVector.add(intArray); Haplotype[] crossHaplos = generateHaplotypes(inputVector, 1)[0]; //get haplos of gap double[][] multilocusTable = new double[haplos[gap].length][]; double[] rowSum = new double[haplos[gap].length]; double[] colSum = new double[haplos[gap+1].length]; double multilocusTotal = 0; for (int i = 0; i < haplos[gap].length; i++){ double[] crossPercentages = new double[haplos[gap+1].length]; StringBuffer firstHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = 0; j < preGapSubset.size(); j++){ //make a string out of uniquely identifying genotypes for this hap firstHapCodeB.append(haplos[gap][i].getGeno()[((Integer)preGapSubset.elementAt(j)).intValue()]); } String firstHapCode = firstHapCodeB.toString(); for (int gapHaplo = 0; gapHaplo < crossHaplos.length; gapHaplo++){ //look at each crossover hap if (crossHaplos[gapHaplo].getPercentage() > CROSSOVER_THRESHOLD){ StringBuffer gapBeginHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = 0; j < preGapSubset.size(); j++){ //make a string as above gapBeginHapCodeB.append(crossHaplos[gapHaplo].getGeno()[j]); } String gapBeginHapCode = gapBeginHapCodeB.toString(); if (gapBeginHapCode.equals(firstHapCode)){ //if this crossover hap corresponds to this pregap hap StringBuffer gapEndHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = preGapSubset.size(); j < crossHaplos[gapHaplo].getGeno().length; j++){ gapEndHapCodeB.append(crossHaplos[gapHaplo].getGeno()[j]); } String gapEndHapCode = gapEndHapCodeB.toString(); for (int j = 0; j < haplos[gap+1].length; j++){ StringBuffer endHapCodeB = new StringBuffer(); for (int k = 0; k < postGapSubset.size(); k++){ endHapCodeB.append(haplos[gap+1][j].getGeno()[((Integer)postGapSubset.elementAt(k)).intValue()]); } String endHapCode = endHapCodeB.toString(); if (gapEndHapCode.equals(endHapCode)){ crossPercentages[j] = crossHaplos[gapHaplo].getPercentage(); } } } } } //thought i needed to fix these percentages, but the raw values are just as good. /* double percentageSum = 0; double[] fixedCross = new double[crossPercentages.length]; for (int y = 0; y < crossPercentages.length; y++){ percentageSum += crossPercentages[y]; } for (int y = 0; y < crossPercentages.length; y++){ fixedCross[y] = crossPercentages[y]/percentageSum; }*/ haplos[gap][i].addCrossovers(crossPercentages); multilocusTable[i] = crossPercentages; } //sort based on "straight line" crossings int hilimit; int lolimit; if (haplos[gap+1].length > haplos[gap].length) { hilimit = haplos[gap+1].length; lolimit = haplos[gap].length; }else{ hilimit = haplos[gap].length; lolimit = haplos[gap+1].length; } boolean[] unavailable = new boolean[hilimit]; int[] prevBlockLocs = new int[haplos[gap].length]; for (int q = 0; q < prevBlockLocs.length; q++){ prevBlockLocs[haplos[gap][q].getListOrder()] = q; } for (int u = 0; u < haplos[gap+1].length; u++){ double currentBestVal = 0; int currentBestLoc = -1; for (int v = 0; v < lolimit; v++){ if (!(unavailable[v])){ if (haplos[gap][prevBlockLocs[v]].getCrossover(u) >= currentBestVal) { currentBestLoc = haplos[gap][prevBlockLocs[v]].getListOrder(); currentBestVal = haplos[gap][prevBlockLocs[v]].getCrossover(u); } } } //it didn't get lined up with any of the previous block's markers //put it at the end of the list if (currentBestLoc == -1){ for (int v = 0; v < unavailable.length; v++){ if (!(unavailable[v])){ currentBestLoc = v; break; } } } haplos[gap+1][u].setListOrder(currentBestLoc); unavailable[currentBestLoc] = true; } //compute multilocus D' for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ rowSum[i] += multilocusTable[i][j]; colSum[j] += multilocusTable[i][j]; multilocusTotal += multilocusTable[i][j]; if (rowSum[i] == 0) rowSum[i] = 0.0001; if (colSum[j] == 0) colSum[j] = 0.0001; } } double multidprime = 0; for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ double num = (multilocusTable[i][j]/multilocusTotal) - (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom; if (num < 0){ double denom1 = (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(1.0 - (colSum[j]/multilocusTotal)); if (denom1 < denom2) { denom = denom1; }else{ denom = denom2; } }else{ double denom1 = (rowSum[i]/multilocusTotal)*(1.0 -(colSum[j]/multilocusTotal)); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(colSum[j]/multilocusTotal); if (denom1 < denom2){ denom = denom1; }else{ denom = denom2; } } multidprime += (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal)*Math.abs(num/denom); } } multidprimeArray[gap] = multidprime; } return haplos; } |
multidprimeArray[gap] = multidprime; | if (noDivByZero){ multidprimeArray[gap] = multidprime; }else{ multidprimeArray[gap] = 1.00; } | Haplotype[][] generateCrossovers(Haplotype[][] haplos) throws HaploViewException{ Vector crossBlock = new Vector(); double CROSSOVER_THRESHOLD = 0.01; //to what percentage do we want to consider crossings? if (haplos.length == 0) return null; //seed first block with ordering numbers for (int u = 0; u < haplos[0].length; u++){ haplos[0][u].setListOrder(u); } for (int i = 0; i < haplos.length; i++){ haplos[i][0].clearTags(); } multidprimeArray = new double[haplos.length]; //get "tag" SNPS if there is only one block: if (haplos.length==1){ Vector theBestSubset = getBestSubset(haplos[0]); for (int i = 0; i < theBestSubset.size(); i++){ haplos[0][0].addTag(((Integer)theBestSubset.elementAt(i)).intValue()); } } for (int gap = 0; gap < haplos.length - 1; gap++){ //compute crossovers for each inter-block gap Vector preGapSubset = getBestSubset(haplos[gap]); Vector postGapSubset = getBestSubset(haplos[gap+1]); int[] preMarkerID = haplos[gap][0].getMarkers(); //index haplos to markers in whole dataset int[] postMarkerID = haplos[gap+1][0].getMarkers(); crossBlock.clear(); //make a "block" of the markers which id the pre- and post- gap haps for (int i = 0; i < preGapSubset.size(); i++){ crossBlock.add(new Integer(preMarkerID[((Integer)preGapSubset.elementAt(i)).intValue()])); //mark tags haplos[gap][0].addTag(((Integer)preGapSubset.elementAt(i)).intValue()); } for (int i = 0; i < postGapSubset.size(); i++){ crossBlock.add(new Integer(postMarkerID[((Integer)postGapSubset.elementAt(i)).intValue()])); //mark tags haplos[gap+1][0].addTag(((Integer)postGapSubset.elementAt(i)).intValue()); } Vector inputVector = new Vector(); int[] intArray = new int[crossBlock.size()]; for (int i = 0; i < crossBlock.size(); i++){ //input format for hap generating routine intArray[i] = ((Integer)crossBlock.elementAt(i)).intValue(); } inputVector.add(intArray); Haplotype[] crossHaplos = generateHaplotypes(inputVector, 1)[0]; //get haplos of gap double[][] multilocusTable = new double[haplos[gap].length][]; double[] rowSum = new double[haplos[gap].length]; double[] colSum = new double[haplos[gap+1].length]; double multilocusTotal = 0; for (int i = 0; i < haplos[gap].length; i++){ double[] crossPercentages = new double[haplos[gap+1].length]; StringBuffer firstHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = 0; j < preGapSubset.size(); j++){ //make a string out of uniquely identifying genotypes for this hap firstHapCodeB.append(haplos[gap][i].getGeno()[((Integer)preGapSubset.elementAt(j)).intValue()]); } String firstHapCode = firstHapCodeB.toString(); for (int gapHaplo = 0; gapHaplo < crossHaplos.length; gapHaplo++){ //look at each crossover hap if (crossHaplos[gapHaplo].getPercentage() > CROSSOVER_THRESHOLD){ StringBuffer gapBeginHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = 0; j < preGapSubset.size(); j++){ //make a string as above gapBeginHapCodeB.append(crossHaplos[gapHaplo].getGeno()[j]); } String gapBeginHapCode = gapBeginHapCodeB.toString(); if (gapBeginHapCode.equals(firstHapCode)){ //if this crossover hap corresponds to this pregap hap StringBuffer gapEndHapCodeB = new StringBuffer(preGapSubset.size()); for (int j = preGapSubset.size(); j < crossHaplos[gapHaplo].getGeno().length; j++){ gapEndHapCodeB.append(crossHaplos[gapHaplo].getGeno()[j]); } String gapEndHapCode = gapEndHapCodeB.toString(); for (int j = 0; j < haplos[gap+1].length; j++){ StringBuffer endHapCodeB = new StringBuffer(); for (int k = 0; k < postGapSubset.size(); k++){ endHapCodeB.append(haplos[gap+1][j].getGeno()[((Integer)postGapSubset.elementAt(k)).intValue()]); } String endHapCode = endHapCodeB.toString(); if (gapEndHapCode.equals(endHapCode)){ crossPercentages[j] = crossHaplos[gapHaplo].getPercentage(); } } } } } //thought i needed to fix these percentages, but the raw values are just as good. /* double percentageSum = 0; double[] fixedCross = new double[crossPercentages.length]; for (int y = 0; y < crossPercentages.length; y++){ percentageSum += crossPercentages[y]; } for (int y = 0; y < crossPercentages.length; y++){ fixedCross[y] = crossPercentages[y]/percentageSum; }*/ haplos[gap][i].addCrossovers(crossPercentages); multilocusTable[i] = crossPercentages; } //sort based on "straight line" crossings int hilimit; int lolimit; if (haplos[gap+1].length > haplos[gap].length) { hilimit = haplos[gap+1].length; lolimit = haplos[gap].length; }else{ hilimit = haplos[gap].length; lolimit = haplos[gap+1].length; } boolean[] unavailable = new boolean[hilimit]; int[] prevBlockLocs = new int[haplos[gap].length]; for (int q = 0; q < prevBlockLocs.length; q++){ prevBlockLocs[haplos[gap][q].getListOrder()] = q; } for (int u = 0; u < haplos[gap+1].length; u++){ double currentBestVal = 0; int currentBestLoc = -1; for (int v = 0; v < lolimit; v++){ if (!(unavailable[v])){ if (haplos[gap][prevBlockLocs[v]].getCrossover(u) >= currentBestVal) { currentBestLoc = haplos[gap][prevBlockLocs[v]].getListOrder(); currentBestVal = haplos[gap][prevBlockLocs[v]].getCrossover(u); } } } //it didn't get lined up with any of the previous block's markers //put it at the end of the list if (currentBestLoc == -1){ for (int v = 0; v < unavailable.length; v++){ if (!(unavailable[v])){ currentBestLoc = v; break; } } } haplos[gap+1][u].setListOrder(currentBestLoc); unavailable[currentBestLoc] = true; } //compute multilocus D' for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ rowSum[i] += multilocusTable[i][j]; colSum[j] += multilocusTable[i][j]; multilocusTotal += multilocusTable[i][j]; if (rowSum[i] == 0) rowSum[i] = 0.0001; if (colSum[j] == 0) colSum[j] = 0.0001; } } double multidprime = 0; for (int i = 0; i < rowSum.length; i++){ for (int j = 0; j < colSum.length; j++){ double num = (multilocusTable[i][j]/multilocusTotal) - (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom; if (num < 0){ double denom1 = (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(1.0 - (colSum[j]/multilocusTotal)); if (denom1 < denom2) { denom = denom1; }else{ denom = denom2; } }else{ double denom1 = (rowSum[i]/multilocusTotal)*(1.0 -(colSum[j]/multilocusTotal)); double denom2 = (1.0 - (rowSum[i]/multilocusTotal))*(colSum[j]/multilocusTotal); if (denom1 < denom2){ denom = denom1; }else{ denom = denom2; } } multidprime += (rowSum[i]/multilocusTotal)*(colSum[j]/multilocusTotal)*Math.abs(num/denom); } } multidprimeArray[gap] = multidprime; } return haplos; } |
registerTag( "script", DefineScriptTag.class ); | public DefineTagLibrary() { registerTag( "taglib", DefineTagLibTag.class ); registerTag( "tag", DefineTagTag.class ); registerTag( "invokeBody", InvokeBodyTag.class ); } |
|
if (currentColor != null) { g2.setColor(tp.getForeground()); } | public void paint(Graphics g, JComponent c) { TablePane tp = (TablePane) c; try { Graphics2D g2 = (Graphics2D) g; if (logger.isDebugEnabled()) { Rectangle clip = g2.getClipBounds(); if (clip != null) { g2.setColor(Color.red); clip.width--; clip.height--; g2.draw(clip); g2.setColor(tp.getForeground()); logger.debug("Clipping region: "+g2.getClip()); } else { logger.debug("Null clipping region"); } } // We don't want to paint inside the insets or borders. Insets insets = c.getInsets(); g.translate(insets.left, insets.top); int width = c.getWidth() - insets.left - insets.right; int height = c.getHeight() - insets.top - insets.bottom; Font font = c.getFont(); if (font == null) { // This happens when the table exists but has no visible ancestor. // Don't ask me why it's being asked to paint under those circumstances! //logger.error("paint(): Null font in TablePane "+c); return; } FontMetrics metrics = c.getFontMetrics(font); int fontHeight = metrics.getHeight(); int ascent = metrics.getAscent(); int maxDescent = metrics.getMaxDescent(); int y = 0; // hilight title if table is selected if (tp.selected == true) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } g2.fillRect(0, 0, c.getWidth(), fontHeight); g2.setColor(c.getForeground()); // print table name g2.drawString(tablePane.getModel().getTableName(), 0, y += ascent); // draw box around columns if (fontHeight < 0) { throw new IllegalStateException("FontHeight is negative"); } g2.drawRect(0, fontHeight+gap, width-boxLineThickness, height-(fontHeight+gap+boxLineThickness)); y += gap + boxLineThickness + tp.getMargin().top; // print columns Iterator colNameIt = tablePane.getModel().getColumns().iterator(); int i = 0; int hwidth = width-tp.getMargin().right-tp.getMargin().left-boxLineThickness*2; boolean stillNeedPKLine = true; while (colNameIt.hasNext()) { SQLColumn col = (SQLColumn) colNameIt.next(); if (col.getPrimaryKeySeq() == null && stillNeedPKLine) { stillNeedPKLine = false; y += pkGap; g2.drawLine(0, y+maxDescent-(pkGap/2), width-1, y+maxDescent-(pkGap/2)); } if (tp.isColumnSelected(i)) { if (logger.isDebugEnabled()) logger.debug("Column "+i+" is selected"); g2.setColor(selectedColor); g2.fillRect(boxLineThickness+tp.getMargin().left, y-ascent+fontHeight, hwidth, fontHeight); g2.setColor(tp.getForeground()); } g2.drawString(col.getShortDisplayName(), boxLineThickness+tp.getMargin().left, y += fontHeight); i++; } if (stillNeedPKLine) { stillNeedPKLine = false; y += pkGap; g2.drawLine(0, y+maxDescent-(pkGap/2), width-1, y+maxDescent-(pkGap/2)); } // paint insertion point int ip = tablePane.getInsertionPoint(); if (logger.isDebugEnabled()) { g2.drawString(String.valueOf(ip), width-20, ascent); } if (ip != TablePane.COLUMN_INDEX_NONE) { y = gap + boxLineThickness + tp.getMargin().top + fontHeight; if (ip == TablePane.COLUMN_INDEX_END_OF_PK) { y += fontHeight * tablePane.getModel().getPkSize(); } else if (ip == TablePane.COLUMN_INDEX_START_OF_NON_PK) { y += fontHeight * tablePane.getModel().getPkSize() + pkGap; } else if (ip < tablePane.getModel().getPkSize()) { if (ip == TablePane.COLUMN_INDEX_TITLE) ip = 0; y += ip * fontHeight; } else { y += ip * fontHeight + pkGap; } g2.drawLine(5, y, width - 6, y); g2.drawLine(2, y-3, 5, y); g2.drawLine(2, y+3, 5, y); g2.drawLine(width - 3, y-3, width - 6, y); g2.drawLine(width - 3, y+3, width - 6, y); } g.translate(-insets.left, -insets.top); } catch (ArchitectException e) { logger.warn("BasicTablePaneUI.paint failed", e); } } |
|
protected void doCreateRelationship() { | static public void doCreateRelationship(SQLTable pkTable,SQLTable fkTable,PlayPen pp, boolean identifying) { | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); | model.setName(pkTable.getName()+"_"+fkTable.getName()+"_fk"); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); | model.setPkTable(pkTable); model.setFkTable(fkTable); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); | pkTable.addExportedKey(model); fkTable.addImportedKey(model); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); | java.util.List pkColListCopy = new ArrayList(pkTable.getColumns().size()); pkColListCopy.addAll(pkTable.getColumns()); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); | SQLColumn match = fkTable.getColumnByName(pkCol.getName()); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
"The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + | "The primary key column " + pkCol.getName() + " already exists\n" + " in the child table, but has an incompatible type. Continue using new name\n" + | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); | fkCol.setName(generateUniqueColumnName(pkCol,fkTable)); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
fkTable.getModel().addColumn(fkCol); | fkTable.addColumn(fkCol); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); | fkCol.setPrimaryKeySeq(new Integer(fkTable.getPkSize())); | protected void doCreateRelationship() { try { SQLRelationship model = new SQLRelationship(); // XXX: need to ensure uniqueness of setName(), but // to_identifier should take care of this... model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); // check to see if the FK table already has this column SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { // there is already a column of this name if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; fkCol.addReference(); // reference counting, stops column from being removed if relationship is removed } else { // ask the user if they would like to rename the column // or cancel the creation of the relationship int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { // XXX: need to ensure uniqueness of setName(), // but to_identifier in DDLGenerator should take // care of this fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; // abort the creation of this relationship } fkTable.getModel().addColumn(fkCol); } } else { // no match, so we need to import this column from PK table fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { // add column to primary key (but only if it's not already there!!! fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().getPkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); pp.addRelationship(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
put(PL_SCHEMA_OWNER, schema); | putImpl(PL_SCHEMA_OWNER, schema, "plSchema"); | public void setPlSchema(String schema) { put(PL_SCHEMA_OWNER, schema); } |
put(PL_TYPE, type); | putImpl(PL_TYPE, type, "plDbType"); | public void setPlDbType(String type) { put(PL_TYPE, type); } |
put(PL_DSN, dsn); | putImpl(PL_DSN, dsn, "odbcDsn"); | public void setOdbcDsn(String dsn) { put(PL_DSN, dsn); } |
protected void handleException(JellyException e) throws JellyTagException { | protected void handleException(JellyTagException e) throws JellyTagException { | protected void handleException(JellyException e) throws JellyTagException { if (log.isTraceEnabled()) { log.trace( "Caught exception: " + e, e ); } applyLocation(e); throw new JellyTagException(e); } |
throw new JellyTagException(e); | throw e; | protected void handleException(JellyException e) throws JellyTagException { if (log.isTraceEnabled()) { log.trace( "Caught exception: " + e, e ); } applyLocation(e); throw new JellyTagException(e); } |
JMenu zoomMenu = new JMenu("D prime zoom"); | JMenu zoomMenu = new JMenu("LD zoom"); | 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); /* 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]); } exportMenuItems[2].setEnabled(true); 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("D prime 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("D prime 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()); } |
JMenu colorMenu = new JMenu("D prime color scheme"); | JMenu colorMenu = new JMenu("LD color scheme"); | 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); /* 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]); } exportMenuItems[2].setEnabled(true); 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("D prime 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("D prime 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 (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; | void readGenotypes(String[] inputOptions, int type){ //input is a 3 element array with //inputOptions[0] = ped file //inputOptions[1] = info file ("" if none) //inputOptions[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); try { if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_TDT_NUM].setEnabled(false); assocTest = 0; } theData = new HaploData(assocTest); if (type == HAPS){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } checkPanel = null; if (type == HAPS){ readMarkers(markerFile, null); }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); checkPanel = new CheckDataPanel(theData); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); } //deal with max comparison distance if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; //let's start the math this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(1); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; tdtPanel = new TDTPanel(theData.chromosomes, assocTest); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
|
DynaTag dynaTag = (DynaTag) tag; | public void run(JellyContext context, XMLOutput output) throws Exception { try { tag.setContext(context); DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } } |
|
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); | if ( tag instanceof DynaTag ) { DynaTag dynaTag = (DynaTag) tag; for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } } else { DynaBean dynaBean = new ConvertingWrapDynaBean( tag ); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaBean.set(name, value); } | public void run(JellyContext context, XMLOutput output) throws Exception { try { tag.setContext(context); DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } } |
byte[] markers = currentInd.getMarker(loc); | byte[] markers; byte[] zeroArray = {0,0}; if (currentInd.getZeroed(loc)){ markers = zeroArray; }else{ markers = currentInd.getMarker(loc); } | private MarkerResult checkMarker(int loc, String name)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; //int indivgeno=0, int missing=0, parenthet=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0; //Hashtable allgenos = new Hashtable(); Hashtable numindivs=new Hashtable(); Hashtable parentgeno = new Hashtable(); Hashtable kidgeno = new Hashtable(); Hashtable parenthom = new Hashtable(); Hashtable count = new Hashtable(); String allele1_string, allele2_string; //loop through each family, check data for marker loc Enumeration famList = _pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = _pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if(!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0"))){ //do mendel check //byte[] marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getMomID())).getMarker(loc); byte[] marker = (currentFamily.getMember(currentInd.getMomID())).getMarker(loc); int momAllele1 = marker[0]; int momAllele2 = marker[1]; //marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getDadID())).getMarker(loc); marker = (currentFamily.getMember(currentInd.getDadID())).getMarker(loc); int dadAllele1 = marker[0]; int dadAllele2 = marker[1]; //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } //end mendel check } } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has parents if(currentInd.getMomID().compareTo(Individual.DATA_MISSING)==0 && currentInd.getDadID().compareTo(Individual.DATA_MISSING)==0){ //$parentgeno{$ped}++ //set parentgeno incOrSetOne(parentgeno,familyID); if(allele1 != allele2) { parenthet++; } else{ incOrSetOne(parenthom,allele1_string); } } else{//$kidgeno{$ped}++ incOrSetOne(kidgeno,familyID); } if(allele1 == allele2) { hom++; } else { het++; } //count number of allele incOrSetOne(count,allele1_string); incOrSetOne(count,allele2_string); } //missing data else missing++; } } } double obsHET = getObsHET(het, hom); double preHET = getPreHET(count); //HW p value double pvalue = getPValue(parenthom, parenthet); //geno percent double genopct = getGenoPercent(het, hom, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(numindivs, parentgeno, kidgeno); //rating int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum); result.setObsHet(obsHET); result.setPredHet(preHET); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setName(name); return result; } |
double preHET = getPreHET(count); | double[] freqStuff = getFreqStuff(count); double preHET = freqStuff[0]; double maf = freqStuff[1]; | private MarkerResult checkMarker(int loc, String name)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; //int indivgeno=0, int missing=0, parenthet=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0; //Hashtable allgenos = new Hashtable(); Hashtable numindivs=new Hashtable(); Hashtable parentgeno = new Hashtable(); Hashtable kidgeno = new Hashtable(); Hashtable parenthom = new Hashtable(); Hashtable count = new Hashtable(); String allele1_string, allele2_string; //loop through each family, check data for marker loc Enumeration famList = _pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = _pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if(!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0"))){ //do mendel check //byte[] marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getMomID())).getMarker(loc); byte[] marker = (currentFamily.getMember(currentInd.getMomID())).getMarker(loc); int momAllele1 = marker[0]; int momAllele2 = marker[1]; //marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getDadID())).getMarker(loc); marker = (currentFamily.getMember(currentInd.getDadID())).getMarker(loc); int dadAllele1 = marker[0]; int dadAllele2 = marker[1]; //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } //end mendel check } } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has parents if(currentInd.getMomID().compareTo(Individual.DATA_MISSING)==0 && currentInd.getDadID().compareTo(Individual.DATA_MISSING)==0){ //$parentgeno{$ped}++ //set parentgeno incOrSetOne(parentgeno,familyID); if(allele1 != allele2) { parenthet++; } else{ incOrSetOne(parenthom,allele1_string); } } else{//$kidgeno{$ped}++ incOrSetOne(kidgeno,familyID); } if(allele1 == allele2) { hom++; } else { het++; } //count number of allele incOrSetOne(count,allele1_string); incOrSetOne(count,allele2_string); } //missing data else missing++; } } } double obsHET = getObsHET(het, hom); double preHET = getPreHET(count); //HW p value double pvalue = getPValue(parenthom, parenthet); //geno percent double genopct = getGenoPercent(het, hom, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(numindivs, parentgeno, kidgeno); //rating int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum); result.setObsHet(obsHET); result.setPredHet(preHET); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setName(name); return result; } |
int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum); | int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum,maf); | private MarkerResult checkMarker(int loc, String name)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; //int indivgeno=0, int missing=0, parenthet=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0; //Hashtable allgenos = new Hashtable(); Hashtable numindivs=new Hashtable(); Hashtable parentgeno = new Hashtable(); Hashtable kidgeno = new Hashtable(); Hashtable parenthom = new Hashtable(); Hashtable count = new Hashtable(); String allele1_string, allele2_string; //loop through each family, check data for marker loc Enumeration famList = _pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = _pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if(!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0"))){ //do mendel check //byte[] marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getMomID())).getMarker(loc); byte[] marker = (currentFamily.getMember(currentInd.getMomID())).getMarker(loc); int momAllele1 = marker[0]; int momAllele2 = marker[1]; //marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getDadID())).getMarker(loc); marker = (currentFamily.getMember(currentInd.getDadID())).getMarker(loc); int dadAllele1 = marker[0]; int dadAllele2 = marker[1]; //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } //end mendel check } } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has parents if(currentInd.getMomID().compareTo(Individual.DATA_MISSING)==0 && currentInd.getDadID().compareTo(Individual.DATA_MISSING)==0){ //$parentgeno{$ped}++ //set parentgeno incOrSetOne(parentgeno,familyID); if(allele1 != allele2) { parenthet++; } else{ incOrSetOne(parenthom,allele1_string); } } else{//$kidgeno{$ped}++ incOrSetOne(kidgeno,familyID); } if(allele1 == allele2) { hom++; } else { het++; } //count number of allele incOrSetOne(count,allele1_string); incOrSetOne(count,allele2_string); } //missing data else missing++; } } } double obsHET = getObsHET(het, hom); double preHET = getPreHET(count); //HW p value double pvalue = getPValue(parenthom, parenthet); //geno percent double genopct = getGenoPercent(het, hom, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(numindivs, parentgeno, kidgeno); //rating int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum); result.setObsHet(obsHET); result.setPredHet(preHET); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setName(name); return result; } |
result.setMAF(maf); | private MarkerResult checkMarker(int loc, String name)throws PedFileException{ MarkerResult result = new MarkerResult(); Individual currentInd; //int indivgeno=0, int missing=0, parenthet=0, mendErrNum=0; int allele1=0, allele2=0, hom=0, het=0; //Hashtable allgenos = new Hashtable(); Hashtable numindivs=new Hashtable(); Hashtable parentgeno = new Hashtable(); Hashtable kidgeno = new Hashtable(); Hashtable parenthom = new Hashtable(); Hashtable count = new Hashtable(); String allele1_string, allele2_string; //loop through each family, check data for marker loc Enumeration famList = _pedFile.getFamList(); while(famList.hasMoreElements()){ Family currentFamily = _pedFile.getFamily((String)famList.nextElement()); Enumeration indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //make sure entry has parents if(!(currentInd.getMomID().equals("0") || currentInd.getDadID().equals("0"))){ //do mendel check //byte[] marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getMomID())).getMarker(loc); byte[] marker = (currentFamily.getMember(currentInd.getMomID())).getMarker(loc); int momAllele1 = marker[0]; int momAllele2 = marker[1]; //marker = ((Individual)pedFileHash.get(familyID + " " + currentInd.getDadID())).getMarker(loc); marker = (currentFamily.getMember(currentInd.getDadID())).getMarker(loc); int dadAllele1 = marker[0]; int dadAllele2 = marker[1]; //don't check if parents are missing any data if (!(momAllele1 == 0 || momAllele2 == 0 || dadAllele1 == 0 || dadAllele2 ==0)){ //mom hom if(momAllele1 == momAllele2){ //both parents hom if (dadAllele1 == dadAllele2){ //both parents hom same allele if (momAllele1 == dadAllele1){ //kid must be hom same allele if (allele1 != momAllele1 || allele2 != momAllele1) { mendErrNum ++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } //parents hom diff allele }else{ //kid must be het if (allele1 == allele2) { mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom hom dad het }else{ //kid can't be hom for non-momallele if (allele1 != momAllele1 && allele2 != momAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //mom het }else{ //dad hom if (dadAllele1 == dadAllele2){ //kid can't be hom for non-dadallele if(allele1 != dadAllele1 && allele2 != dadAllele1){ mendErrNum++; currentInd.zeroOutMarker(loc); currentFamily.getMember(currentInd.getMomID()).zeroOutMarker(loc); currentFamily.getMember(currentInd.getDadID()).zeroOutMarker(loc); } } //both parents het no mend err poss } } } //end mendel check } } } indList = currentFamily.getMemberList(); //loop through each individual in the current Family while(indList.hasMoreElements()){ currentInd = currentFamily.getMember((String)indList.nextElement()); if (currentInd.getIsTyped()){ byte[] markers = currentInd.getMarker(loc); allele1 = markers[0]; allele1_string = Integer.toString(allele1); allele2 = markers[1]; allele2_string = Integer.toString(allele2); String familyID = currentInd.getFamilyID(); incOrSetOne(numindivs,familyID); //no allele data missing if(allele1 > 0 && allele2 >0){ //indiv has parents if(currentInd.getMomID().compareTo(Individual.DATA_MISSING)==0 && currentInd.getDadID().compareTo(Individual.DATA_MISSING)==0){ //$parentgeno{$ped}++ //set parentgeno incOrSetOne(parentgeno,familyID); if(allele1 != allele2) { parenthet++; } else{ incOrSetOne(parenthom,allele1_string); } } else{//$kidgeno{$ped}++ incOrSetOne(kidgeno,familyID); } if(allele1 == allele2) { hom++; } else { het++; } //count number of allele incOrSetOne(count,allele1_string); incOrSetOne(count,allele2_string); } //missing data else missing++; } } } double obsHET = getObsHET(het, hom); double preHET = getPreHET(count); //HW p value double pvalue = getPValue(parenthom, parenthet); //geno percent double genopct = getGenoPercent(het, hom, missing); // num of families with a fully genotyped trio //int famTrio =0; int famTrio = getNumOfFamTrio(numindivs, parentgeno, kidgeno); //rating int rating = this.getRating(genopct, pvalue, obsHET, mendErrNum); result.setObsHet(obsHET); result.setPredHet(preHET); result.setHWpvalue(pvalue); result.setGenoPercent(genopct); result.setFamTrioNum(famTrio); result.setMendErrNum(mendErrNum); result.setRating(rating); result.setName(name); return result; } |
|
private int getRating(double genopct, double pval, double obsHet, int menderr){ | private int getRating(double genopct, double pval, double obsHet, int menderr, double maf){ | private int getRating(double genopct, double pval, double obsHet, int menderr){ int rating = 0; if (obsHet < 0.01){ rating -= 1; } if (genopct < failedGenoCut){ rating -= 2; } if (pval < hwCut){ rating -= 4; } if (menderr > numMendErrCut){ rating -= 8; } if (rating == 0){ rating = 1; } return rating; } |
return "To be implemented:errorCode:" + errorCode; | return ErrorCatalog.getMessage(errorCode, values); | public String getMessage(){ // TODO: look in the message catalog and get an error string return "To be implemented:errorCode:" + errorCode; } |
if (Constants.BETA_VERSION > 0){ UpdateChecker betaUc; betaUc = new UpdateChecker(); try { betaUc.checkForUpdate(); } catch(IOException ioe) { } if (betaUc.isNewVersionAvailable()){ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",betaUc); betaUdp.pack(); betaUdp.setVisible(true); } } | public static void main(String[] args) { //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { try { UIManager.put("EditorPane.selectionBackground",Color.lightGray); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } window = new HaploView(); //setup view object window.setTitle(TITLE_STRING); window.setSize(1024,768); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); final SwingWorker worker = showUpdatePanel(); worker.start(); //parse command line stuff for input files or prompt data dialog String[] inputArray = new String[3]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = null; window.readGenotypes(inputArray, HAPS_FILE, false); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = null; window.readGenotypes(inputArray, PED_FILE, false); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = null; inputArray[2] = null; window.readGenotypes(inputArray, HMP_FILE, false); }else if (argParser.getPlinkFileName() != null){ inputArray[0] = argParser.getPlinkFileName(); inputArray[1] = argParser.getMapFileName(); inputArray[2] = null; window.readWGA(inputArray); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
|
if(uc != null) { | if(uc != null && Constants.BETA_VERSION == 0) { | public static SwingWorker showUpdatePanel(){ final SwingWorker worker; worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); try { uc.checkForUpdate(); } catch(IOException ioe) { //this means we couldnt connect but we want it to die quietly } return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } }; return worker; } |
if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); | udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); | public static SwingWorker showUpdatePanel(){ final SwingWorker worker; worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); try { uc.checkForUpdate(); } catch(IOException ioe) { //this means we couldnt connect but we want it to die quietly } return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } }; return worker; } |
java.util.Timer updateTimer = new java.util.Timer(); updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } | java.util.Timer updateTimer = new java.util.Timer(); updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); | public static SwingWorker showUpdatePanel(){ final SwingWorker worker; worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); try { uc.checkForUpdate(); } catch(IOException ioe) { //this means we couldnt connect but we want it to die quietly } return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } }; return worker; } |
if(uc != null) { | if(uc != null && Constants.BETA_VERSION == 0) { | public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } |
if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); | udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); | public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } |
java.util.Timer updateTimer = new java.util.Timer(); updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } | java.util.Timer updateTimer = new java.util.Timer(); updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); | public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); if (Constants.BETA_VERSION == 0){ udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new java.util.Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); }else{ UpdateDisplayDialog betaUdp = new UpdateDisplayDialog(window,"Update Check",uc); betaUdp.pack(); betaUdp.setVisible(true); } } } } |
JMenuItem clearItem = new JMenuItem("Clear Recent Files"); clearItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { recent.clear(); } }); | private void init() throws ArchitectException { int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); prefs = PrefsUtils.getUserPrefsNode(architectSession); CoreUserSettings us; // must be done right away, because a static // initializer in this class effects BeanUtils // behaviour which the XML Digester relies // upon heavily //TypeMap.getInstance(); contentPane = (JComponent)getContentPane(); try { ConfigFile cf = ConfigFile.getDefaultInstance(); us = cf.read(getArchitectSession()); architectSession.setUserSettings(us); sprefs = architectSession.getUserSettings().getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } while (!us.isPlDotIniPathValid()) { String message; String[] options = new String[] {"Browse", "Create"}; if (us.getPlDotIniPath() == null) { message = "location is not set"; } else if (new File(us.getPlDotIniPath()).isFile()) { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n could not be read"; } else { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n does not exist"; } int choice = JOptionPane.showOptionDialog(null, // blocking wait "The Architect keeps its list of database connections" + "\nin a file called PL.INI. Your PL.INI "+message+"." + "\n\nYou can browse for an existing PL.INI file on your system" + "\nor allow the Architect to create a new one in your home directory." + "\n\nHint: If you are a Power*Loader Suite user, you should browse for" + "\nan existing PL.INI in your Power*Loader installation directory.", "Missing PL.INI", 0, JOptionPane.INFORMATION_MESSAGE, null, options, null); File newPlIniFile; if (choice == JOptionPane.CLOSED_OPTION) { throw new ArchitectException("Can't start without a pl.ini file"); } else if (choice == 0) { JFileChooser fc = new JFileChooser(); fc.setFileFilter(ASUtils.INI_FILE_FILTER); fc.setDialogTitle("Locate your PL.INI file"); int fcChoice = fc.showOpenDialog(null); // blocking wait if (fcChoice == JFileChooser.APPROVE_OPTION) { newPlIniFile = fc.getSelectedFile(); } else { newPlIniFile = null; } } else if (choice == 1) { newPlIniFile = new File(System.getProperty("user.home"), "pl.ini"); } else throw new ArchitectException("Unexpected return from JOptionPane.showOptionDialog to get pl.ini"); if (newPlIniFile != null) try { newPlIniFile.createNewFile(); us.setPlDotIniPath(newPlIniFile.getPath()); } catch (IOException e1) { logger.error("Caught IO exception while creating empty PL.INI at \"" +newPlIniFile.getPath()+"\"", e1); JOptionPane.showMessageDialog(null, "Failed to create file \""+newPlIniFile.getPath()+"\":\n"+e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } // Create actions aboutAction = new AboutAction(); Action helpAction = new HelpAction(); newProjectAction = new AbstractAction("New Project", ASUtils.createJLFIcon("general/New","New Project",sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { if (promptForUnsavedModifications()) { try { prefs.putInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); closeProject(getProject()); setProject(new SwingUIProject("New Project")); logger.debug("Glass pane is "+getGlassPane()); } catch (Exception ex) { JOptionPane.showMessageDialog(ArchitectFrame.this, "Can't create new project: "+ex.getMessage()); logger.error("Got exception while creating new project", ex); } } } }; newProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "New"); newProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, accelMask)); recent = new RecentMenu(this) { @Override public void loadFile(String fileName) throws IOException { File f = new File(fileName); LoadFileWorker worker; try { worker = new LoadFileWorker(f,null); new Thread(worker).start(); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( ArchitectFrame.this, "File not found: "+f.getPath()); } catch (Exception e1) { ASUtils.showExceptionDialog( ArchitectFrame.this, "Error loading file", e1); } } }; openProjectAction = new OpenProjectAction(recent); JMenuItem clearItem = new JMenuItem("Clear Recent Files"); clearItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { recent.clear(); } }); saveProjectAction = new AbstractAction("Save Project", ASUtils.createJLFIcon("general/Save", "Save Project", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(false, true); } }; saveProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save"); saveProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, accelMask)); saveProjectAsAction = new AbstractAction("Save Project As...", ASUtils.createJLFIcon("general/SaveAs", "Save Project As...", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(true, true); } }; saveProjectAsAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save As"); prefAction = new PreferencesAction(); projectSettingsAction = new ProjectSettingsAction(); projectSettingsAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, accelMask)); printAction = new PrintAction(); printAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, accelMask)); zoomInAction = new ZoomAction(ZOOM_STEP); zoomOutAction = new ZoomAction(ZOOM_STEP * -1.0); zoomNormalAction = new AbstractAction("Reset Zoom", ASUtils.createJLFIcon("general/Zoom", "Reset Zoom", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); } }; zoomNormalAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Reset Zoom"); zoomAllAction = new AbstractAction("Zoom to fit", ASUtils.createJLFIcon("general/Zoom", "Reset Zoom", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } }; zoomAllAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Zoom to fit"); undoAction = new UndoAction(); redoAction = new RedoAction(); autoLayoutAction = new AutoLayoutAction(); autoLayout = new FruchtermanReingoldForceLayout(); autoLayoutAction.setLayout(autoLayout); exportDDLAction = new ExportDDLAction(); compareDMAction = new CompareDMAction(); exportPLTransAction = new ExportPLTransAction(); exportPLJobXMLAction = new ExportPLJobXMLAction(); quickStartAction = new QuickStartAction(); Action exportCSVAction = new AbstractAction("Export CSV File") { public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }; Action mappingReportAction = new AbstractAction("Visual Mapping Report") { // TODO convert this to an architect pane public void actionPerformed(ActionEvent e) { try { final MappingReport mr ; final List<SQLTable> selectedTables; if (playpen.getSelectedTables().size() == 0) { selectedTables = new ArrayList(playpen.getTables()); } else { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(ArchitectFrame.getMainInstance(),"View only the "+playpen.getSelectedTables().size()+" selected tables","Show Mapping",JOptionPane.YES_NO_OPTION)) { selectedTables = new ArrayList<SQLTable>(); for(TablePane tp: playpen.getSelectedTables()) { selectedTables.add(tp.getModel()); } } else { selectedTables = new ArrayList(playpen.getTables()); } } mr = new MappingReport(selectedTables); final JFrame f = new JFrame("Mapping Report"); // You call this a radar?? -- No sir, we call it Mr. Panel. JPanel mrPanel = new JPanel() { protected void paintComponent(java.awt.Graphics g) { super.paintComponent(g); try { mr.drawHighLevelReport((Graphics2D) g,null); } catch (ArchitectException e1) { logger.error("ArchitectException while generating mapping diagram", e1); ASUtils.showExceptionDialog(ArchitectFrame.this, "Couldn't generate mapping diagram", e1); } } }; mrPanel.setDoubleBuffered(true); mrPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mrPanel.setPreferredSize(mr.getRequiredSize()); mrPanel.setOpaque(true); mrPanel.setBackground(Color.WHITE); ButtonBarBuilder buttonBar = new ButtonBarBuilder(); JButton csv = new JButton(new AbstractAction(){ public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(selectedTables); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); csv.setText("Export CSV"); buttonBar.addGriddedGrowing(csv); ExportPLTransAction plTransaction = new ExportPLTransAction(); JButton pl = new JButton(plTransaction); plTransaction.setExportingTables(selectedTables); pl.setText("Export PL Transaction"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(pl); JButton close = new JButton(new AbstractAction(){ public void actionPerformed(ActionEvent e) { f.setVisible(false); } }); close.setText("Close"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(close); JPanel basePane = new JPanel(new BorderLayout(5,5)); basePane.add(new JScrollPane(mrPanel),BorderLayout.CENTER); basePane.add(buttonBar.getPanel(),BorderLayout.SOUTH); f.setContentPane(basePane); f.pack(); ASUtils.centre(f); f.setVisible(true); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }; deleteSelectedAction = new DeleteSelectedAction(); createIdentifyingRelationshipAction = new CreateRelationshipAction(true); createNonIdentifyingRelationshipAction = new CreateRelationshipAction(false); editRelationshipAction = new EditRelationshipAction(); createTableAction = new CreateTableAction(); editColumnAction = new EditColumnAction(); insertColumnAction = new InsertColumnAction(); editTableAction = new EditTableAction(); searchReplaceAction = new SearchReplaceAction(); searchReplaceAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, accelMask)); selectAllAction = new SelectAllAction(); selectAllAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, accelMask)); /* profiling stuff */ profileAction = new ProfilePanelAction(); //viewProfileAction = new ViewProfileAction(); not being used for second architect release menuBar = new JMenuBar(); //Settingup JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newProjectAction); fileMenu.add(openProjectAction); fileMenu.add(recent); fileMenu.add(clearItem); fileMenu.addSeparator(); fileMenu.add(saveProjectAction); fileMenu.add(saveProjectAsAction); fileMenu.add(printAction); fileMenu.addSeparator(); if (!MAC_OS_X) { fileMenu.add(prefAction); } fileMenu.add(saveSettingsAction); fileMenu.add(projectSettingsAction); if (!MAC_OS_X) { fileMenu.addSeparator(); fileMenu.add(exitAction); } menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoAction); editMenu.add(redoAction); editMenu.addSeparator(); editMenu.add(selectAllAction); editMenu.addSeparator(); editMenu.add(searchReplaceAction); menuBar.add(editMenu); // the connections menu is set up when a new project is created (because it depends on the current DBTree) connectionsMenu = new JMenu("Connections"); connectionsMenu.setMnemonic('c'); menuBar.add(connectionsMenu); JMenu etlMenu = new JMenu("ETL"); etlMenu.setMnemonic('l'); JMenu etlSubmenuOne = new JMenu("Power*Loader"); etlSubmenuOne.add(exportPLTransAction); // Todo add in ability to run the engine from the architect /* Action runPL = new RunPLAction(); runPL.putValue(Action.NAME,"Run Power*Loader"); etlSubmenuOne.add(runPL); */ etlSubmenuOne.add(exportPLJobXMLAction); etlSubmenuOne.add(quickStartAction); etlMenu.add(etlSubmenuOne); etlMenu.add(exportCSVAction); etlMenu.add(mappingReportAction); menuBar.add(etlMenu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(exportDDLAction); toolsMenu.add(compareDMAction); toolsMenu.add(new SQLRunnerAction()); menuBar.add(toolsMenu); JMenu profileMenu = new JMenu("Profile"); profileMenu.setMnemonic('p'); profileMenu.add(profileAction); //profileMenu.add(viewProfileAction);not being used for second architect release menuBar.add(profileMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); if (!MAC_OS_X) { helpMenu.add(aboutAction); helpMenu.addSeparator(); } helpMenu.add(helpAction); menuBar.add(helpMenu); setJMenuBar(menuBar); projectBar = new JToolBar(JToolBar.HORIZONTAL); ppBar = new JToolBar(JToolBar.VERTICAL); projectBar.add(newProjectAction); projectBar.add(openProjectAction); projectBar.add(saveProjectAction); projectBar.addSeparator(); projectBar.add(printAction); projectBar.addSeparator(); projectBar.add(undoAction); projectBar.add(redoAction); projectBar.addSeparator(); projectBar.add(exportDDLAction); projectBar.add(compareDMAction); projectBar.addSeparator(); projectBar.add(autoLayoutAction); projectBar.add(profileAction); projectBar.addSeparator(); projectBar.add(helpAction); projectBar.setToolTipText("Project Toolbar"); projectBar.setName("Project Toolbar"); JButton tempButton = null; // shared actions need to report where they are coming from ppBar.setToolTipText("PlayPen Toolbar"); ppBar.setName("PlayPen ToolBar"); ppBar.add(zoomInAction); ppBar.add(zoomOutAction); ppBar.add(zoomNormalAction); ppBar.add(zoomAllAction); ppBar.addSeparator(); tempButton = ppBar.add(deleteSelectedAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(createTableAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(insertColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); tempButton = ppBar.add(editColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); ppBar.add(createNonIdentifyingRelationshipAction); ppBar.add(createIdentifyingRelationshipAction); tempButton = ppBar.add(editRelationshipAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); Container projectBarPane = getContentPane(); projectBarPane.setLayout(new BorderLayout()); projectBarPane.add(projectBar, BorderLayout.NORTH); JPanel cp = new JPanel(new BorderLayout()); cp.add(ppBar, BorderLayout.EAST); projectBarPane.add(cp, BorderLayout.CENTER); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); cp.add(splitPane, BorderLayout.CENTER); logger.debug("Added splitpane to content pane"); splitPane.setDividerLocation(prefs.getInt(SwingUserSettings.DIVIDER_LOCATION,150)); Rectangle bounds = new Rectangle(); bounds.x = prefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = prefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = prefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = prefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); addWindowListener(afWindowListener = new ArchitectFrameWindowListener()); setProject(new SwingUIProject("New Project")); } |
|
fileMenu.add(recent); fileMenu.add(clearItem); | fileMenu.add(recent); | private void init() throws ArchitectException { int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); prefs = PrefsUtils.getUserPrefsNode(architectSession); CoreUserSettings us; // must be done right away, because a static // initializer in this class effects BeanUtils // behaviour which the XML Digester relies // upon heavily //TypeMap.getInstance(); contentPane = (JComponent)getContentPane(); try { ConfigFile cf = ConfigFile.getDefaultInstance(); us = cf.read(getArchitectSession()); architectSession.setUserSettings(us); sprefs = architectSession.getUserSettings().getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } while (!us.isPlDotIniPathValid()) { String message; String[] options = new String[] {"Browse", "Create"}; if (us.getPlDotIniPath() == null) { message = "location is not set"; } else if (new File(us.getPlDotIniPath()).isFile()) { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n could not be read"; } else { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n does not exist"; } int choice = JOptionPane.showOptionDialog(null, // blocking wait "The Architect keeps its list of database connections" + "\nin a file called PL.INI. Your PL.INI "+message+"." + "\n\nYou can browse for an existing PL.INI file on your system" + "\nor allow the Architect to create a new one in your home directory." + "\n\nHint: If you are a Power*Loader Suite user, you should browse for" + "\nan existing PL.INI in your Power*Loader installation directory.", "Missing PL.INI", 0, JOptionPane.INFORMATION_MESSAGE, null, options, null); File newPlIniFile; if (choice == JOptionPane.CLOSED_OPTION) { throw new ArchitectException("Can't start without a pl.ini file"); } else if (choice == 0) { JFileChooser fc = new JFileChooser(); fc.setFileFilter(ASUtils.INI_FILE_FILTER); fc.setDialogTitle("Locate your PL.INI file"); int fcChoice = fc.showOpenDialog(null); // blocking wait if (fcChoice == JFileChooser.APPROVE_OPTION) { newPlIniFile = fc.getSelectedFile(); } else { newPlIniFile = null; } } else if (choice == 1) { newPlIniFile = new File(System.getProperty("user.home"), "pl.ini"); } else throw new ArchitectException("Unexpected return from JOptionPane.showOptionDialog to get pl.ini"); if (newPlIniFile != null) try { newPlIniFile.createNewFile(); us.setPlDotIniPath(newPlIniFile.getPath()); } catch (IOException e1) { logger.error("Caught IO exception while creating empty PL.INI at \"" +newPlIniFile.getPath()+"\"", e1); JOptionPane.showMessageDialog(null, "Failed to create file \""+newPlIniFile.getPath()+"\":\n"+e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } // Create actions aboutAction = new AboutAction(); Action helpAction = new HelpAction(); newProjectAction = new AbstractAction("New Project", ASUtils.createJLFIcon("general/New","New Project",sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { if (promptForUnsavedModifications()) { try { prefs.putInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); closeProject(getProject()); setProject(new SwingUIProject("New Project")); logger.debug("Glass pane is "+getGlassPane()); } catch (Exception ex) { JOptionPane.showMessageDialog(ArchitectFrame.this, "Can't create new project: "+ex.getMessage()); logger.error("Got exception while creating new project", ex); } } } }; newProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "New"); newProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, accelMask)); recent = new RecentMenu(this) { @Override public void loadFile(String fileName) throws IOException { File f = new File(fileName); LoadFileWorker worker; try { worker = new LoadFileWorker(f,null); new Thread(worker).start(); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( ArchitectFrame.this, "File not found: "+f.getPath()); } catch (Exception e1) { ASUtils.showExceptionDialog( ArchitectFrame.this, "Error loading file", e1); } } }; openProjectAction = new OpenProjectAction(recent); JMenuItem clearItem = new JMenuItem("Clear Recent Files"); clearItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { recent.clear(); } }); saveProjectAction = new AbstractAction("Save Project", ASUtils.createJLFIcon("general/Save", "Save Project", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(false, true); } }; saveProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save"); saveProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, accelMask)); saveProjectAsAction = new AbstractAction("Save Project As...", ASUtils.createJLFIcon("general/SaveAs", "Save Project As...", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(true, true); } }; saveProjectAsAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save As"); prefAction = new PreferencesAction(); projectSettingsAction = new ProjectSettingsAction(); projectSettingsAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, accelMask)); printAction = new PrintAction(); printAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, accelMask)); zoomInAction = new ZoomAction(ZOOM_STEP); zoomOutAction = new ZoomAction(ZOOM_STEP * -1.0); zoomNormalAction = new AbstractAction("Reset Zoom", ASUtils.createJLFIcon("general/Zoom", "Reset Zoom", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); } }; zoomNormalAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Reset Zoom"); zoomAllAction = new AbstractAction("Zoom to fit", ASUtils.createJLFIcon("general/Zoom", "Reset Zoom", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } }; zoomAllAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Zoom to fit"); undoAction = new UndoAction(); redoAction = new RedoAction(); autoLayoutAction = new AutoLayoutAction(); autoLayout = new FruchtermanReingoldForceLayout(); autoLayoutAction.setLayout(autoLayout); exportDDLAction = new ExportDDLAction(); compareDMAction = new CompareDMAction(); exportPLTransAction = new ExportPLTransAction(); exportPLJobXMLAction = new ExportPLJobXMLAction(); quickStartAction = new QuickStartAction(); Action exportCSVAction = new AbstractAction("Export CSV File") { public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }; Action mappingReportAction = new AbstractAction("Visual Mapping Report") { // TODO convert this to an architect pane public void actionPerformed(ActionEvent e) { try { final MappingReport mr ; final List<SQLTable> selectedTables; if (playpen.getSelectedTables().size() == 0) { selectedTables = new ArrayList(playpen.getTables()); } else { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(ArchitectFrame.getMainInstance(),"View only the "+playpen.getSelectedTables().size()+" selected tables","Show Mapping",JOptionPane.YES_NO_OPTION)) { selectedTables = new ArrayList<SQLTable>(); for(TablePane tp: playpen.getSelectedTables()) { selectedTables.add(tp.getModel()); } } else { selectedTables = new ArrayList(playpen.getTables()); } } mr = new MappingReport(selectedTables); final JFrame f = new JFrame("Mapping Report"); // You call this a radar?? -- No sir, we call it Mr. Panel. JPanel mrPanel = new JPanel() { protected void paintComponent(java.awt.Graphics g) { super.paintComponent(g); try { mr.drawHighLevelReport((Graphics2D) g,null); } catch (ArchitectException e1) { logger.error("ArchitectException while generating mapping diagram", e1); ASUtils.showExceptionDialog(ArchitectFrame.this, "Couldn't generate mapping diagram", e1); } } }; mrPanel.setDoubleBuffered(true); mrPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mrPanel.setPreferredSize(mr.getRequiredSize()); mrPanel.setOpaque(true); mrPanel.setBackground(Color.WHITE); ButtonBarBuilder buttonBar = new ButtonBarBuilder(); JButton csv = new JButton(new AbstractAction(){ public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(selectedTables); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); csv.setText("Export CSV"); buttonBar.addGriddedGrowing(csv); ExportPLTransAction plTransaction = new ExportPLTransAction(); JButton pl = new JButton(plTransaction); plTransaction.setExportingTables(selectedTables); pl.setText("Export PL Transaction"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(pl); JButton close = new JButton(new AbstractAction(){ public void actionPerformed(ActionEvent e) { f.setVisible(false); } }); close.setText("Close"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(close); JPanel basePane = new JPanel(new BorderLayout(5,5)); basePane.add(new JScrollPane(mrPanel),BorderLayout.CENTER); basePane.add(buttonBar.getPanel(),BorderLayout.SOUTH); f.setContentPane(basePane); f.pack(); ASUtils.centre(f); f.setVisible(true); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }; deleteSelectedAction = new DeleteSelectedAction(); createIdentifyingRelationshipAction = new CreateRelationshipAction(true); createNonIdentifyingRelationshipAction = new CreateRelationshipAction(false); editRelationshipAction = new EditRelationshipAction(); createTableAction = new CreateTableAction(); editColumnAction = new EditColumnAction(); insertColumnAction = new InsertColumnAction(); editTableAction = new EditTableAction(); searchReplaceAction = new SearchReplaceAction(); searchReplaceAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, accelMask)); selectAllAction = new SelectAllAction(); selectAllAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, accelMask)); /* profiling stuff */ profileAction = new ProfilePanelAction(); //viewProfileAction = new ViewProfileAction(); not being used for second architect release menuBar = new JMenuBar(); //Settingup JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newProjectAction); fileMenu.add(openProjectAction); fileMenu.add(recent); fileMenu.add(clearItem); fileMenu.addSeparator(); fileMenu.add(saveProjectAction); fileMenu.add(saveProjectAsAction); fileMenu.add(printAction); fileMenu.addSeparator(); if (!MAC_OS_X) { fileMenu.add(prefAction); } fileMenu.add(saveSettingsAction); fileMenu.add(projectSettingsAction); if (!MAC_OS_X) { fileMenu.addSeparator(); fileMenu.add(exitAction); } menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoAction); editMenu.add(redoAction); editMenu.addSeparator(); editMenu.add(selectAllAction); editMenu.addSeparator(); editMenu.add(searchReplaceAction); menuBar.add(editMenu); // the connections menu is set up when a new project is created (because it depends on the current DBTree) connectionsMenu = new JMenu("Connections"); connectionsMenu.setMnemonic('c'); menuBar.add(connectionsMenu); JMenu etlMenu = new JMenu("ETL"); etlMenu.setMnemonic('l'); JMenu etlSubmenuOne = new JMenu("Power*Loader"); etlSubmenuOne.add(exportPLTransAction); // Todo add in ability to run the engine from the architect /* Action runPL = new RunPLAction(); runPL.putValue(Action.NAME,"Run Power*Loader"); etlSubmenuOne.add(runPL); */ etlSubmenuOne.add(exportPLJobXMLAction); etlSubmenuOne.add(quickStartAction); etlMenu.add(etlSubmenuOne); etlMenu.add(exportCSVAction); etlMenu.add(mappingReportAction); menuBar.add(etlMenu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(exportDDLAction); toolsMenu.add(compareDMAction); toolsMenu.add(new SQLRunnerAction()); menuBar.add(toolsMenu); JMenu profileMenu = new JMenu("Profile"); profileMenu.setMnemonic('p'); profileMenu.add(profileAction); //profileMenu.add(viewProfileAction);not being used for second architect release menuBar.add(profileMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); if (!MAC_OS_X) { helpMenu.add(aboutAction); helpMenu.addSeparator(); } helpMenu.add(helpAction); menuBar.add(helpMenu); setJMenuBar(menuBar); projectBar = new JToolBar(JToolBar.HORIZONTAL); ppBar = new JToolBar(JToolBar.VERTICAL); projectBar.add(newProjectAction); projectBar.add(openProjectAction); projectBar.add(saveProjectAction); projectBar.addSeparator(); projectBar.add(printAction); projectBar.addSeparator(); projectBar.add(undoAction); projectBar.add(redoAction); projectBar.addSeparator(); projectBar.add(exportDDLAction); projectBar.add(compareDMAction); projectBar.addSeparator(); projectBar.add(autoLayoutAction); projectBar.add(profileAction); projectBar.addSeparator(); projectBar.add(helpAction); projectBar.setToolTipText("Project Toolbar"); projectBar.setName("Project Toolbar"); JButton tempButton = null; // shared actions need to report where they are coming from ppBar.setToolTipText("PlayPen Toolbar"); ppBar.setName("PlayPen ToolBar"); ppBar.add(zoomInAction); ppBar.add(zoomOutAction); ppBar.add(zoomNormalAction); ppBar.add(zoomAllAction); ppBar.addSeparator(); tempButton = ppBar.add(deleteSelectedAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(createTableAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(insertColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); tempButton = ppBar.add(editColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); ppBar.add(createNonIdentifyingRelationshipAction); ppBar.add(createIdentifyingRelationshipAction); tempButton = ppBar.add(editRelationshipAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); Container projectBarPane = getContentPane(); projectBarPane.setLayout(new BorderLayout()); projectBarPane.add(projectBar, BorderLayout.NORTH); JPanel cp = new JPanel(new BorderLayout()); cp.add(ppBar, BorderLayout.EAST); projectBarPane.add(cp, BorderLayout.CENTER); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); cp.add(splitPane, BorderLayout.CENTER); logger.debug("Added splitpane to content pane"); splitPane.setDividerLocation(prefs.getInt(SwingUserSettings.DIVIDER_LOCATION,150)); Rectangle bounds = new Rectangle(); bounds.x = prefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = prefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = prefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = prefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); addWindowListener(afWindowListener = new ArchitectFrameWindowListener()); setProject(new SwingUIProject("New Project")); } |
ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); | final MappingReport mr ; final List<SQLTable> selectedTables; if (playpen.getSelectedTables().size() == 0) { selectedTables = new ArrayList(playpen.getTables()); } else { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(ArchitectFrame.getMainInstance(),"View only the "+playpen.getSelectedTables().size()+" selected tables","Show Mapping",JOptionPane.YES_NO_OPTION)) { selectedTables = new ArrayList<SQLTable>(); for(TablePane tp: playpen.getSelectedTables()) { selectedTables.add(tp.getModel()); } } else { selectedTables = new ArrayList(playpen.getTables()); } } mr = new MappingReport(selectedTables); | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
File file = null; | final JFrame f = new JFrame("Mapping Report"); | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); | JPanel mrPanel = new JPanel() { protected void paintComponent(java.awt.Graphics g) { | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } | super.paintComponent(g); try { mr.drawHighLevelReport((Graphics2D) g,null); } catch (ArchitectException e1) { logger.error("ArchitectException while generating mapping diagram", e1); ASUtils.showExceptionDialog(ArchitectFrame.this, "Couldn't generate mapping diagram", e1); } } }; mrPanel.setDoubleBuffered(true); mrPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mrPanel.setPreferredSize(mr.getRequiredSize()); mrPanel.setOpaque(true); mrPanel.setBackground(Color.WHITE); ButtonBarBuilder buttonBar = new ButtonBarBuilder(); JButton csv = new JButton(new AbstractAction(){ | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(selectedTables); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); csv.setText("Export CSV"); buttonBar.addGriddedGrowing(csv); ExportPLTransAction plTransaction = new ExportPLTransAction(); JButton pl = new JButton(plTransaction); plTransaction.setExportingTables(selectedTables); pl.setText("Export PL Transaction"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(pl); JButton close = new JButton(new AbstractAction(){ public void actionPerformed(ActionEvent e) { f.setVisible(false); } }); close.setText("Close"); buttonBar.addRelatedGap(); buttonBar.addGriddedGrowing(close); JPanel basePane = new JPanel(new BorderLayout(5,5)); basePane.add(new JScrollPane(mrPanel),BorderLayout.CENTER); basePane.add(buttonBar.getPanel(),BorderLayout.SOUTH); f.setContentPane(basePane); f.pack(); ASUtils.centre(f); f.setVisible(true); | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
try { ExportCSV export = new ExportCSV(selectedTables); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } | f.setVisible(false); | public void actionPerformed(ActionEvent e) { try { ExportCSV export = new ExportCSV(selectedTables); File file = null; JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } |
recent.clear(); } | saveOrSaveAs(false, true); } | public void actionPerformed(ActionEvent e) { recent.clear(); } |
saveOrSaveAs(false, true); | saveOrSaveAs(true, true); | public void actionPerformed(ActionEvent e) { saveOrSaveAs(false, true); } |
saveOrSaveAs(true, true); | playpen.setZoom(1.0); | public void actionPerformed(ActionEvent e) { saveOrSaveAs(true, true); } |
playpen.setZoom(1.0); | Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } | public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); } |
if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } | public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); } |
|
Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } | try { ExportCSV export = new ExportCSV(getProject().getPlayPen().getDatabase().getTables()); | public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } |
if ( rect == null ) return; | File file = null; | public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } |
double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; | JFileChooser fileDialog = new JFileChooser(); fileDialog.setSelectedFile(new File("map.csv")); | public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } |
playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } | if (fileDialog.showSaveDialog(ArchitectFrame.getMainInstance()) == JFileChooser.APPROVE_OPTION){ file = fileDialog.getSelectedFile(); } else { return; } FileWriter output = null; output = new FileWriter(file); output.write(export.getCSVMapping()); output.flush(); } catch (IOException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } | public void actionPerformed(ActionEvent e) { Rectangle rect = null; if ( playpen != null ) { for (int i = 0; i < playpen.getContentPane().getComponentCount(); i++) { PlayPenComponent ppc = playpen.getContentPane().getComponent(i); if ( rect == null ) { rect = new Rectangle(ppc.getLocation(),ppc.getSize()); } else { rect.add(ppc.getBounds()); } } } if ( rect == null ) return; double zoom = Math.min(playpen.getViewportSize().getHeight()/rect.height, playpen.getViewportSize().getWidth()/rect.width); zoom *= 0.90; playpen.setZoom(zoom); playpen.scrollRectToVisible(playpen.zoomRect(rect)); } |
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); logger.debug("current motion threshold is: " + System.getProperty("awt.dnd.drag.threshold")); System.setProperty("awt.dnd.drag.threshold","10"); logger.debug("new motion threshold is: " + System.getProperty("awt.dnd.drag.threshold")); getMainInstance().macOSXRegistration(); getMainInstance().setVisible(true); LoadFileWorker worker; if (openFile != null) { try { worker = getMainInstance().new LoadFileWorker(openFile,getMainInstance().recent); new Thread(worker).start(); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( getMainInstance(), "File not found: "+openFile.getPath()); } catch (Exception e1) { ASUtils.showExceptionDialog( getMainInstance(), "Error loading file", e1); } } } | try { lastSaveOpSuccessful = false; project.setSaveInProgress(true); project.save(finalSeparateThread ? pm : null); lastSaveOpSuccessful = true; JOptionPane.showMessageDialog(ArchitectFrame.this, "Save successful"); } catch (Exception ex) { lastSaveOpSuccessful = false; JOptionPane.showMessageDialog (ArchitectFrame.this, "Can't save project: "+ex.getMessage()); logger.error("Got exception while saving project", ex); } finally { project.setSaveInProgress(false); } } | public void run() { Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); // this doesn't appear to have any effect on the motion threshold // in the Playpen, but it does seem to work on the DBTree... logger.debug("current motion threshold is: " + System.getProperty("awt.dnd.drag.threshold")); System.setProperty("awt.dnd.drag.threshold","10"); logger.debug("new motion threshold is: " + System.getProperty("awt.dnd.drag.threshold")); getMainInstance().macOSXRegistration(); getMainInstance().setVisible(true); LoadFileWorker worker; if (openFile != null) { try { worker = getMainInstance().new LoadFileWorker(openFile,getMainInstance().recent); new Thread(worker).start(); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( getMainInstance(), "File not found: "+openFile.getPath()); } catch (Exception e1) { ASUtils.showExceptionDialog( getMainInstance(), "Error loading file", e1); } } } |
logger.debug("bounds: " + cbounds); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
|
logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
|
Dimension min = getMinimumSize(); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
|
logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); | Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, getMinimumSize().width) * zoom), (int) ((double) Math.max(maxy - miny, getMinimumSize().height) * zoom)); Dimension vpSize = getViewportSize(); Dimension ppSize = null; | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } | if (vpSize != null) { ppSize = new Dimension(Math.max(usedSpace.width, vpSize.width), Math.max(usedSpace.height, vpSize.height)); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; | logger.debug("minsize is: " + getMinimumSize()); logger.debug("unzoomed userDim is: " + userDim); logger.debug("zoom="+zoom+",usedSpace size is " + usedSpace); if (ppSize != null) { logger.debug("preferred size is ppSize (viewport size was null): " + ppSize); return ppSize; } else { logger.debug("preferred size is usedSpace: " + usedSpace); return usedSpace; } | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); logger.debug("bounds: " + cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } } Dimension min = getMinimumSize(); Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); logger.debug("zoom="+zoom+",usedSpace size is viewport size: " + usedSpace); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width && vpSize.height > usedSpace.height) { logger.debug("preferered size is viewport?: " + vpSize); return vpSize; } } // default logger.debug("preferred size is usedSpace?: " + usedSpace); return usedSpace; } |
registerBeanFactory( "progressBar", JProgressBar.class ); | protected void registerFactories() { registerBeanFactory( "button", JButton.class ); registerBeanFactory( "buttonGroup", ButtonGroup.class ); registerBeanFactory( "checkBox", JCheckBox.class ); registerBeanFactory( "checkBoxMenuItem", JCheckBoxMenuItem.class ); registerBeanFactory( "comboBox", JComboBox.class ); // how to add content there ? // Have a ComboBoxModel (just one should have a Table or Tree Model objects) ? // can the element control it's children ? // but children should also be able to be any component (as Swing comps. are all container) registerBeanFactory( "desktopPane", JDesktopPane.class ); registerBeanFactory( "dialog", JDialog.class ); registerBeanFactory( "editorPane", JEditorPane.class ); registerBeanFactory( "fileChooser", JFileChooser.class ); registerBeanFactory( "frame", JFrame.class ); registerBeanFactory( "internalFrame", JInternalFrame.class ); registerBeanFactory( "label", JLabel.class ); registerBeanFactory( "list", JList.class ); registerBeanFactory( "menu", JMenu.class ); registerBeanFactory( "menuBar", JMenuBar.class ); registerBeanFactory( "menuItem", JMenuItem.class ); registerBeanFactory( "panel", JPanel.class ); registerBeanFactory( "passwordField", JPasswordField.class ); registerBeanFactory( "popupMenu", JPopupMenu.class ); registerBeanFactory( "radioButton", JRadioButton.class ); registerBeanFactory( "radioButtonMenuItem", JRadioButtonMenuItem.class ); registerBeanFactory( "optionPane", JOptionPane.class ); registerBeanFactory( "scrollPane", JScrollPane.class ); registerBeanFactory( "separator", JSeparator.class ); registerFactory( "splitPane", new Factory() { public Object newInstance() { JSplitPane answer = new JSplitPane(); answer.setLeftComponent(null); answer.setRightComponent(null); answer.setTopComponent(null); answer.setBottomComponent(null); return answer; } } ); // Box related layout components registerFactory( "hbox", new Factory() { public Object newInstance() { return Box.createHorizontalBox(); } } ); registerFactory( "vbox", new Factory() { public Object newInstance() { return Box.createVerticalBox(); } } ); registerBeanFactory( "tabbedPane", JTabbedPane.class ); registerBeanFactory( "table", JTable.class ); registerBeanFactory( "textArea", JTextArea.class ); registerBeanFactory( "textField", JTextField.class ); registerBeanFactory( "toggleButton", JToggleButton.class ); registerBeanFactory( "tree", JTree.class ); registerBeanFactory( "toolBar", JToolBar.class ); } |
|
getBody().run(context, new XMLOutput( handler ) ); | invokeBody( new XMLOutput( handler ) ); | public void doTag(final XMLOutput output) throws Exception { if ( verifier == null ) { throw new MissingAttributeException("verifier"); } boolean valid = false; // evaluate the body using the current Verifier if ( errorHandler != null ) { // we are redirecting errors to another handler // so just filter the body VerifierFilter filter = verifier.getVerifierFilter(); // now install the current output in the filter chain... // #### ContentHandler handler = filter.getContentHandler(); handler.startDocument(); getBody().run(context, new XMLOutput( handler ) ); handler.endDocument(); valid = filter.isValid(); } else { // outputting the errors to the current output verifier.setErrorHandler( new ErrorHandler() { public void error(SAXParseException exception) throws SAXException { outputException(output, "error", exception); } public void fatalError(SAXParseException exception) throws SAXException { outputException(output, "fatalError", exception); } public void warning(SAXParseException exception) throws SAXException { outputException(output, "warning", exception); } } ); VerifierHandler handler = verifier.getVerifierHandler(); handler.startDocument(); getBody().run(context, new XMLOutput( handler ) ); handler.endDocument(); valid = handler.isValid(); } if (var != null ) { Boolean value = (valid) ? Boolean.TRUE : Boolean.FALSE; context.setVariable(var, value); } } |
if ( exportImage.getSampleModel().getSampleSize( 0 ) == 16 ) { double[] subtract = new double[1]; subtract[0] = 0; double[] divide = new double[1]; divide[0] = 1./256.; ParameterBlock pbRescale = new ParameterBlock(); pbRescale.add(divide); pbRescale.add(subtract); pbRescale.addSource( exportImage ); PlanarImage outputImage = (PlanarImage)JAI.create("rescale", pbRescale, null); ParameterBlock pbConvert = new ParameterBlock(); pbConvert.addSource(outputImage); pbConvert.add(DataBuffer.TYPE_BYTE); exportImage = JAI.create("format", pbConvert); } | public void exportPhoto( File file, int width, int height ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are no instances, nothing can be exported log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } // Read the image BufferedImage origImage = null; try { log.warn( "Export: reading image " + original.getImageFile() ); origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); AffineTransform xform = org.photovault.image.ImageXform.getRotateXform( prefRotation -original.getRotated(), origWidth, origHeight ); ParameterBlockJAI rotParams = new ParameterBlockJAI( "affine" ); rotParams.addSource( origImage ); rotParams.setParameter( "transform", xform ); rotParams.setParameter( "interpolation", Interpolation.getInstance( Interpolation.INTERP_BICUBIC ) ); RenderedOp rotatedImage = JAI.create( "affine", rotParams ); ParameterBlockJAI cropParams = new ParameterBlockJAI( "crop" ); cropParams.addSource( rotatedImage ); cropParams.setParameter( "x", (float)( rotatedImage.getMinX() + cropMinX * rotatedImage.getWidth() ) ); cropParams.setParameter( "y", (float)( rotatedImage.getMinY() + cropMinY * rotatedImage.getHeight() ) ); cropParams.setParameter( "width", (float)( (cropMaxX - cropMinX) * rotatedImage.getWidth() ) ); cropParams.setParameter( "height", (float) ( (cropMaxY - cropMinY) * rotatedImage.getHeight() ) ); RenderedOp cropped = JAI.create("crop", cropParams, null); // Translate the image so that it begins in origo ParameterBlockJAI pbXlate = new ParameterBlockJAI( "translate" ); pbXlate.addSource( cropped ); pbXlate.setParameter( "xTrans", (float) (-cropped.getMinX() ) ); pbXlate.setParameter( "yTrans", (float) (-cropped.getMinY() ) ); RenderedOp xformImage = JAI.create( "translate", pbXlate ); // Finally, scale this to thumbnail PlanarImage exportImage = xformImage; if ( width > 0 ) { AffineTransform scale = org.photovault.image.ImageXform.getFittingXform( width, height, 0, xformImage.getWidth(), xformImage.getHeight() ); ParameterBlockJAI scaleParams = new ParameterBlockJAI( "affine" ); scaleParams.addSource( xformImage ); scaleParams.setParameter( "transform", scale ); scaleParams.setParameter( "interpolation", Interpolation.getInstance( Interpolation.INTERP_BICUBIC ) ); exportImage = JAI.create( "affine", scaleParams ); } // Try to determine the file type based on extension String ftype = "jpg"; String imageFname = file.getName(); int extIndex = imageFname.lastIndexOf( "." ) + 1; if ( extIndex > 0 ) { ftype = imageFname.substring( extIndex ); } try { // Find a writer for that file extensions ImageWriter writer = null; Iterator iter = ImageIO.getImageWritersByFormatName( ftype ); if (iter.hasNext()) writer = (ImageWriter)iter.next(); if (writer != null) { ImageOutputStream ios = null; try { // Prepare output file ios = ImageIO.createImageOutputStream( file ); writer.setOutput(ios); // Set some parameters ImageWriteParam param = writer.getDefaultWriteParam(); // if bi has type ARGB and alpha is false, we have // to tell the writer to not use the alpha // channel: this is especially needed for jpeg // files where imageio seems to produce wrong jpeg // files right now...// if (exportImage.getType() == BufferedImage.TYPE_INT_ARGB ) {// // this is not so obvious: create a new// // ColorModel without OPAQUE transparency and// // no alpha channel.// ColorModel cm = new ComponentColorModel(exportImage.getColorModel().getColorSpace(),// false, false,// Transparency.OPAQUE, DataBuffer.TYPE_BYTE);// // tell the writer to only use the first 3 bands (skip alpha)// int[] bands = {0, 1, 2};// param.setSourceBands(bands);// // although the java documentation says that// // SampleModel can be null, an exception is// // thrown in that case therefore a 1*1// // SampleModel that is compatible to cm is// // created:// param.setDestinationType(new ImageTypeSpecifier(cm,// cm.createCompatibleSampleModel(1, 1)));// } // Write the image writer.write(null, new IIOImage(exportImage, null, null), param); // Cleanup ios.flush(); } finally { if (ios != null) ios.close(); writer.dispose(); } } } catch ( IOException e ) { log.warn( "Error writing exported image: " + e.getMessage() ); txw.abort(); return; } txw.commit(); } |
|
columnsFolder.children.add(newIdx, col); | getColumns().add(newIdx, col); | public void changeColumnIndex(int oldIdx, int newIdx) 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 (newIdx == 0 || ((SQLColumn) columnsFolder.children.get(newIdx-1)).primaryKeySeq != null) { col.primaryKeySeq = new Integer(1); // will get sane value when normalized } normalizePrimaryKey(); columnsFolder.fireDbChildInserted(newIdx, col); } |
|| ((SQLColumn) columnsFolder.children.get(newIdx-1)).primaryKeySeq != null) { | || ((SQLColumn) getColumns().get(newIdx-1)).primaryKeySeq != null) { | public void changeColumnIndex(int oldIdx, int newIdx) 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 (newIdx == 0 || ((SQLColumn) columnsFolder.children.get(newIdx-1)).primaryKeySeq != null) { col.primaryKeySeq = new Integer(1); // will get sane value when normalized } normalizePrimaryKey(); columnsFolder.fireDbChildInserted(newIdx, col); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.