bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public void actionPerformed(ActionEvent e) { saveOrSaveAs(false, true); }
public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); }
1,111,164
protected void tearDown() throws Exception { db.disconnect(); db = null; }
protected void tearDown() throws Exception { db = null; }
1,111,165
public void setDataSource(Object dataSource) { if ( dataSource != null ) { log.info( "Setting data source to: " + dataSource + " of type: " + dataSource.getClass() ); } else { log.info( "Setting data source to: " + dataSource ); } this.rawDataSource = dataSource; this.dataSourceSpecified = true; }
public void setDataSource(Object dataSource) { if ( dataSource != null ) { log.info( "Setting data source to: " + dataSource + " of type: " + dataSource.getClass() ); } else { log.info( "Setting data source to: " + dataSource ); } this.rawDataSource = dataSource; this.dataSourceSpecified = true; }
1,111,166
public SQLCatalog getCatalogByName(String catalogName) throws ArchitectException { if (!populated) populate(); if (children == null || children.size() == 0) { return null; } if (! (children.get(0) instanceof SQLCatalog) ) { // this database doesn't contain catalogs! return null; } Iterator childit = children.iterator(); while (childit.hasNext()) { SQLCatalog child = (SQLCatalog) childit.next(); if (child.getName().equalsIgnoreCase(catalogName)) { return child; } } return null; }
public SQLCatalog getCatalogByName(String catalogName) throws ArchitectException { populate(); if (children == null || children.size() == 0) { return null; } if (! (children.get(0) instanceof SQLCatalog) ) { // this database doesn't contain catalogs! return null; } Iterator childit = children.iterator(); while (childit.hasNext()) { SQLCatalog child = (SQLCatalog) childit.next(); if (child.getName().equalsIgnoreCase(catalogName)) { return child; } } return null; }
1,111,168
public SQLSchema getSchemaByName(String schemaName) throws ArchitectException { if (!populated) populate(); if (children == null || children.size() == 0) { return null; } if (! (children.get(0) instanceof SQLSchema || children.get(0) instanceof SQLCatalog) ) { // this database doesn't contain schemas or catalogs! return null; } Iterator childit = children.iterator(); while (childit.hasNext()) { SQLObject child = (SQLObject) childit.next(); if (child instanceof SQLCatalog) { // children are tables or schemas SQLSchema schema = ((SQLCatalog) child).getSchemaByName(schemaName); if (schema != null) { return schema; } } else if (child instanceof SQLSchema) { if (child.getName().equalsIgnoreCase(schemaName)) { return (SQLSchema) child; } } else { throw new IllegalStateException("Database contains a mix of schemas or catalogs with other objects"); } } return null; }
public SQLSchema getSchemaByName(String schemaName) throws ArchitectException { populate(); if (children == null || children.size() == 0) { return null; } if (! (children.get(0) instanceof SQLSchema || children.get(0) instanceof SQLCatalog) ) { // this database doesn't contain schemas or catalogs! return null; } Iterator childit = children.iterator(); while (childit.hasNext()) { SQLObject child = (SQLObject) childit.next(); if (child instanceof SQLCatalog) { // children are tables or schemas SQLSchema schema = ((SQLCatalog) child).getSchemaByName(schemaName); if (schema != null) { return schema; } } else if (child instanceof SQLSchema) { if (child.getName().equalsIgnoreCase(schemaName)) { return (SQLSchema) child; } } else { throw new IllegalStateException("Database contains a mix of schemas or catalogs with other objects"); } } return null; }
1,111,169
public void propertyChange(PropertyChangeEvent e) { String pn = e.getPropertyName(); if ( (e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue())) ) { if (pn.equals("url") || pn.equals("driverClass") || pn.equals("user")) { reset(); } else if (pn.equals("displayName")) { fireDbObjectChanged("shortDisplayName"); } } }
public void propertyChange(PropertyChangeEvent e) { String pn = e.getPropertyName(); if ( (e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue())) ) { if ("url".equals(pn) || "driverClass".equals(pn) || "user".equals(pn)) { reset(); } else if (pn.equals("displayName")) { fireDbObjectChanged("shortDisplayName"); } } }
1,111,170
public void propertyChange(PropertyChangeEvent e) { String pn = e.getPropertyName(); if ( (e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue())) ) { if (pn.equals("url") || pn.equals("driverClass") || pn.equals("user")) { reset(); } else if (pn.equals("displayName")) { fireDbObjectChanged("shortDisplayName"); } } }
public void propertyChange(PropertyChangeEvent e) { String pn = e.getPropertyName(); if ( (e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue())) ) { if (pn.equals("url") || pn.equals("driverClass") || pn.equals("user")) { reset(); } else if ("displayName".equals(pn)) { fireDbObjectChanged("shortDisplayName"); } } }
1,111,171
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new MissingAttributeException( "var" ); } Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
1,111,172
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } if (select == null) { select = createXPathFromBody(xpathContext); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
1,111,173
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Object xpathContext = getXPathContext(); if (select == null) { select = createXPathFromBody(xpathContext); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Object xpathContext = getXPathContext(); if (select == null) { throw new MissingAttributeException( "select" ); } Object value = select.evaluate(xpathContext); context.setVariable(var, value); }
1,111,174
public void saveDprimeToText(File dumpDprimeFile, int source, int start, int stop) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); System.out.println("save dprime to text!"); //we use this LinkedList to store the dprime computations for a window of 5 markers //in either direction in the for loop farther down. //a tInt value is calculated for each marker which requires the dprime calculations //for the 5 markers before and 5 after the current marker, so we store these values while we need //them to avoid unnecesary recomputation. LinkedList savedDPrimes = new LinkedList(); long dist; if (infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\tT-int\n"); }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tT-int\n"); } boolean adj = false; if (start == -1 && stop == -1){ //user selected "adjacent markers" option start = 0; stop = Chromosome.getSize(); adj = true; } if (start < 0){ start = 0; } if (stop > Chromosome.getSize()){ stop = Chromosome.getSize(); } PairwiseLinkage currComp = null; //initialize the savedDPrimes linkedlist with 10 empty arrays of size 10 PairwiseLinkage[] pwlArray = new PairwiseLinkage[10]; savedDPrimes.add(pwlArray); for(int k=0;k<4;k++) { savedDPrimes.add(pwlArray.clone()); } PairwiseLinkage[] tempArray; if(source != TABLE_TYPE) { //savedDPrimes is a linkedlist which stores 5 arrays at all times. //it temporarily stores a set of computeDPrime() results so that we do not //do them over and over //each array contains 10 PairwiseLinkage objects. //each array contains the PairwiseLinkage objects for a marker being compared to the 10 previous markers. //if marker1 is some marker number, and tempArray is one of the arrays in savedDPrimes, then: // tempArray[0] = computeDPrime(marker1 - 10, marker1) // tempArray[9] = computeDPrime(marker1 - 1, marker1) //if the value of marker1 is less than 10, then the array is filled with nulls up the first valid comparison //that is, if marker1 = 5, then: // tempArray[0] through tempArray[4] are null // tempArray[5] = computeDPrime(marker1-5,marker1) for(int m=1;m<6;m++) { tempArray = (PairwiseLinkage[]) savedDPrimes.get(m-1); for(int n=1;n<11;n++){ if( (start+m) >= Chromosome.getSize() || (start+m-n)<0) { tempArray[10-n] = null; } else { //the next line used to have Chromosome.getUnfilteredMarker(Chromosome.realIndex[]) //but it seems like this should do the same thing long sep = Chromosome.getMarker(start+m).getPosition() - Chromosome.getMarker(start+m-n).getPosition(); if(Options.getMaxDistance() == 0 || sep < Options.getMaxDistance() ) { tempArray[10-n] = this.computeDPrime(Chromosome.realIndex[start+m-n],Chromosome.realIndex[start+m]); //tempArray[10-n] = "" + (start+m-n) + "," + (start+m) ; } } } } } for (int i = start; i < stop; i++){ if(source != TABLE_TYPE && i != start) { //here the first element of savedDPrimes is discarded. //the array of results for the marker (i+5) is then computed and added to the end of savedDPrimes tempArray = (PairwiseLinkage[]) savedDPrimes.removeFirst(); for(int m=0;m<10;m++) { tempArray[m] = null; } for(int n=1;n<11;n++){ if(i+5 < Chromosome.getSize() && (i+5-n) >=0) { long sep = Chromosome.getMarker(i+5).getPosition() - Chromosome.getMarker(i+5-n).getPosition(); if(Options.getMaxDistance() == 0 || sep < Options.getMaxDistance() ) { tempArray[10-n] = this.computeDPrime(Chromosome.realIndex[i+5-n],Chromosome.realIndex[i+5]); } } } savedDPrimes.addLast(tempArray); } for (int j = i+1; j < stop; j++){ if (adj){ if (!(i == j-1)){ continue; } } if (source == TABLE_TYPE){ currComp = dpTable.getLDStats(i,j); }else{ long sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(j).getPosition(); if(Options.getMaxDistance() == 0 || sep < Options.getMaxDistance() ) { currComp = this.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); } } if(currComp != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //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 >= Chromosome.getSize()){ continue; } tempArray = (PairwiseLinkage[]) savedDPrimes.get(y-1); PairwiseLinkage tintPair = null; if (source == TABLE_TYPE){ tintPair = dpTable.getLDStats(i-x,i+y); }else{ long sep = Chromosome.getUnfilteredMarker(Chromosome.realIndex[i-x]).getPosition() - Chromosome.getUnfilteredMarker(Chromosome.realIndex[i+y]).getPosition(); if(Options.getMaxDistance() == 0 || sep < Options.getMaxDistance() ) { tintPair = tempArray[9-x-y+1]; /*tintPair = this.computeDPrime(Chromosome.realIndex[i-x], Chromosome.realIndex[i+y]); if(tempArray[9-x-y+1] == null) { System.out.println("storage is null "); } if(tintPair == null) { System.out.println("tintPair is null"); } if(tempArray[9-x-y+1] == tintPair || (tintPair != null && tempArray[9-x-y+1] != null && tintPair.getLOD() == tempArray[9-x-y+1].getLOD())) { System.out.println("match"); } else { System.out.println("dont match"); }*/ } } if (tintPair != null){ LODSum += tintPair.getLOD(); } } } tInt = String.valueOf(roundDouble(LODSum)); } if (infoKnown){ dist = (Chromosome.getMarker(j)).getPosition() - (Chromosome.getMarker(i)).getPosition(); saveDprimeWriter.write(Chromosome.getMarker(i).getName() + "\t" + Chromosome.getMarker(j).getName() + "\t" + currComp.toString() + "\t" + dist + "\t" + tInt +"\n"); }else{ saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + currComp.toString() + "\t" + tInt + "\n"); } } } } saveDprimeWriter.close(); }
public void saveDprimeToText(File dumpDprimeFile, int source, int start, int stop) throws IOException{ FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); System.out.println("save dprime to text!"); //we use this LinkedList to store the dprime computations for a window of 5 markers //in either direction in the for loop farther down. //a tInt value is calculated for each marker which requires the dprime calculations //for the 5 markers before and 5 after the current marker, so we store these values while we need //them to avoid unnecesary recomputation. LinkedList savedDPrimes = new LinkedList(); long dist; if (infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\tT-int\n"); }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tT-int\n"); } boolean adj = false; if (start == -1 && stop == -1){ //user selected "adjacent markers" option start = 0; stop = Chromosome.getSize(); adj = true; } if (start < 0){ start = 0; } if (stop > Chromosome.getSize()){ stop = Chromosome.getSize(); } PairwiseLinkage currComp = null; //initialize the savedDPrimes linkedlist with 10 empty arrays of size 10 PairwiseLinkage[] pwlArray = new PairwiseLinkage[10]; savedDPrimes.add(pwlArray); for(int k=0;k<4;k++) { savedDPrimes.add(pwlArray.clone()); } PairwiseLinkage[] tempArray; if(source != TABLE_TYPE) { //savedDPrimes is a linkedlist which stores 5 arrays at all times. //it temporarily stores a set of computeDPrime() results so that we do not //do them over and over //each array contains 10 PairwiseLinkage objects. //each array contains the PairwiseLinkage objects for a marker being compared to the 10 previous markers. //if marker1 is some marker number, and tempArray is one of the arrays in savedDPrimes, then: // tempArray[0] = computeDPrime(marker1 - 10, marker1) // tempArray[9] = computeDPrime(marker1 - 1, marker1) //if the value of marker1 is less than 10, then the array is filled with nulls up the first valid comparison //that is, if marker1 = 5, then: // tempArray[0] through tempArray[4] are null // tempArray[5] = computeDPrime(marker1-5,marker1) for(int m=1;m<6;m++) { tempArray = (PairwiseLinkage[]) savedDPrimes.get(m-1); for(int n=1;n<11;n++){ if( (start+m) >= Chromosome.getSize() || (start+m-n)<0) { tempArray[10-n] = null; } else { //the next line used to have Chromosome.getUnfilteredMarker(Chromosome.realIndex[]) //but it seems like this should do the same thing long sep = Chromosome.getMarker(start+m).getPosition() - Chromosome.getMarker(start+m-n).getPosition(); if(Options.getMaxDistance() == 0 || Math.abs(sep) < Options.getMaxDistance() ) { tempArray[10-n] = this.computeDPrime(Chromosome.realIndex[start+m-n],Chromosome.realIndex[start+m]); //tempArray[10-n] = "" + (start+m-n) + "," + (start+m) ; } } } } } for (int i = start; i < stop; i++){ if(source != TABLE_TYPE && i != start) { //here the first element of savedDPrimes is discarded. //the array of results for the marker (i+5) is then computed and added to the end of savedDPrimes tempArray = (PairwiseLinkage[]) savedDPrimes.removeFirst(); for(int m=0;m<10;m++) { tempArray[m] = null; } for(int n=1;n<11;n++){ if(i+5 < Chromosome.getSize() && (i+5-n) >=0) { long sep = Chromosome.getMarker(i+5).getPosition() - Chromosome.getMarker(i+5-n).getPosition(); if(Options.getMaxDistance() == 0 || Math.abs(sep) < Options.getMaxDistance() ) { tempArray[10-n] = this.computeDPrime(Chromosome.realIndex[i+5-n],Chromosome.realIndex[i+5]); } } } savedDPrimes.addLast(tempArray); } for (int j = i+1; j < stop; j++){ if (adj){ if (!(i == j-1)){ continue; } } if (source == TABLE_TYPE){ currComp = dpTable.getLDStats(i,j); }else{ long sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(j).getPosition(); if(Options.getMaxDistance() == 0 || Math.abs(sep) < Options.getMaxDistance() ) { currComp = this.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); } } if(currComp != null) { double LODSum = 0; String tInt = "-"; if (i == j-1){ //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 >= Chromosome.getSize()){ continue; } tempArray = (PairwiseLinkage[]) savedDPrimes.get(y-1); PairwiseLinkage tintPair = null; if (source == TABLE_TYPE){ tintPair = dpTable.getLDStats(i-x,i+y); }else{ long sep = Chromosome.getUnfilteredMarker(Chromosome.realIndex[i-x]).getPosition() - Chromosome.getUnfilteredMarker(Chromosome.realIndex[i+y]).getPosition(); if(Options.getMaxDistance() == 0 || Math.abs(sep) < Options.getMaxDistance() ) { tintPair = tempArray[9-x-y+1]; /*tintPair = this.computeDPrime(Chromosome.realIndex[i-x], Chromosome.realIndex[i+y]); if(tempArray[9-x-y+1] == null) { System.out.println("storage is null "); } if(tintPair == null) { System.out.println("tintPair is null"); } if(tempArray[9-x-y+1] == tintPair || (tintPair != null && tempArray[9-x-y+1] != null && tintPair.getLOD() == tempArray[9-x-y+1].getLOD())) { System.out.println("match"); } else { System.out.println("dont match"); }*/ } } if (tintPair != null){ LODSum += tintPair.getLOD(); } } } tInt = String.valueOf(roundDouble(LODSum)); } if (infoKnown){ dist = (Chromosome.getMarker(j)).getPosition() - (Chromosome.getMarker(i)).getPosition(); saveDprimeWriter.write(Chromosome.getMarker(i).getName() + "\t" + Chromosome.getMarker(j).getName() + "\t" + currComp.toString() + "\t" + dist + "\t" + tInt +"\n"); }else{ saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + currComp.toString() + "\t" + tInt + "\n"); } } } } saveDprimeWriter.close(); }
1,111,175
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
1,111,176
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(appEvent instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
1,111,177
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
1,111,178
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(event.getTime()); } }
public void handleEvent(Event event) { ApplicationDowntimeHistory downtimeHistory = getDowntimeHistory(event.getApplicationConfig()); assert downtimeHistory != null; if(event instanceof ApplicationUpEvent){ // application must have went down earlier assert downtimeHistory.getDowntimeBegin() != null; // log the downtime to the db recordDowntime(event.getApplicationConfig().getApplicationId(), downtimeHistory.getDowntimeBegin(), event.getTime()); downtimeHistory.applicationCameUp(event.getTime()); }else if(event instanceof ApplicationDownEvent){ downtimeHistory.applicationWentDown(appEvent.getTime()); } }
1,111,179
public void applicationWentDown(long time){ assert downtimeBegin == null; downtimeBegin = time; }
public void applicationWentDown(long time){ assert downtimeBegin == null; downtimeBegin = time; }
1,111,180
public void mouseReleased(MouseEvent mouseEvent) { firstMouseEvent = null; if ( dragType == DRAG_TYPE_SELECT ) { // Find out thumbails inside the selection rectangle // First lets restrict search to those rows that intersect with selection int topRow = (int) dragSelectionRect.getMinY()/rowHeight; int bottomRow = ((int) dragSelectionRect.getMaxY()/rowHeight)+1; int startPhoto = topRow * columnsToPaint; int endPhoto = bottomRow * columnsToPaint; if ( endPhoto > photoCollection.getPhotoCount() ) { endPhoto = photoCollection.getPhotoCount(); } ODMGXAWrapper xa = new ODMGXAWrapper(); // Find out which photos are selected for ( int n = startPhoto; n < endPhoto; n++ ) { /* Performance optimization: Since getPhotoBounds() needs access to photo thumbnail which may not yet be loaded we will do first a rough check of if the table cell is in the selection area. */ Rectangle cellRect = getPhotoCellBounds( n ); if ( dragSelectionRect.intersects( cellRect ) ) { Rectangle photoRect = getPhotoBounds( n ); if ( dragSelectionRect.intersects( photoRect ) ) { selection.add( photoCollection.getPhoto( n ) ); repaintPhoto( photoCollection.getPhoto( n ) ); } } } fireSelectionChangeEvent(); xa.commit(); // Redrw the selection area so that the selection rectangle is not shown anymore Rectangle repaintRect = dragSelectionRect; if ( lastDragSelectionRect != null ) { repaintRect = dragSelectionRect.union( lastDragSelectionRect ); } repaint( (int) repaintRect.getX()-1, (int) repaintRect.getY()-1, (int) repaintRect.getWidth()+2, (int) repaintRect.getHeight()+2 ); dragSelectionRect = null; lastDragSelectionRect = null; // Notify the mouse click handler that it has to do nothing dragJustEnded = true; } }
public void mouseReleased(MouseEvent mouseEvent) { firstMouseEvent = null; if ( dragType == DRAG_TYPE_SELECT && photoCollection != null ) { // Find out thumbails inside the selection rectangle // First lets restrict search to those rows that intersect with selection int topRow = (int) dragSelectionRect.getMinY()/rowHeight; int bottomRow = ((int) dragSelectionRect.getMaxY()/rowHeight)+1; int startPhoto = topRow * columnsToPaint; int endPhoto = bottomRow * columnsToPaint; if ( endPhoto > photoCollection.getPhotoCount() ) { endPhoto = photoCollection.getPhotoCount(); } ODMGXAWrapper xa = new ODMGXAWrapper(); // Find out which photos are selected for ( int n = startPhoto; n < endPhoto; n++ ) { /* Performance optimization: Since getPhotoBounds() needs access to photo thumbnail which may not yet be loaded we will do first a rough check of if the table cell is in the selection area. */ Rectangle cellRect = getPhotoCellBounds( n ); if ( dragSelectionRect.intersects( cellRect ) ) { Rectangle photoRect = getPhotoBounds( n ); if ( dragSelectionRect.intersects( photoRect ) ) { selection.add( photoCollection.getPhoto( n ) ); repaintPhoto( photoCollection.getPhoto( n ) ); } } } fireSelectionChangeEvent(); xa.commit(); // Redrw the selection area so that the selection rectangle is not shown anymore Rectangle repaintRect = dragSelectionRect; if ( lastDragSelectionRect != null ) { repaintRect = dragSelectionRect.union( lastDragSelectionRect ); } repaint( (int) repaintRect.getX()-1, (int) repaintRect.getY()-1, (int) repaintRect.getWidth()+2, (int) repaintRect.getHeight()+2 ); dragSelectionRect = null; lastDragSelectionRect = null; // Notify the mouse click handler that it has to do nothing dragJustEnded = true; } }
1,111,181
public TablePane() { setOpaque(true); dt = new DropTarget(this, new TablePaneDropListener(this)); dgl = new TablePaneDragGestureListener(); ds = new DragSource(); // dgr = getToolkit().createDragGestureRecognizer(MouseDragGestureRecognizer.class, ds, this, DnDConstants.ACTION_MOVE, dgl); dgr = ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, dgl); logger.info("motion threshold is: " + getToolkit().getDesktopProperty("DnD.gestureMotionThreshold")); setInsertionPoint(COLUMN_INDEX_NONE); addMouseListener(this); updateUI(); }
private TablePane() { setOpaque(true); dt = new DropTarget(this, new TablePaneDropListener(this)); dgl = new TablePaneDragGestureListener(); ds = new DragSource(); // dgr = getToolkit().createDragGestureRecognizer(MouseDragGestureRecognizer.class, ds, this, DnDConstants.ACTION_MOVE, dgl); dgr = ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, dgl); logger.info("motion threshold is: " + getToolkit().getDesktopProperty("DnD.gestureMotionThreshold")); setInsertionPoint(COLUMN_INDEX_NONE); addMouseListener(this); updateUI(); }
1,111,182
public ApplicationConfig getApplicationConfig() { assert appName != null; return ServiceUtils.getApplicationConfigByName(appName); }
public ApplicationConfig getApplicationConfig() { if (appName == null) return null; return ServiceUtils.getApplicationConfigByName(appName); }
1,111,183
public ObjectName getObjectName() { assert mbeanName != null; String mbeanName = ServiceUtils.resolveMBeanName(getApplicationConfig(), this.mbeanName); return new ObjectName(mbeanName); }
public ObjectName getObjectName() { if (mbeanName == null) return null; String mbeanName = ServiceUtils.resolveMBeanName(getApplicationConfig(), this.mbeanName); return new ObjectName(mbeanName); }
1,111,184
protected Action createAction() { return new Action() { public void run(Node node) throws Exception { xpathSource = node; if (log.isDebugEnabled()) { log.debug( "Firing template body for match: " + match + " and node: " + node ); } invokeBody(output); } }; }
protected Action createAction(final StylesheetTag tag, final XMLOutput output) { return new Action() { public void run(Node node) throws Exception { xpathSource = node; if (log.isDebugEnabled()) { log.debug( "Firing template body for match: " + match + " and node: " + node ); } invokeBody(output); } }; }
1,111,187
protected Rule createRule() { return new Rule( match, getAction() ); }
protected Rule createRule() { return new Rule( match, getAction() ); }
1,111,190
public void doTag(XMLOutput output) throws Exception { // for use by inner classes this.output = output; StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" ); } if ( log.isDebugEnabled() ) { log.debug( "adding template rule for match: " + match ); } Rule rule = getRule(); if ( rule != null && tag != null) { rule.setMode( mode ); tag.addTemplate( rule ); } }
public void doTag(XMLOutput output) throws Exception { // for use by inner classes StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" ); } if ( log.isDebugEnabled() ) { log.debug( "adding template rule for match: " + match ); } Rule rule = getRule(); if ( rule != null && tag != null) { rule.setMode( mode ); tag.addTemplate( rule ); } }
1,111,191
public void doTag(XMLOutput output) throws Exception { // for use by inner classes this.output = output; StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" ); } if ( log.isDebugEnabled() ) { log.debug( "adding template rule for match: " + match ); } Rule rule = getRule(); if ( rule != null && tag != null) { rule.setMode( mode ); tag.addTemplate( rule ); } }
public void doTag(XMLOutput output) throws Exception { // for use by inner classes this.output = output; StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" ); } if ( log.isDebugEnabled() ) { log.debug( "adding template rule for match: " + match ); } Rule rule = createRule(tag, output); if ( rule != null && tag != null) { rule.setMode( mode ); tag.addTemplate( rule ); } }
1,111,192
protected URL resolveURL(String name) throws MalformedURLException { URL url = this.getClass().getClassLoader().getResource(name); if (url == null) { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); } else { return url; } }
protected URL resolveURL(String name) throws MalformedURLException { URL url = this.getClass().getClassLoader().getResource(name); if (url == null) { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); } else { return url; } }
1,111,193
protected URL resolveURL(String name) throws MalformedURLException { URL url = this.getClass().getClassLoader().getResource(name); if (url == null) { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); } else { return url; } }
protected URL resolveURL(String name) throws MalformedURLException { URL url = this.getClass().getClassLoader().getResource(name); if (url == null) { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); } else { return resourceUrl; } }
1,111,194
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new JellyException( "<define:script> must have a var attribute" ); } context.setVariable( var, getbody() ); }
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new JellyException( "<define:script> must have a var attribute" ); } context.setVariable( var, getBody() ); }
1,111,196
public void setUp() { PhotovaultSettings.setConfiguration( "pv_test" ); String sqldbName = PhotovaultSettings.getConfProperty( "dbname" ); ODMG.initODMG("harri", "r1t1rat1", sqldbName); odmg = ODMG.getODMGImplementation(); db = ODMG.getODMGDatabase();// try {// db.open( "repository.xml", Database.OPEN_READ_WRITE );// } catch ( ODMGException e ) {// // log.warn( "Could not open database: " + e.getMessage() );// db = null;// }// tx = odmg.newTransaction();// tx.begin(); }
public void setUp() { PhotovaultSettings.setConfiguration( "pv_test" ); String sqldbName = PhotovaultSettings.getConfProperty( "dbname" ); ODMG.initODMG("harri", "r1t1rat1", sqldbName); odmg = ODMG.getODMGImplementation(); db = ODMG.getODMGDatabase();// try {// db.open( "repository.xml", Database.OPEN_READ_WRITE );// } catch ( ODMGException e ) {// // log.warn( "Could not open database: " + e.getMessage() );// db = null;// }// tx = odmg.newTransaction();// tx.begin(); }
1,111,197
private static void authenticate(ServiceContextImpl context, String className, String methodName){ User user = context.getUser(); if(user == null){ /* only the login method in AuthService is allowed without authentication */ if(!className.equals(AuthService.class.getName()) || !methodName.equals("login")){ throw new RuntimeException("Service method called without " + "User credentials"); } return; } /* User must have username and password specified */ assert user.getUsername() != null; assert user.getPassword() != null; UserManager userManager = UserManager.getInstance(); User completeUser = userManager.getUser(user.getUsername()); /* validate password */ if(!user.getPassword().equals(completeUser.getPassword()) || !"A".equals(completeUser.getStatus())){ throw new RuntimeException("Invalid user credentials."); } context .setUser(completeUser); }
private static void authenticate(ServiceContextImpl context, String className, String methodName){ User user = context.getUser(); if(user == null){ /* only the login method in AuthService is allowed without authentication */ if(!className.equals(AuthService.class.getName()) || !methodName.equals("login")){ throw new RuntimeException("Service method called without " + "User credentials"); } return; } /* User must have username and password specified */ assert user.getUsername() != null; assert user.getPassword() != null; UserManager userManager = UserManager.getInstance(); User completeUser = userManager.getUser(user.getUsername()); /* validate password */ if(!user.getPassword().equals(completeUser.getPassword()) || !User.STATUS_ACTIVE.equals(completeUser.getStatus())){ throw new RuntimeException("Invalid user credentials."); } context .setUser(completeUser); }
1,111,198
public void setUp() { File f = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" ); try { source = ImageIO.read( f ); } catch ( IOException e ) { System.err.println( "Error reading image: " + e.getMessage() ); return; } testDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\image\\ImageXform" ); }
public void setUp() { File f = new File( testImgDir, "test1.jpg" ); try { source = ImageIO.read( f ); } catch ( IOException e ) { System.err.println( "Error reading image: " + e.getMessage() ); return; } testDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\image\\ImageXform" ); }
1,111,199
public void setUp() { File f = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" ); try { source = ImageIO.read( f ); } catch ( IOException e ) { System.err.println( "Error reading image: " + e.getMessage() ); return; } testDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\image\\ImageXform" ); }
public void setUp() { File f = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" ); try { source = ImageIO.read( f ); } catch ( IOException e ) { System.err.println( "Error reading image: " + e.getMessage() ); return; } testDir = new File( refImgDir, "photovault/image/ImageXform" ); }
1,111,200
public void doPermutations() { stopProcessing = false; Vector curResults = null; Haplotype[][] haplotypes = new Haplotype[testSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = testSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = testSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(new int[0],haplotypes[j][k].getPercentage(),null); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = null; permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { permuteInd = new Vector(); for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.add(new Boolean(true)); } else { permuteInd.add(new Boolean(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = new AssociationTestSet(fakeHaplos, null); curResults.addAll(ats.getResults()); } //end of haplotype association test //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
public void doPermutations() { stopProcessing = false; Vector curResults = null; Haplotype[][] haplotypes = new Haplotype[testSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = testSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = testSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(haplotypes[j][k].getGeno(),haplotypes[j][k].getPercentage(), haplotypes[j][k].getMarkers()); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = null; permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { permuteInd = new Vector(); for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.add(new Boolean(true)); } else { permuteInd.add(new Boolean(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = new AssociationTestSet(fakeHaplos, null); curResults.addAll(ats.getResults()); } //end of haplotype association test //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
1,111,201
public void doPermutations() { stopProcessing = false; Vector curResults = null; Haplotype[][] haplotypes = new Haplotype[testSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = testSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = testSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(new int[0],haplotypes[j][k].getPercentage(),null); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = null; permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { permuteInd = new Vector(); for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.add(new Boolean(true)); } else { permuteInd.add(new Boolean(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = new AssociationTestSet(fakeHaplos, null); curResults.addAll(ats.getResults()); } //end of haplotype association test //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
public void doPermutations() { stopProcessing = false; Vector curResults = null; Haplotype[][] haplotypes = new Haplotype[testSet.getHaplotypeAssociationResults().size()][]; Iterator hitr = testSet.getHaplotypeAssociationResults().iterator(); int count = 0; while (hitr.hasNext()){ haplotypes[count] = ((HaplotypeAssociationResult)hitr.next()).getHaps(); count++; } Vector snpSet = new Vector(); Iterator sitr = testSet.getFilteredResults().iterator(); while (sitr.hasNext()){ Object o = sitr.next(); if (o instanceof MarkerAssociationResult){ SNP snp = ((MarkerAssociationResult)o).getSnp(); snpSet.add(snp); } } //we need to make fake Haplotype objects so that we can use the getcounts() and getChiSq() methods of //AssociationResult. kludgetastic! Haplotype[][] fakeHaplos; if(haplotypes != null) { fakeHaplos = new Haplotype[haplotypes.length][]; for(int j=0;j<haplotypes.length;j++) { fakeHaplos[j] = new Haplotype[haplotypes[j].length]; for(int k=0;k<haplotypes[j].length;k++) { fakeHaplos[j][k] = new Haplotype(new int[0],haplotypes[j][k].getPercentage(),null); } } } else { fakeHaplos = new Haplotype[0][0]; } //need to use the same affected status for marker and haplotype association tests in case control, //so affectedStatus stores the shuffled affected status Vector affectedStatus = null; //need to use the same coin toss for marker and haplotype association tests in trio tdt, //so permuteInd stores whether each individual is permuted Vector permuteInd = null; permutationsPerformed = 0; bestExceededCount = 0; double[] chiSqs = new double[permutationCount]; permBestOverallChiSq = 0; //start the permuting! for(int i=0;i<permutationCount; i++) { //this variable gets set by the thread we're running if it wants us to stop if(stopProcessing) { break; } //begin single marker association test if (Options.getAssocTest() == ASSOC_TRIO){ try { permuteInd = new Vector(); for(int j =0;j<pedFile.getAllIndividuals().size();j++) { if(Math.random() < .5) { permuteInd.add(new Boolean(true)); } else { permuteInd.add(new Boolean(false)); } } curResults = new AssociationTestSet(pedFile, permuteInd, snpSet).getMarkerAssociationResults(); } catch(PedFileException pfe) { } }else if (Options.getAssocTest() == ASSOC_CC){ Vector indList = pedFile.getUnrelatedIndividuals(); affectedStatus = new Vector(); for(int j=0;j<indList.size();j++) { affectedStatus.add(new Integer(((Individual)indList.elementAt(j)).getAffectedStatus())); } Collections.shuffle(affectedStatus); try{ curResults = new AssociationTestSet(pedFile,affectedStatus, snpSet).getMarkerAssociationResults(); }catch (PedFileException pfe){ } } //end of marker association test //begin haplotype association test if(Options.getAssocTest() == ASSOC_TRIO) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(null,permuteInd); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setTransCount(curEM.getTransCount(k)); fakeHaplos[j][k].setUntransCount(curEM.getUntransCount(k)); } } } else if(Options.getAssocTest() == ASSOC_CC) { for(int j=0;j<fakeHaplos.length;j++) { EM curEM = (EM) theEMs.get(j); curEM.doAssociationTests(affectedStatus,null); for(int k=0;k<fakeHaplos[j].length;k++) { fakeHaplos[j][k].setCaseCount(curEM.getCaseCount(k)); fakeHaplos[j][k].setControlCount(curEM.getControlCount(k)); } } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { AssociationTestSet ats = null; if (testSet.getFilterAlleles() == null){ ats = new AssociationTestSet(fakeHaplos, null); }else{ try{ ats = new AssociationTestSet(fakeHaplos,null,testSet.getFilterAlleles()); }catch (HaploViewException hve){ } } curResults.addAll(ats.getResults()); } //end of haplotype association test //find the best chi square from all the tests double tempBestChiSquare = 0; for(int j=0; j<curResults.size();j++) { AssociationResult tempResult = (AssociationResult) curResults.elementAt(j); for (int k = 0; k < tempResult.getAlleleCount(); k++){ if(tempResult.getChiSquare(k) > tempBestChiSquare) { tempBestChiSquare = tempResult.getChiSquare(k); } } } chiSqs[i] = tempBestChiSquare; if (chiSqs[i] >= bestObsChiSq){ bestExceededCount++; } if(chiSqs[i] > permBestOverallChiSq){ permBestOverallChiSq = chiSqs[i]; } permutationsPerformed++; } permBestChiSq = new double[permutationsPerformed]; for (int i = 0; i < permutationsPerformed; i++){ permBestChiSq[i] = chiSqs[i]; } Arrays.sort(permBestChiSq); }
1,111,202
public BufferedImage export(int start, int stop){ forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > theData.filteredDPrimeTable.length){ exportStop = theData.filteredDPrimeTable.length; } Dimension pref = getPreferredSize(); BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); forExport = false; return i; }
public BufferedImage export(int start, int stop, boolean compress){ forExport = true; exportStart = start; if (exportStart < 0){ exportStart = 0; } exportStop = stop; if (exportStop > theData.filteredDPrimeTable.length){ exportStop = theData.filteredDPrimeTable.length; } Dimension pref = getPreferredSize(); BufferedImage i = new BufferedImage(pref.width, pref.height, BufferedImage.TYPE_3BYTE_BGR); paintComponent(i.getGraphics()); forExport = false; return i; }
1,111,203
public Dimension getPreferredSize() { //loop through table to find deepest non-null comparison PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; int upLim, loLim; if (forExport){ loLim = exportStart; upLim = exportStop; }else{ loLim = 0; upLim = dPrimeTable.length; } int count = 0; for (int x = loLim; x < upLim-1; x++){ for (int y = x+1; y < upLim; y++){ if (dPrimeTable[x][y] != null){ if (count < y-x){ count = y-x; } } } } //add one so we don't clip bottom box count ++; Graphics g = this.getGraphics(); g.setFont(markerNameFont); FontMetrics fm = g.getFontMetrics(); if (printDetails){ blockDispHeight = boxSize/3 + fm.getAscent(); }else{ blockDispHeight = boxSize/3; } int high = 2*V_BORDER + count*boxSize/2 + blockDispHeight; chartSize = new Dimension(2*H_BORDER + boxSize*(upLim-1),high); //this dimension is just the area taken up by the dprime chart //it is used in drawing the worldmap if (theData.infoKnown){ infoHeight = TICK_HEIGHT + TICK_BOTTOM + widestMarkerName + TEXT_GAP; high += infoHeight; }else{ infoHeight=0; } if (theData.trackExists){ //make room for analysis track at top high += TRACK_HEIGHT + TRACK_GAP; } int wide = 2*H_BORDER + boxSize*(upLim-loLim-1); Rectangle visRect = getVisibleRect(); //big datasets often scroll way offscreen in zoom-out mode //but aren't the full height of the viewport if (high < visRect.height && showWM){ high = visRect.height; } return new Dimension(wide, high); }
public Dimension getPreferredSize() { //loop through table to find deepest non-null comparison PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; int upLim, loLim; if (forExport){ loLim = exportStart; upLim = exportStop; }else{ loLim = 0; upLim = dPrimeTable.length; } int count = 0; for (int x = loLim; x < upLim-1; x++){ for (int y = x+1; y < upLim; y++){ if (dPrimeTable[x][y] != null){ if (count < y-x){ count = y-x; } } } } //add one so we don't clip bottom box count ++; Graphics g = this.getGraphics(); g.setFont(markerNameFont); FontMetrics fm = g.getFontMetrics(); if (printDetails){ blockDispHeight = boxSize/3 + fm.getAscent(); }else{ blockDispHeight = boxSize/3; } int high = 2*V_BORDER + count*boxSize/2 + blockDispHeight; chartSize = new Dimension(2*H_BORDER + boxSize*(upLim-1),high); //this dimension is just the area taken up by the dprime chart //it is used in drawing the worldmap if (theData.infoKnown){ infoHeight = TICK_HEIGHT + TICK_BOTTOM + widestMarkerName + TEXT_GAP; high += infoHeight; }else{ infoHeight=0; } if (theData.trackExists){ //make room for analysis track at top high += TRACK_HEIGHT + TRACK_GAP; } int wide = 2*H_BORDER + boxSize*(upLim-loLim-1); Rectangle visRect = getVisibleRect(); //big datasets often scroll way offscreen in zoom-out mode //but aren't the full height of the viewport if (high < visRect.height && showWM){ high = visRect.height; } return new Dimension(wide, high); }
1,111,205
public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel == 0){ printDetails = true; } else{ printDetails = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel == 0){ printDetails = true; } else{ printDetails = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
1,111,206
public static ImageInstance retrieve( VolumeBase volume, String fname ) throws PhotoNotFoundException { String oql = "select instance from " + ImageInstance.class.getName() + " where volumeId = \"" + volume.getName() + "\" and fname = \"" + fname + "\""; List instances = null; // Get transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); try { OQLQuery query = odmg.newOQLQuery(); query.create( oql ); instances = (List) query.execute(); txw.commit(); } catch ( Exception e ) { txw.abort(); return null; } ImageInstance instance = (ImageInstance) instances.get( 0 ); return instance; }
public static ImageInstance retrieve( VolumeBase volume, String fname ) throws PhotoNotFoundException { String oql = "select instance from " + ImageInstance.class.getName() + " where volumeId = \"" + volume.getName() + "\" and fname = \"" + fname + "\""; List instances = null; // Get transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); try { OQLQuery query = odmg.newOQLQuery(); query.create( oql ); instances = (List) query.execute(); txw.commit(); } catch ( Exception e ) { txw.abort(); return null; } ImageInstance instance = null; if ( instances != null && instances.size() > 0 ) { instance = (ImageInstance) instances.get( 0 ); } return instance; }
1,111,209
public void actionPerformed(ActionEvent evt) { Selectable invoker = pp.getSelection(); if (invoker instanceof TablePane) { TablePane tp = (TablePane) invoker; int idx; while ( (idx = tp.getSelectedColumnIndex()) >= 0) { tp.getModel().removeChild(idx); } } else { JOptionPane.showMessageDialog((JComponent) invoker, "The selected item type is not recognised"); } }
public void actionPerformed(ActionEvent evt) { Selectable invoker = pp.getSelection(); if (invoker instanceof TablePane) { TablePane tp = (TablePane) invoker; int idx; while ( (idx = tp.getSelectedColumnIndex()) >= 0) { tp.getModel().removeColumn(idx); } } else { JOptionPane.showMessageDialog((JComponent) invoker, "The selected item type is not recognised"); } }
1,111,210
public void actionPerformed(ActionEvent evt ) { manager.undo(); }
public void actionPerformed(ActionEvent evt ) { if (logger.isDebugEnabled()) { logger.debug(manager); int choice = JOptionPane.showConfirmDialog(null, "Undo manager state dumped to logger." + "\n\n" + "Proceed with undo?"); if (choice == JOptionPane.YES_OPTION) { manager.undo(); } } else { manager.undo(); } }
1,111,212
public Object getVariable(String name) { Object value = variables.get(name); if ( value == null && isInherit() ) { JellyContext parent = getParent(); if (parent != null) { value = parent.findVariable( name ); } } return value; }
public Object getVariable(String name) { Object value = variables.get(name); if ( value == null && isInherit() ) { JellyContext parent = getParent(); if (parent != null) { value = parent.getVariable( name ); } } return value; }
1,111,213
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); permTests.cat(blockTestSet); final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced included tags does not appear in the marker info file."); System.exit(1); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced excluded tags does not appear in the marker info file."); System.exit(1); } } forceExcludeTags.retainAll(filteredNames); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getAbsolutePath()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); if(blockTestSet != null) { permTests.cat(blockTestSet); } final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(tagging != Tagger.NONE) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced included tags does not appear in the marker info file."); System.exit(1); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced excluded tags does not appear in the marker info file."); System.exit(1); } } forceExcludeTags.retainAll(filteredNames); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, tagging); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
1,111,215
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); 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.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")); }
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); 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() { @Override public void actionPerformed(ActionEvent e) { try { setExportingTables(getProject().getTargetDatabase().getTables()); super.actionPerformed(e); } catch (ArchitectException ex) { ASUtils.showExceptionDialog( ArchitectFrame.this, "Error Creating List of Tables to Export", ex); } } }; 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.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")); }
1,111,216
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); } }
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); } }
1,111,217
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); } }
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); } }
1,111,218
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); } }
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()); } } 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); } }
1,111,219
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); } }
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); } }
1,111,220
public void actionPerformed(ActionEvent e) { 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); } }
1,111,221
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); } }
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); } }
1,111,222
public void run() { 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() { 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); } }
1,111,223
public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; } }; worker.start(); } } } }
public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; } }; worker.start(); } } } }
1,111,224
public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; } }; worker.start(); } } } }
public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; } }; worker.start(); } } } }
1,111,225
public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; }
public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; }
1,111,226
public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; }
public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } //edge shifts prevent window from popping up partially offscreen int clipRightBound = (int)(clipRect.getWidth() + clipRect.getX()); int clipBotBound = (int)(clipRect.getHeight() + clipRect.getY()); int rightEdgeShift = 0; if (clickX + strlen + leftMargin +5 > clipRightBound){ rightEdgeShift = clickX + strlen + leftMargin + 10 - clipRightBound; } int botEdgeShift = 0; if (clickY + 5*metrics.getHeight()+10 > clipBotBound){ botEdgeShift = clickY + 5*metrics.getHeight()+15 - clipBotBound; } g.setColor(Color.WHITE); g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); } return ""; }
1,111,227
DPrimeDisplay(PairwiseLinkage[][] t, boolean b, Vector v){ markersLoaded = b; dPrimeTable = t; markers = v; this.setDoubleBuffered(true); addMouseListener(new PopMouseListener(this)); }
DPrimeDisplay(PairwiseLinkage[][] t, boolean b){ markersLoaded = b; dPrimeTable = t; markers = v; this.setDoubleBuffered(true); addMouseListener(new PopMouseListener(this)); }
1,111,228
DPrimeDisplay(PairwiseLinkage[][] t, boolean b, Vector v){ markersLoaded = b; dPrimeTable = t; markers = v; this.setDoubleBuffered(true); addMouseListener(new PopMouseListener(this)); }
DPrimeDisplay(PairwiseLinkage[][] t, boolean b, Vector v){ markersLoaded = b; dPrimeTable = t; this.setDoubleBuffered(true); addMouseListener(new PopMouseListener(this)); }
1,111,229
public void loadMarkers(Vector v){ markersLoaded = true; markers = v; repaint(); }
public void loadMarkers(){ markersLoaded = true; markers = v; repaint(); }
1,111,230
public void loadMarkers(Vector v){ markersLoaded = true; markers = v; repaint(); }
public void loadMarkers(Vector v){ markersLoaded = true; repaint(); }
1,111,231
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,232
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,233
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,234
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,235
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(Chromosome.getMarker(x).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,236
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //okay so this dumb if block is to prevent the ugly //repainting bug when loading markers after the data are already //being displayed, results in a little off-centering for small //datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } /** if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } }**/ //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } }
1,111,237
public void adjustDisplay(){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > Options.getHaplotypeDisplayThreshold()){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + Options.getHaplotypeDisplayThreshold(), "Error", JOptionPane.ERROR_MESSAGE); return; } filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
public void adjustDisplay(){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > Options.getHaplotypeDisplayThreshold()){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + Options.getHaplotypeDisplayThreshold(), "Error", JOptionPane.ERROR_MESSAGE); return; } filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
1,111,238
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks,false); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} orderedHaplos = theData.generateHaplotypes(theData.blocks,false); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
1,111,239
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks,false); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks,false); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
1,111,240
public void testForObjectCompareToNull(){ SQLTable t = new SQLTable(); t.setName("Testing"); assertEquals (1, comparator.compare(t, null)); assertEquals (-1, comparator.compare(null, t)); }
public void testForObjectCompareToNull() throws ArchitectException{ SQLTable t = new SQLTable(); t.setName("Testing"); assertEquals (1, comparator.compare(t, null)); assertEquals (-1, comparator.compare(null, t)); }
1,111,242
public void testForObjectCompareToObject(){ SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); t1.setName("cow"); t2.setName("pigs"); assertTrue( comparator.compare(t1,t2) < 0); }
public void testForObjectCompareToObject() throws ArchitectException{ SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); t1.setName("cow"); t2.setName("pigs"); assertTrue( comparator.compare(t1,t2) < 0); }
1,111,243
public void testWithNullName() { SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); assertEquals(0, comparator.compare(t1,t2)); }
public void testWithNullName() throws ArchitectException { SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); assertEquals(0, comparator.compare(t1,t2)); }
1,111,244
public void testWithSameName(){ SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); t1.setName("cow"); t2.setName("cow"); assertEquals( 0, comparator.compare(t1,t2)); }
public void testWithSameName() throws ArchitectException{ SQLTable t1 = new SQLTable(); SQLTable t2 = new SQLTable(); t1.setName("cow"); t2.setName("cow"); assertEquals( 0, comparator.compare(t1,t2)); }
1,111,245
public void dragGestureRecognized(DragGestureEvent dge) { PlayPenComponent c = contentPane.getComponentAt( unzoomPoint(((MouseEvent) dge.getTriggerEvent()).getPoint())); if ( c instanceof TablePane ) { TablePane tp = (TablePane) c; int colIndex = TablePane.COLUMN_INDEX_NONE; Point dragOrigin = tp.getPlayPen().unzoomPoint(new Point(dge.getDragOrigin())); dragOrigin.x -= tp.getX(); dragOrigin.y -= tp.getY(); // ignore drag events that aren't from the left mouse button if (dge.getTriggerEvent() instanceof MouseEvent && (dge.getTriggerEvent().getModifiers() & InputEvent.BUTTON1_MASK) == 0) return; // ignore drag events if we're in the middle of a createRelationship if (ArchitectFrame.getMainInstance().createRelationshipIsActive()) { logger.debug("CreateRelationship() is active, short circuiting DnD."); return; } try { colIndex = tp.pointToColumnIndex(dragOrigin); } catch (ArchitectException e) { logger.error("Got exception while translating drag point", e); } logger.debug("Recognized drag gesture on "+tp.getName()+"! origin="+dragOrigin +"; col="+colIndex); try { logger.debug("DGL: colIndex="+colIndex+",columnsSize="+tp.getModel().getColumns().size()); if (colIndex == TablePane.COLUMN_INDEX_TITLE) { // we don't use this because it often misses drags // that start near the edge of the titlebar logger.debug("Discarding drag on titlebar (handled by mousePressed())"); draggingTablePanes = true; } else if (colIndex >= 0 && colIndex < tp.getModel().getColumns().size()) { // export column as DnD event if (logger.isDebugEnabled()) { logger.debug("Exporting column "+colIndex+" with DnD"); } tp.draggingColumn = tp.getModel().getColumn(colIndex); DBTree tree = ArchitectFrame.getMainInstance().dbTree; int[] path = tree.getDnDPathToNode(tp.draggingColumn); if (logger.isDebugEnabled()) { StringBuffer array = new StringBuffer(); for (int i = 0; i < path.length; i++) { array.append(path[i]); array.append(","); } logger.debug("Path to dragged node: "+array); } // export list of DnD-type tree paths ArrayList paths = new ArrayList(1); paths.add(path); logger.info("DBTree: exporting 1-item list of DnD-type tree path"); JLabel label = new JLabel(tp.getModel().getName()+"."+tp.draggingColumn.getName()); Dimension labelSize = label.getPreferredSize(); label.setSize(labelSize); // because a LayoutManager would normally do this BufferedImage dragImage = new BufferedImage(labelSize.width, labelSize.height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D imageGraphics = dragImage.createGraphics(); // XXX: it would be nice to make this transparent, but initial attempts using AlphaComposite failed (on OS X) label.repaint(); imageGraphics.dispose(); dge.getDragSource().startDrag(dge, null, dragImage, new Point(0, 0), new DnDTreePathTransferable(paths), tp); } } catch (ArchitectException ex) { logger.error("Couldn't drag column", ex); JOptionPane.showMessageDialog(tp.getPlayPen(), "Can't drag column: "+ex.getMessage()); } } else { return; } }
public void dragGestureRecognized(DragGestureEvent dge) { PlayPenComponent c = contentPane.getComponentAt( unzoomPoint(((MouseEvent) dge.getTriggerEvent()).getPoint())); if ( c instanceof TablePane ) { TablePane tp = (TablePane) c; int colIndex = TablePane.COLUMN_INDEX_NONE; Point dragOrigin = tp.getPlayPen().unzoomPoint(new Point(dge.getDragOrigin())); dragOrigin.x -= tp.getX(); dragOrigin.y -= tp.getY(); // ignore drag events that aren't from the left mouse button if (dge.getTriggerEvent() instanceof MouseEvent && (dge.getTriggerEvent().getModifiers() & InputEvent.BUTTON1_MASK) == 0) return; // ignore drag events if we're in the middle of a createRelationship if (ArchitectFrame.getMainInstance().createRelationshipIsActive()) { logger.debug("CreateRelationship() is active, short circuiting DnD."); return; } try { colIndex = tp.pointToColumnIndex(dragOrigin); } catch (ArchitectException e) { logger.error("Got exception while translating drag point", e); } logger.debug("Recognized drag gesture on "+tp.getName()+"! origin="+dragOrigin +"; col="+colIndex); try { logger.debug("DGL: colIndex="+colIndex+",columnsSize="+tp.getModel().getColumns().size()); if (colIndex == TablePane.COLUMN_INDEX_TITLE) { // we don't use this because it often misses drags // that start near the edge of the titlebar logger.debug("Discarding drag on titlebar (handled by mousePressed())"); draggingTablePanes = true; } else if (colIndex >= 0 && colIndex < tp.getModel().getColumns().size()) { // export column as DnD event if (logger.isDebugEnabled()) { logger.debug("Exporting column "+colIndex+" with DnD"); } tp.draggingColumn = tp.getModel().getColumn(colIndex); DBTree tree = ArchitectFrame.getMainInstance().dbTree; int[] path = tree.getDnDPathToNode(tp.draggingColumn); if (logger.isDebugEnabled()) { StringBuffer array = new StringBuffer(); for (int i = 0; i < path.length; i++) { array.append(path[i]); array.append(","); } logger.debug("Path to dragged node: "+array); } // export list of DnD-type tree paths ArrayList paths = new ArrayList(1); paths.add(path); logger.info("DBTree: exporting 1-item list of DnD-type tree path"); JLabel label = new JLabel(tp.getModel().getName()+"."+tp.draggingColumn.getName()); Dimension labelSize = label.getPreferredSize(); label.setSize(labelSize); // because a LayoutManager would normally do this BufferedImage dragImage = new BufferedImage(labelSize.width, labelSize.height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D imageGraphics = dragImage.createGraphics(); // XXX: it would be nice to make this transparent, but initial attempts using AlphaComposite failed (on OS X) label.repaint(); imageGraphics.dispose(); dge.getDragSource().startDrag(dge, null, dragImage, new Point(0, 0), new DnDTreePathTransferable(paths), tp); } } catch (ArchitectException ex) { logger.error("Couldn't drag column", ex); JOptionPane.showMessageDialog(tp.getPlayPen(), "Can't drag column: "+ex.getMessage()); } } else { return; } }
1,111,247
public PlayPen() { zoom = 1.0; setBackground(java.awt.Color.white); contentPane = new PlayPenContentPane(this); setLayout(null); setName("Play Pen"); setMinimumSize(new Dimension(1,1)); dt = new DropTarget(this, new PlayPenDropListener()); bringToFrontAction = new BringToFrontAction(this); sendToBackAction = new SendToBackAction(this); setupTablePanePopup(); setupPlayPenPopup(); setupKeyboardActions(); ppMouseListener = new PPMouseListener(); addMouseListener(ppMouseListener); addMouseMotionListener(ppMouseListener); dgl = new TablePaneDragGestureListener(); ds = new DragSource(); ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, dgl); logger.debug("DragGestureRecognizer motion threshold: " + getToolkit().getDesktopProperty("DnD.gestureMotionThreshold")); }
public PlayPen() { zoom = 1.0; setBackground(java.awt.Color.white); contentPane = new PlayPenContentPane(this); setLayout(new PlayPenLayout()); setName("Play Pen"); setMinimumSize(new Dimension(1,1)); dt = new DropTarget(this, new PlayPenDropListener()); bringToFrontAction = new BringToFrontAction(this); sendToBackAction = new SendToBackAction(this); setupTablePanePopup(); setupPlayPenPopup(); setupKeyboardActions(); ppMouseListener = new PPMouseListener(); addMouseListener(ppMouseListener); addMouseMotionListener(ppMouseListener); dgl = new TablePaneDragGestureListener(); ds = new DragSource(); ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, dgl); logger.debug("DragGestureRecognizer motion threshold: " + getToolkit().getDesktopProperty("DnD.gestureMotionThreshold")); }
1,111,248
public void actionPerformed(ActionEvent e) { logger.debug("oldZoom="+playpen.getZoom()+",zoomStep="+zoomStep); playpen.setZoom(playpen.getZoom() + zoomStep); logger.debug("newZoom="+playpen.getZoom()); Rectangle scrollTo = null; Iterator it = playpen.getSelectedItems().iterator(); while (it.hasNext()) { Rectangle bounds = ((Component) it.next()).getBounds(); logger.debug("new rectangle, bounds: " + bounds); if (scrollTo == null) { scrollTo = new Rectangle(bounds); } else { logger.debug("added rectangles, new bounds: " + scrollTo); scrollTo.add(bounds); } } if (scrollTo != null && !scrollTo.isEmpty()) { playpen.zoomRect(scrollTo); playpen.scrollRectToVisible(scrollTo); } }
public void actionPerformed(ActionEvent e) { logger.debug("oldZoom="+playpen.getZoom()+",zoomStep="+zoomStep); playpen.setZoom(playpen.getZoom() * Math.pow(2,zoomStep)); logger.debug("newZoom="+playpen.getZoom()); Rectangle scrollTo = null; Iterator it = playpen.getSelectedItems().iterator(); while (it.hasNext()) { Rectangle bounds = ((Component) it.next()).getBounds(); logger.debug("new rectangle, bounds: " + bounds); if (scrollTo == null) { scrollTo = new Rectangle(bounds); } else { logger.debug("added rectangles, new bounds: " + scrollTo); scrollTo.add(bounds); } } if (scrollTo != null && !scrollTo.isEmpty()) { playpen.zoomRect(scrollTo); playpen.scrollRectToVisible(scrollTo); } }
1,111,249
public void propertyChange(PropertyChangeEvent e) { if ("zoom".equals(e.getPropertyName())) { if (playpen.getZoom() + zoomStep < 0.1) { setEnabled(false); } else { setEnabled(true); } } }
public void propertyChange(PropertyChangeEvent e) { if ("zoom".equals(e.getPropertyName())) { if (playpen.getZoom() + zoomStep < 0.1) { setEnabled(false); } else { setEnabled(true); } } }
1,111,250
public boolean validate(Message message, MailProcessingRecord record) { return true; }
public boolean validate(Message message, MailProcessingRecord record) { MimeMultipart mimeMultipart; try { mimeMultipart = new MimeMultipart(message.getDataHandler().getDataSource()); } catch (MessagingException e) { return false; } int textPartSize = MailMatchingUtils.getMimePartSize(mimeMultipart, "text/plain"); record.setByteReceivedText(textPartSize); int binaryPartSize = MailMatchingUtils.getMimePartSize(mimeMultipart, "application/octet-stream"); record.setByteReceivedBinary(binaryPartSize); boolean textPartValid = textPartSize == record.getByteSendText(); boolean binaryPartValid = binaryPartSize == record.getByteSendBinary(); boolean valid = textPartValid && binaryPartValid; return valid; }
1,111,251
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
1,111,253
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
1,111,254
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
protected void createUI() { editor = new PhotoInfoEditor( ctrl ); getContentPane().add( editor, BorderLayout.NORTH ); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); } } ); JButton applyBtn = new JButton( "Apply" ); applyBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } } } ); JButton discardBtn = new JButton( "Discard" ); discardBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); } } ); JButton closeBtn = new JButton( "Close" ); closeBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { ctrl.discard(); setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(applyBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(discardBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(closeBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( applyBtn ); pack(); }
1,111,255
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); }
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); }
1,111,256
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } setVisible( false ); }
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { JOptionPane.showMessageDialog( staticThis, "Error while saving changes: \n" + ex.getMessage(), "Error saving changes", JOptionPane.ERROR_MESSAGE, null ); log.warn( "problem while saving changes: " + ex.getMessage() ); } } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } catch ( Exception ex ) { JOptionPane.showMessageDialog( staticThis, "Error while saving changes: \n" + ex.getMessage(), "Error saving changes", JOptionPane.ERROR_MESSAGE, null ); log.warn( "problem while saving changes: " + ex.getMessage() ); } } setVisible( false ); } catch ( Exception ex ) { JOptionPane.showMessageDialog( staticThis, "Error while saving changes: \n" + ex.getMessage(), "Error saving changes", JOptionPane.ERROR_MESSAGE, null ); log.warn( "problem while saving changes: " + ex.getMessage() ); } }
1,111,257
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } }
public void actionPerformed( ActionEvent e ) { try { ctrl.save(); photoChanged = true; } catch ( Exception ex ) { log.warn( "problem while saving changes: " + ex.getMessage() ); } }
1,111,258
public void saveDprimeToText(String[][] dPrimeTable, String infile) throws IOException{ File dumpDprimeFile = new File(infile); FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } saveDprimeWriter.close(); }
public void saveDprimeToText(String[][] dPrimeTable, String infile) throws IOException{ File dumpDprimeFile = new File(infile); FileWriter saveDprimeWriter = new FileWriter(dumpDprimeFile); saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); for (int i = 0; i < dPrimeTable.length; i++){ for (int j = 0; j < dPrimeTable[i].length; j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ saveDprimeWriter.write(i + "\t" + j + "\t" + dPrimeTable[i][j] + "\n"); } } } saveDprimeWriter.close(); }
1,111,259
public void saveHapsToText(Haplotype[][] finishedHaplos, String saveName) throws IOException{ NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); //open file for saving haps text File saveHapsFile = new File(saveName); FileWriter saveHapsWriter = new FileWriter(saveHapsFile); int[][]lookupPos = new int[finishedHaplos.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[finishedHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][finishedHaplos[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + finishedHaplos[p][q].getListOrder()); } } //go through each block and print haplos for (int i = 0; i < finishedHaplos.length; i++){ //write block header saveHapsWriter.write("BLOCK " + (i+1) + ". MARKERS:"); int[] markerNums = finishedHaplos[i][0].getMarkers(); for (int j = 0; j < finishedHaplos[i].length; j++){ saveHapsWriter.write(" " + (markerNums[j]+1)); } saveHapsWriter.write("\n"); //write haps and crossover percentages for (int j = 0; j < finishedHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; String theHap = new String(); int[] theGeno = finishedHaplos[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ theHap += theGeno[k]; } saveHapsWriter.write(theHap + " (" + nf.format(finishedHaplos[i][curHapNum].getPercentage()) + ")"); if (i < finishedHaplos.length-1){ saveHapsWriter.write("\t|"); for (int crossCount = 0; crossCount < finishedHaplos[i+1].length; crossCount++){ if (crossCount != 0) saveHapsWriter.write("\t"); saveHapsWriter.write(nf.format(finishedHaplos[i][curHapNum].getCrossover(crossCount))); } saveHapsWriter.write("|"); } saveHapsWriter.write("\n"); } saveHapsWriter.write("\n"); } saveHapsWriter.close(); }
public void saveHapsToText(Haplotype[][] finishedHaplos, File saveHapsFile) throws IOException{ NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); //open file for saving haps text File saveHapsFile = new File(saveName); FileWriter saveHapsWriter = new FileWriter(saveHapsFile); int[][]lookupPos = new int[finishedHaplos.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[finishedHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][finishedHaplos[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + finishedHaplos[p][q].getListOrder()); } } //go through each block and print haplos for (int i = 0; i < finishedHaplos.length; i++){ //write block header saveHapsWriter.write("BLOCK " + (i+1) + ". MARKERS:"); int[] markerNums = finishedHaplos[i][0].getMarkers(); for (int j = 0; j < finishedHaplos[i].length; j++){ saveHapsWriter.write(" " + (markerNums[j]+1)); } saveHapsWriter.write("\n"); //write haps and crossover percentages for (int j = 0; j < finishedHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; String theHap = new String(); int[] theGeno = finishedHaplos[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ theHap += theGeno[k]; } saveHapsWriter.write(theHap + " (" + nf.format(finishedHaplos[i][curHapNum].getPercentage()) + ")"); if (i < finishedHaplos.length-1){ saveHapsWriter.write("\t|"); for (int crossCount = 0; crossCount < finishedHaplos[i+1].length; crossCount++){ if (crossCount != 0) saveHapsWriter.write("\t"); saveHapsWriter.write(nf.format(finishedHaplos[i][curHapNum].getCrossover(crossCount))); } saveHapsWriter.write("|"); } saveHapsWriter.write("\n"); } saveHapsWriter.write("\n"); } saveHapsWriter.close(); }
1,111,260
public void saveHapsToText(Haplotype[][] finishedHaplos, String saveName) throws IOException{ NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); //open file for saving haps text File saveHapsFile = new File(saveName); FileWriter saveHapsWriter = new FileWriter(saveHapsFile); int[][]lookupPos = new int[finishedHaplos.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[finishedHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][finishedHaplos[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + finishedHaplos[p][q].getListOrder()); } } //go through each block and print haplos for (int i = 0; i < finishedHaplos.length; i++){ //write block header saveHapsWriter.write("BLOCK " + (i+1) + ". MARKERS:"); int[] markerNums = finishedHaplos[i][0].getMarkers(); for (int j = 0; j < finishedHaplos[i].length; j++){ saveHapsWriter.write(" " + (markerNums[j]+1)); } saveHapsWriter.write("\n"); //write haps and crossover percentages for (int j = 0; j < finishedHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; String theHap = new String(); int[] theGeno = finishedHaplos[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ theHap += theGeno[k]; } saveHapsWriter.write(theHap + " (" + nf.format(finishedHaplos[i][curHapNum].getPercentage()) + ")"); if (i < finishedHaplos.length-1){ saveHapsWriter.write("\t|"); for (int crossCount = 0; crossCount < finishedHaplos[i+1].length; crossCount++){ if (crossCount != 0) saveHapsWriter.write("\t"); saveHapsWriter.write(nf.format(finishedHaplos[i][curHapNum].getCrossover(crossCount))); } saveHapsWriter.write("|"); } saveHapsWriter.write("\n"); } saveHapsWriter.write("\n"); } saveHapsWriter.close(); }
public void saveHapsToText(Haplotype[][] finishedHaplos, String saveName) throws IOException{ NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); //open file for saving haps text FileWriter saveHapsWriter = new FileWriter(saveHapsFile); int[][]lookupPos = new int[finishedHaplos.length][]; for (int p = 0; p < lookupPos.length; p++){ lookupPos[p] = new int[finishedHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][finishedHaplos[p][q].getListOrder()] = q; //System.out.println(p + " " + q + " " + finishedHaplos[p][q].getListOrder()); } } //go through each block and print haplos for (int i = 0; i < finishedHaplos.length; i++){ //write block header saveHapsWriter.write("BLOCK " + (i+1) + ". MARKERS:"); int[] markerNums = finishedHaplos[i][0].getMarkers(); for (int j = 0; j < finishedHaplos[i].length; j++){ saveHapsWriter.write(" " + (markerNums[j]+1)); } saveHapsWriter.write("\n"); //write haps and crossover percentages for (int j = 0; j < finishedHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; String theHap = new String(); int[] theGeno = finishedHaplos[i][curHapNum].getGeno(); for (int k = 0; k < theGeno.length; k++){ theHap += theGeno[k]; } saveHapsWriter.write(theHap + " (" + nf.format(finishedHaplos[i][curHapNum].getPercentage()) + ")"); if (i < finishedHaplos.length-1){ saveHapsWriter.write("\t|"); for (int crossCount = 0; crossCount < finishedHaplos[i+1].length; crossCount++){ if (crossCount != 0) saveHapsWriter.write("\t"); saveHapsWriter.write(nf.format(finishedHaplos[i][curHapNum].getCrossover(crossCount))); } saveHapsWriter.write("|"); } saveHapsWriter.write("\n"); } saveHapsWriter.write("\n"); } saveHapsWriter.close(); }
1,111,261
public void export(List<SQLTable> tablesToExport) throws SQLException, ArchitectException { logger.debug("Starting export of tables: "+tablesToExport); finished = false; hasStarted = true; Connection con = null; // repository connection Connection tCon = null; // target db connection try { currentDB = tablesToExport; // first, set the logWriter logWriter = new LogWriter(ArchitectSession.getInstance().getUserSettings().getETLUserSettings().getString( ETLUserSettings.PROP_ETL_LOG_PATH, "")); SQLDatabase repository = new SQLDatabase(repositoryDataSource); // we // are // exporting // db // into // this con = repository.getConnection(); try { defParam = new DefaultParameters(con); } catch (PLSchemaException p) { throw new ArchitectException("couldn't load default parameters", p); } SQLDatabase target = new SQLDatabase(targetDataSource); tCon = target.getConnection(); exportResultList.add(new LabelValueBean("\n Creating Power Loader Job", "\n")); sm = null; for (int tryNum = 0; tryNum < 3 && sm == null; tryNum++) { String username; if (tryNum == 1) { username = repositoryDataSource.get(ArchitectDataSource.PL_UID).toUpperCase(); } else if (tryNum == 2) { username = repositoryDataSource.get(ArchitectDataSource.PL_UID).toLowerCase(); } else { username = repositoryDataSource.get(ArchitectDataSource.PL_UID); } try { // don't need to verify passwords in client apps (as opposed // to webapps) sm = new PLSecurityManager(con, username, repositoryDataSource.get(ArchitectDataSource.PL_PWD), false); } catch (PLSecurityException se) { logger.debug("Couldn't find pl user " + username, se); } } if (sm == null) { throw new ArchitectException("There is no entry for \"" + repositoryDataSource.get(ArchitectDataSource.PL_UID) + "\" in the PL_USER table"); } logWriter.info("Starting creation of job <" + jobId + "> at " + new java.util.Date(System.currentTimeMillis())); logWriter.info("Connected to database: " + repositoryDataSource.toString()); maybeInsertFolder(con); PLJob job = new PLJob(jobId); insertJob(con); insertFolderDetail(con, job.getObjectType(), job.getObjectName()); // This will order the target tables so that the parent tables are // loaded before their children DepthFirstSearch targetDFS = new DepthFirstSearch(tablesToExport); List tables = targetDFS.getFinishOrder(); if (logger.isDebugEnabled()) { StringBuffer tableOrder = new StringBuffer(); Iterator dit = tables.iterator(); while (dit.hasNext()) { tableOrder.append(((SQLTable) dit.next()).getName()).append(", "); } logger.debug("Safe load order for job is: " + tableOrder); } int outputTableNum = 1; Hashtable inputTables = new Hashtable(); Iterator targetTableIt = tables.iterator(); while (targetTableIt.hasNext()) { tableCount++; SQLTable outputTable = (SQLTable) targetTableIt.next(); // reset loop variables for each output table boolean createdOutputTableMetaData = false; int transNum = 0; int seqNum = 1; String transName = null; String outputTableId = null; String inputTableId = null; for (SQLColumn outputCol : outputTable.getColumns()) { SQLColumn inputCol = outputCol.getSourceColumn(); if (inputCol != null && !inputTables.keySet().contains(inputCol.getParentTable())) { // create transaction and input table meta data here if // we need to SQLTable inputTable = inputCol.getParentTable(); String baseTransName = PLUtils.toPLIdentifier("LOAD_" + outputTable.getName()); transNum = generateUniqueTransIdx(con, baseTransName); transName = baseTransName + "_" + transNum; logger.debug("transName: " + transName); insertTrans(con, transName, outputTable.getRemarks()); insertFolderDetail(con, "TRANSACTION", transName); insertTransExceptHandler(con, "A", transName, tCon); // error // handling // is // w.r.t. // target // database insertTransExceptHandler(con, "U", transName, tCon); // error // handling // is // w.r.t. // target // database insertTransExceptHandler(con, "D", transName, tCon); // error // handling // is // w.r.t. // target // database insertJobDetail(con, outputTableNum * 10, "TRANSACTION", transName); inputTableId = PLUtils.toPLIdentifier(inputTable.getName() + "_IN_" + transNum); logger.debug("inputTableId: " + inputTableId); insertTransTableFile(con, transName, inputTableId, inputTable, false, transNum); inputTables.put(inputTable, new PLTransaction(transName, inputTableId, transNum)); } else { // restore input/transaction variables PLTransaction plt = (PLTransaction) inputTables.get(inputCol.getParentTable()); transName = plt.getName(); inputTableId = plt.getInputTableId(); transNum = plt.getTransNum(); } if (!createdOutputTableMetaData) { // create output table meta data once logger.debug("outputTableNum: " + outputTableNum); outputTableId = PLUtils.toPLIdentifier(outputTable.getName() + "_OUT_" + outputTableNum); logger.debug("outputTableId: " + outputTableId); insertTransTableFile(con, transName, outputTableId, outputTable, true, transNum); createdOutputTableMetaData = true; } // finally, insert the mapping for this column if (inputCol != null) { // note: output proc seq num appears to be meaningless // based on what the Power Loader // does after you view generated transaction in the VB // Front end. insertTransColMap(con, transName, outputTableId, outputCol, inputTableId, seqNum * 10); } seqNum++; outputTableNum++; } } } finally { hasStarted = false; finished = true; currentDB = null; // close and flush the logWriter (and set the reference to null) logWriter.flush(); logWriter.close(); logWriter = null; try { if (con != null) con.close(); } catch (SQLException e) { logger.error("Couldn't close repository connection", e); } try { if (tCon != null) tCon.close(); } catch (SQLException e) { logger.error("Couldn't close target connection", e); } } }
public void export(List<SQLTable> tablesToExport) throws SQLException, ArchitectException { logger.debug("Starting export of tables: "+tablesToExport); finished = false; hasStarted = true; Connection con = null; // repository connection Connection tCon = null; // target db connection try { currentDB = tablesToExport; // first, set the logWriter logWriter = new LogWriter(ArchitectSessionImpl.getInstance().getUserSettings().getETLUserSettings().getString( ETLUserSettings.PROP_ETL_LOG_PATH, "")); SQLDatabase repository = new SQLDatabase(repositoryDataSource); // we // are // exporting // db // into // this con = repository.getConnection(); try { defParam = new DefaultParameters(con); } catch (PLSchemaException p) { throw new ArchitectException("couldn't load default parameters", p); } SQLDatabase target = new SQLDatabase(targetDataSource); tCon = target.getConnection(); exportResultList.add(new LabelValueBean("\n Creating Power Loader Job", "\n")); sm = null; for (int tryNum = 0; tryNum < 3 && sm == null; tryNum++) { String username; if (tryNum == 1) { username = repositoryDataSource.get(ArchitectDataSource.PL_UID).toUpperCase(); } else if (tryNum == 2) { username = repositoryDataSource.get(ArchitectDataSource.PL_UID).toLowerCase(); } else { username = repositoryDataSource.get(ArchitectDataSource.PL_UID); } try { // don't need to verify passwords in client apps (as opposed // to webapps) sm = new PLSecurityManager(con, username, repositoryDataSource.get(ArchitectDataSource.PL_PWD), false); } catch (PLSecurityException se) { logger.debug("Couldn't find pl user " + username, se); } } if (sm == null) { throw new ArchitectException("There is no entry for \"" + repositoryDataSource.get(ArchitectDataSource.PL_UID) + "\" in the PL_USER table"); } logWriter.info("Starting creation of job <" + jobId + "> at " + new java.util.Date(System.currentTimeMillis())); logWriter.info("Connected to database: " + repositoryDataSource.toString()); maybeInsertFolder(con); PLJob job = new PLJob(jobId); insertJob(con); insertFolderDetail(con, job.getObjectType(), job.getObjectName()); // This will order the target tables so that the parent tables are // loaded before their children DepthFirstSearch targetDFS = new DepthFirstSearch(tablesToExport); List tables = targetDFS.getFinishOrder(); if (logger.isDebugEnabled()) { StringBuffer tableOrder = new StringBuffer(); Iterator dit = tables.iterator(); while (dit.hasNext()) { tableOrder.append(((SQLTable) dit.next()).getName()).append(", "); } logger.debug("Safe load order for job is: " + tableOrder); } int outputTableNum = 1; Hashtable inputTables = new Hashtable(); Iterator targetTableIt = tables.iterator(); while (targetTableIt.hasNext()) { tableCount++; SQLTable outputTable = (SQLTable) targetTableIt.next(); // reset loop variables for each output table boolean createdOutputTableMetaData = false; int transNum = 0; int seqNum = 1; String transName = null; String outputTableId = null; String inputTableId = null; for (SQLColumn outputCol : outputTable.getColumns()) { SQLColumn inputCol = outputCol.getSourceColumn(); if (inputCol != null && !inputTables.keySet().contains(inputCol.getParentTable())) { // create transaction and input table meta data here if // we need to SQLTable inputTable = inputCol.getParentTable(); String baseTransName = PLUtils.toPLIdentifier("LOAD_" + outputTable.getName()); transNum = generateUniqueTransIdx(con, baseTransName); transName = baseTransName + "_" + transNum; logger.debug("transName: " + transName); insertTrans(con, transName, outputTable.getRemarks()); insertFolderDetail(con, "TRANSACTION", transName); insertTransExceptHandler(con, "A", transName, tCon); // error // handling // is // w.r.t. // target // database insertTransExceptHandler(con, "U", transName, tCon); // error // handling // is // w.r.t. // target // database insertTransExceptHandler(con, "D", transName, tCon); // error // handling // is // w.r.t. // target // database insertJobDetail(con, outputTableNum * 10, "TRANSACTION", transName); inputTableId = PLUtils.toPLIdentifier(inputTable.getName() + "_IN_" + transNum); logger.debug("inputTableId: " + inputTableId); insertTransTableFile(con, transName, inputTableId, inputTable, false, transNum); inputTables.put(inputTable, new PLTransaction(transName, inputTableId, transNum)); } else { // restore input/transaction variables PLTransaction plt = (PLTransaction) inputTables.get(inputCol.getParentTable()); transName = plt.getName(); inputTableId = plt.getInputTableId(); transNum = plt.getTransNum(); } if (!createdOutputTableMetaData) { // create output table meta data once logger.debug("outputTableNum: " + outputTableNum); outputTableId = PLUtils.toPLIdentifier(outputTable.getName() + "_OUT_" + outputTableNum); logger.debug("outputTableId: " + outputTableId); insertTransTableFile(con, transName, outputTableId, outputTable, true, transNum); createdOutputTableMetaData = true; } // finally, insert the mapping for this column if (inputCol != null) { // note: output proc seq num appears to be meaningless // based on what the Power Loader // does after you view generated transaction in the VB // Front end. insertTransColMap(con, transName, outputTableId, outputCol, inputTableId, seqNum * 10); } seqNum++; outputTableNum++; } } } finally { hasStarted = false; finished = true; currentDB = null; // close and flush the logWriter (and set the reference to null) logWriter.flush(); logWriter.close(); logWriter = null; try { if (con != null) con.close(); } catch (SQLException e) { logger.error("Couldn't close repository connection", e); } try { if (tCon != null) tCon.close(); } catch (SQLException e) { logger.error("Couldn't close target connection", e); } } }
1,111,262
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } System.out.println(first + " " + last + " " + numStrong); //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return stringVec2intVec(blocks); }
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return stringVec2intVec(blocks); }
1,111,263
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } System.out.println(first + " " + last + " " + numStrong); //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return stringVec2intVec(blocks); }
Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } System.out.println(first + " " + last + " " + numStrong); //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if ((double)numStrong/(double)(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return stringVec2intVec(blocks); }
1,111,264
protected Script compileScript() throws Exception { XMLParser parser = new XMLParser(); parser.setContext(getJellyContext()); Script script = parser.parse(getUrl().openStream()); script = script.compile(); if (log.isDebugEnabled()) { log.debug("Compiled script: " + getUrl()); } return script; }
protected Script compileScript() throws Exception { XMLParser parser = new XMLParser(); parser.setContext(getJellyContext()); Script script = parser.parse(getUrl().toString()); script = script.compile(); if (log.isDebugEnabled()) { log.debug("Compiled script: " + getUrl()); } return script; }
1,111,265
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command==RAW_DATA){ load(PED); }else if (command == PHASED_DATA){ load(HAPS); }else if (command == BROWSE_GENO){ browse(GENO); }else if (command == BROWSE_INFO){ browse(INFO); }else if (command == HAPMAP_DATA){ //hapmap }else if (command == "OK"){ HaploView caller = (HaploView)this.getParent(); String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (fileType == HAPS){ caller.readPhasedGenotypes(returnStrings); }else if (fileType == PED){ caller.readPedGenotypes(returnStrings); } caller.doTDT = this.doTDT.isSelected(); if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); } this.dispose(); }else if (command == "Cancel"){ this.dispose(); } }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command==RAW_DATA){ load(PED); }else if (command == PHASED_DATA){ load(HAPS); }else if (command == BROWSE_GENO){ browse(GENO); }else if (command == BROWSE_INFO){ browse(INFO); }else if (command == HAPMAP_DATA){ //hapmap }else if (command == "OK"){ HaploView caller = (HaploView)this.getParent(); String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; if (fileType == HAPS){ caller.readPhasedGenotypes(returnStrings); }else if (fileType == PED){ caller.readPedGenotypes(returnStrings); } if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); } this.dispose(); }else if (command == "Cancel"){ this.dispose(); } }
1,111,266
void load(int ft){ fileType = ft; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.Y_AXIS)); JPanel topFilePanel = new JPanel(); JPanel botFilePanel = new JPanel(); genoFileField = new JTextField("",20); //workaround for dumb Swing can't requestfocus until shown bug //this one seems to throw a harmless exception in certain versions of the linux JRE try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { genoFileField.requestFocus(); }}); }catch (RuntimeException re){ } //this one seems to really fuck over the 1.3 version of the windows JRE //in short: Java sucks. /*genoFileField.dispatchEvent( new FocusEvent( genoFileField, FocusEvent.FOCUS_GAINED, false ) );*/ infoFileField = new JTextField("",20); JButton browseGenoButton = new JButton("Browse"); browseGenoButton.setActionCommand(BROWSE_GENO); browseGenoButton.addActionListener(this); JButton browseInfoButton = new JButton("Browse"); browseInfoButton.setActionCommand(BROWSE_INFO); browseInfoButton.addActionListener(this); topFilePanel.add(new JLabel("Genotype file: ")); topFilePanel.add(genoFileField); topFilePanel.add(browseGenoButton); botFilePanel.add(new JLabel("Locus information file: ")); botFilePanel.add(infoFileField); botFilePanel.add(browseInfoButton); filePanel.add(topFilePanel); filePanel.add(botFilePanel); filePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); contents.add(filePanel); JPanel prefsPanel = new JPanel(); maxComparisonDistField = new NumberTextField("500",4); prefsPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); prefsPanel.add(maxComparisonDistField); prefsPanel.add(new JLabel("kb apart.")); contents.add(prefsPanel); doTDT = new JCheckBox(); doTDT.setSelected(false); if (ft == PED){ JPanel tdtPanel = new JPanel(); tdtPanel.add(new JLabel("Run family trio TDT? ")); tdtPanel.add(doTDT); contents.add(tdtPanel); } JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); this.getRootPane().setDefaultButton(okButton); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(okButton); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.pack(); }
void load(int ft){ fileType = ft; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.Y_AXIS)); JPanel topFilePanel = new JPanel(); JPanel botFilePanel = new JPanel(); genoFileField = new JTextField("",20); //workaround for dumb Swing can't requestfocus until shown bug //this one seems to throw a harmless exception in certain versions of the linux JRE try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { genoFileField.requestFocus(); }}); }catch (RuntimeException re){ } //this one seems to really fuck over the 1.3 version of the windows JRE //in short: Java sucks. /*genoFileField.dispatchEvent( new FocusEvent( genoFileField, FocusEvent.FOCUS_GAINED, false ) );*/ infoFileField = new JTextField("",20); JButton browseGenoButton = new JButton("Browse"); browseGenoButton.setActionCommand(BROWSE_GENO); browseGenoButton.addActionListener(this); JButton browseInfoButton = new JButton("Browse"); browseInfoButton.setActionCommand(BROWSE_INFO); browseInfoButton.addActionListener(this); topFilePanel.add(new JLabel("Genotype file: ")); topFilePanel.add(genoFileField); topFilePanel.add(browseGenoButton); botFilePanel.add(new JLabel("Locus information file: ")); botFilePanel.add(infoFileField); botFilePanel.add(browseInfoButton); filePanel.add(topFilePanel); filePanel.add(botFilePanel); filePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); contents.add(filePanel); JPanel prefsPanel = new JPanel(); maxComparisonDistField = new NumberTextField("500",4); prefsPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); prefsPanel.add(maxComparisonDistField); prefsPanel.add(new JLabel("kb apart.")); contents.add(prefsPanel); doTDT = new JCheckBox(); doTDT.setSelected(false); if (ft == PED){ JPanel tdtPanel = new JPanel(); tdtPanel.add(new JLabel("Run family trio TDT? ")); tdtPanel.add(doTDT); contents.add(tdtPanel); } JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); this.getRootPane().setDefaultButton(okButton); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(okButton); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.pack(); }
1,111,268
public int doStartTag() throws JspException{ HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); WebContext context = null; try{ context = WebContext.get(request); ApplicationConfig appConfig = context.getApplicationConfig(); // Graphs at cluster level are not supported yet assert !appConfig.isCluster(); String dashboardId = request.getParameter("dashBID"); DashboardConfig currentDashboardConfig = DashboardRepository.getInstance().get(dashboardId); assert currentDashboardConfig != null : "Error retrieving dashboard details"; DashboardComponent component = currentDashboardConfig.getComponents().get(getId()); String componentDisplay = component.draw(new DashboardContextImpl(context, currentDashboardConfig, (HttpServletRequest)pageContext.getRequest())); componentDisplay = MessageFormat.format(componentDisplay, getWidth(), getHeight(), Utils.getCookieValue(request, "JSESSIONID")); pageContext.getOut().println(componentDisplay); }catch(Throwable e){ logger.log(Level.SEVERE, "Error displaying component", e); }finally{ if(context != null) context.releaseResources(); } return SKIP_BODY; }
public int doStartTag() throws JspException{ HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); WebContext context = null; try{ context = WebContext.get(request); ApplicationConfig appConfig = context.getApplicationConfig(); // Graphs at cluster level are not supported yet assert !appConfig.isCluster(); String dashboardId = request.getParameter("dashBID"); DashboardConfig currentDashboardConfig = DashboardRepository.getInstance().get(dashboardId); assert currentDashboardConfig != null : "Error retrieving dashboard details"; DashboardComponent component = currentDashboardConfig.getComponents().get(getId()); String componentDisplay = component.draw(new DashboardContextImpl(context, currentDashboardConfig, (HttpServletRequest)pageContext.getRequest())); componentDisplay = MessageFormat.format(componentDisplay, getWidth(), getHeight(), Utils.getCookieValue(request, "JSESSIONID")); pageContext.getOut().println("<div id=\""+getId()+"\">"+componentDisplay+""); }catch(Throwable e){ logger.log(Level.SEVERE, "Error displaying component", e); }finally{ if(context != null) context.releaseResources(); } return SKIP_BODY; }
1,111,269
public TagScript createCustomTagScript(final String name, Attributes attributes) throws Exception { // custom Ant tags if ( name.equals("fileScanner") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner()); } } ); } if ( name.equals("setProperty") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new SetPropertyTag(); } } ); } return null; }
public TagScript createCustomTagScript(String name, Attributes attributes) throws Exception { // custom Ant tags if ( name.equals("fileScanner") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner()); } } ); } if ( name.equals("setProperty") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new SetPropertyTag(); } } ); } return null; }
1,111,270
public TagScript createCustomTagScript(final String name, Attributes attributes) throws Exception { // custom Ant tags if ( name.equals("fileScanner") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner()); } } ); } if ( name.equals("setProperty") ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { return new SetPropertyTag(); } } ); } return null; }
public TagScript createCustomTagScript(final String name, Attributes attributes) throws Exception { // custom Ant tags if ( name.equals("fileScanner") ) { return new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) throws Exception { return new FileScannerTag(new FileScanner()); } } ); } if ( name.equals("setProperty") ) { return new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) throws Exception { return new SetPropertyTag(); } } ); } return null; }
1,111,271
public Tag createTag() throws Exception { return new FileScannerTag(new FileScanner()); }
public Tag createTag(String name, Attributes attributes) throws Exception { return new FileScannerTag(new FileScanner()); }
1,111,272
public Tag createTag() throws Exception { return new SetPropertyTag(); }
public Tag createTag(String name, Attributes attributes) throws Exception { return new SetPropertyTag(); }
1,111,273
public Tag createTag(String name) throws Exception { AntTag tag = new AntTag( name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return tag; }
public Tag createTag(String name, Attributes attributes) throws Exception { AntTag tag = new AntTag( name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return tag; }
1,111,274
public TagScript createTagScript(final String name, Attributes attributes) throws Exception { TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new TagScript( new TagFactory() { public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); } } ); } return answer; }
public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new TagScript( new TagFactory() { public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); } } ); } return answer; }
1,111,275
public TagScript createTagScript(final String name, Attributes attributes) throws Exception { TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new TagScript( new TagFactory() { public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); } } ); } return answer; }
public TagScript createTagScript(final String name, Attributes attributes) throws Exception { TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new TagScript( new TagFactory() { public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); } } ); } return answer; }
1,111,276
public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); }
public Tag createTag() throws Exception { return AntTagLibrary.this.createTag(name); }
1,111,277
protected String loadText(Reader reader) throws Exception { StringBuffer buffer = new StringBuffer(); // @todo its probably more efficient to use a fixed char[] buffer instead BufferedReader bufferedReader = new BufferedReader(reader); while (true) { String line = bufferedReader.readLine(); if (line == null) { break; } else { buffer.append(line); buffer.append('\n'); } } return buffer.toString(); }
protected String loadText(Reader reader) throws Exception { StringBuffer buffer = new StringBuffer(); // @todo its probably more efficient to use a fixed char[] buffer instead BufferedReader bufferedReader = new BufferedReader(reader); while (true) { String line = bufferedReader.readLine(); if (line == null) { break; } else { buffer.append(line); buffer.append('\n'); } } return buffer.toString(); }
1,111,278