rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
schemaLabel.setText(""); | public void cleanup() throws ArchitectException { logger.debug("SCHEMA POPULATOR IS ABOUT TO CLEAN UP..."); SQLCatalog populatedCat = (SQLCatalog) catalogDropdown .getSelectedItem(); if (populatedCat.isSchemaContainer()) { for (SQLObject item : (List<SQLObject>) populatedCat .getChildren()) { schemaDropdown.addItem(item); } if (schemaDropdown.getItemCount() > 0) { schemaDropdown.setEnabled(true); } } startCompareAction.setEnabled(isStartable()); } |
|
schemaLabel.setText(((SQLSchema)(populatedCat.getChild(0))).getNativeTerm()); | public void cleanup() throws ArchitectException { logger.debug("SCHEMA POPULATOR IS ABOUT TO CLEAN UP..."); SQLCatalog populatedCat = (SQLCatalog) catalogDropdown .getSelectedItem(); if (populatedCat.isSchemaContainer()) { for (SQLObject item : (List<SQLObject>) populatedCat .getChildren()) { schemaDropdown.addItem(item); } if (schemaDropdown.getItemCount() > 0) { schemaDropdown.setEnabled(true); } } startCompareAction.setEnabled(isStartable()); } |
|
builder.append("Catalog"); builder.append("Schema"); | builder.append(catalogLabel = new JLabel("Catalog")); builder.append(schemaLabel = new JLabel("Schema")); | private void buildPartialUI(DefaultFormBuilder builder, boolean defaultPlayPen) { String prefix; if (defaultPlayPen == true) { prefix = "source"; } else { prefix = "target"; } CellConstraints cc = new CellConstraints(); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); playPenRadio = new JRadioButton(); playPenRadio.setName(prefix + "PlayPenRadio"); physicalRadio = new JRadioButton(); physicalRadio.setName(prefix + "PhysicalRadio"); loadRadio = new JRadioButton(); loadRadio.setName(prefix + "LoadRadio"); buttonGroup.add(playPenRadio); buttonGroup.add(physicalRadio); buttonGroup.add(loadRadio); schemaDropdown = new JComboBox(); schemaDropdown.setEnabled(false); schemaDropdown.setName(prefix + "SchemaDropdown"); catalogDropdown = new JComboBox(); catalogDropdown.setEnabled(false); catalogDropdown.setName(prefix + "CatalogDropdown"); databaseDropdown = new JComboBox(); databaseDropdown.setName(prefix + "DatabaseDropdown"); databaseDropdown.addItem(null); // the non-selection selection for (ArchitectDataSource ds : af.getUserSettings().getConnections()) { databaseDropdown.addItem(ds); } databaseDropdown.setEnabled(false); databaseDropdown.setRenderer(dataSourceRenderer); newConnButton = new JButton(); newConnButton.setName(prefix + "NewConnButton"); newConnButton.setAction(newConnectionAction); newConnectionAction.setEnabled(false); loadFilePath = new JTextField(); loadFilePath.setName(prefix + "LoadFilePath"); loadFilePath.setEnabled(false); loadFilePath.getDocument().addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { startCompareAction.setEnabled(isStartable()); } public void removeUpdate(DocumentEvent e) { startCompareAction.setEnabled(isStartable()); } public void changedUpdate(DocumentEvent e) { startCompareAction.setEnabled(isStartable()); } }); loadFileButton = new JButton(); loadFileButton.setName(prefix + "LoadFileButton"); loadFileButton.setAction(chooseFileAction); chooseFileAction.setEnabled(false); catalogDropdown.addActionListener(new SchemaPopulator()); databaseDropdown.addActionListener(new CatalogPopulator()); ActionListener listener = new OptionGroupListener(); playPenRadio.addActionListener(listener); physicalRadio.addActionListener(listener); loadRadio.addActionListener(listener); if (defaultPlayPen) { playPenRadio.doClick(); } else { physicalRadio.doClick(); } // now give all our shiny new components to the builder builder.append(playPenRadio); builder.append("Current Project [" + project.getName() + "]"); builder.nextLine(); builder.append(""); // takes up blank space builder.append(physicalRadio); builder.append("Physical Database"); // builder.nextColumn(2); builder.append("Catalog"); builder.append("Schema"); builder.appendRow(builder.getLineGapSpec()); builder.appendRow("pref"); builder.nextLine(2); builder.nextColumn(4); builder.append(databaseDropdown); builder.append(catalogDropdown, schemaDropdown, newConnButton); builder.nextLine(); builder.append(""); builder.append(loadRadio); builder.append("From File:"); builder.nextLine(); builder.append(""); // takes up blank space builder.add(loadFilePath, cc.xyw(5, builder.getRow(), 5)); builder.nextColumn(8); builder.append(loadFileButton); builder.nextLine(); } |
registerTag("if", IfTag.class); | public XMLTagLibrary() { registerTag("out", ExprTag.class); registerTag("forEach", ForEachTag.class); registerTag("parse", ParseTag.class); registerTag("set", SetTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); } |
|
String attributeValue) { | String attributeValue) throws JellyException { | public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) { if (attributeName.equals("select")) { return new XPathExpression(attributeValue); } // will use the default expression instead return null; } |
if (attributeName.equals("select")) { return new XPathExpression(attributeValue); | if (attributeName.equals("select")) { log.info( "Parsing XPath expression: " + attributeValue ); try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(xpath); } catch (JaxenException e) { throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e ); } | public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) { if (attributeName.equals("select")) { return new XPathExpression(attributeValue); } // will use the default expression instead return null; } |
String id = MailMatchingUtils.getMailIdHeader(message); try { mailProcessingRecord.setByteReceivedTotal(message.getSize()); mailProcessingRecord.setMailId(id); mailProcessingRecord.setSubject(message.getSubject()); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch (MessagingException e) { log.info(queue + ": failed to process mail. remains on server"); return; } finally { MailProcessingRecord matchedAndMergedRecord = results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord != null) { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); results.recordValidatedMatch(matchedAndMergedRecord); } } | String id = MailMatchingUtils.getMailIdHeader(message); try { mailProcessingRecord.setByteReceivedTotal(message.getSize()); | public void handle() throws Exception { MailProcessingRecord mailProcessingRecord = prepareRecord(); MimeMessage message = loadMessage(); // do we _really_ have to handle this? if (!MailMatchingUtils.isMatchCandidate(message)) return; String id = MailMatchingUtils.getMailIdHeader(message); try { mailProcessingRecord.setByteReceivedTotal(message.getSize()); mailProcessingRecord.setMailId(id); mailProcessingRecord.setSubject(message.getSubject()); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch (MessagingException e) { log.info(queue + ": failed to process mail. remains on server"); return; } finally { MailProcessingRecord matchedAndMergedRecord = results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord != null) { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); results.recordValidatedMatch(matchedAndMergedRecord); } } dismissMessage(); } |
dismissMessage(); | mailProcessingRecord.setMailId(id); mailProcessingRecord.setSubject(message.getSubject()); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch (MessagingException e) { log.info(queue + ": failed to process mail. remains on server"); return; } finally { MailProcessingRecord matchedAndMergedRecord = results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord != null) { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); results.recordValidatedMatch(matchedAndMergedRecord); } } dismissMessage(); | public void handle() throws Exception { MailProcessingRecord mailProcessingRecord = prepareRecord(); MimeMessage message = loadMessage(); // do we _really_ have to handle this? if (!MailMatchingUtils.isMatchCandidate(message)) return; String id = MailMatchingUtils.getMailIdHeader(message); try { mailProcessingRecord.setByteReceivedTotal(message.getSize()); mailProcessingRecord.setMailId(id); mailProcessingRecord.setSubject(message.getSubject()); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch (MessagingException e) { log.info(queue + ": failed to process mail. remains on server"); return; } finally { MailProcessingRecord matchedAndMergedRecord = results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord != null) { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); results.recordValidatedMatch(matchedAndMergedRecord); } } dismissMessage(); } |
odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { db = null; } | PhotovaultSettings.setConfiguration( "pv_test" ); String sqldbName = PhotovaultSettings.getConfProperty( "dbname" ); ODMG.initODMG("harri", "r1t1rat1", sqldbName); odmg = ODMG.getODMGImplementation(); db = ODMG.getODMGDatabase(); | public void setUp() { odmg = OJB.getInstance(); db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { // log.warn( "Could not open database: " + e.getMessage() ); db = null; }// tx = odmg.newTransaction();// tx.begin(); } |
String body = getBodyText(); setBeanProperties(); if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); | else { StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = null; // must be a datatype. TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } |
catch (Exception e) { } | tag.doTag(output); | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = null; // must be a datatype. TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } } |
public int getAvgLength() { | public double getAvgLength() { | public int getAvgLength() { return avgLength; } |
public void setAvgLength(int avgLength) { | public void setAvgLength(double avgLength) { | public void setAvgLength(int avgLength) { this.avgLength = avgLength; } |
for (int j = 0; j < theBlock.length-1; j++){ | for (int j = 0; j < theBlock.length; j++){ | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getMarker(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(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < 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(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length-1; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius, left + (2*theBlock[j]+1) * boxSize/2 +boxRadius, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } } |
g.drawLine (left + (2*theBlock[j]+1) * boxSize/2, | g.drawLine (left + (2*theBlock[j]) * boxSize/2 - boxRadius, | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getMarker(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(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < 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(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length-1; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius, left + (2*theBlock[j]+1) * boxSize/2 +boxRadius, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } } |
left + (2*theBlock[j]+1) * boxSize/2 +boxRadius, | left + (2*theBlock[j]) * boxSize/2, | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle visRect = getVisibleRect(); /* boxSize = ((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } */ //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); BasicStroke fatStroke = new BasicStroke(3.0f); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getSize(); i++) { double pos = (Chromosome.getMarker(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(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < 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(Chromosome.realIndex[x] + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks boolean even = true; //g.setColor(new Color(153,255,153)); g.setColor(new Color(51,153,51)); g2.setStroke(fatStroke); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; g.drawLine(left + (2*first + 1) * boxSize/2 - boxRadius, top + boxSize/2, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last - 1) * boxSize/2+boxRadius, top + boxSize/2); for (int j = 0; j < theBlock.length-1; j++){ g.drawLine(left + (2*theBlock[j]+1) * boxSize/2 - boxRadius, top + boxSize/2, left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius); g.drawLine (left + (2*theBlock[j]+1) * boxSize/2, top + boxSize/2 - boxRadius, left + (2*theBlock[j]+1) * boxSize/2 +boxRadius, top + boxSize/2); } } g2.setStroke(thickerStroke); if (pref.getWidth() > (2*visRect.width)){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_MAX_WIDTH = visRect.width/3; double scalefactor; scalefactor = (double)(chartSize.width)/WM_MAX_WIDTH; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-2,worldmap.getHeight()-2); //make a pretty border gw2.setColor(Color.BLACK); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth()-1,worldmap.getHeight()-1); ir = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth()-1, worldmap.getHeight()-1); double prefBoxSize = boxSize/scalefactor; float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } g.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); worldmapRect = new Rectangle(visRect.x, visRect.y+visRect.height-worldmap.getHeight(), worldmap.getWidth(), worldmap.getHeight()); //draw the outline of the viewport g.setColor(Color.BLACK); double hRatio = ir.getWidth()/pref.getWidth(); double vRatio = ir.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-ir.width; int vBump = worldmap.getHeight()-ir.height; //bump a few pixels to avoid drawing on the border g.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } } |
JellyContext ctx = new JellyContext(); | JellyContext ctx = new JellyServletContext(getServletContext()); | protected JellyContext createContext( HttpServletRequest req, HttpServletResponse res) { JellyContext ctx = new JellyContext(); ctx.setVariable(REQUEST, req); ctx.setVariable(RESPONSE, res); return ctx; } |
URL template = getTemplate(req); | protected void doRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { JellyContext context = createContext(req, res); URL template = getTemplate(req); try { runScript(template, context, req, res); } catch (Exception e) { error(req, res, e); } } |
|
runScript(template, context, req, res); | URL script = getScript(req); runScript(script, context, req, res); | protected void doRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { JellyContext context = createContext(req, res); URL template = getTemplate(req); try { runScript(template, context, req, res); } catch (Exception e) { error(req, res, e); } } |
html.append("<h2>JellyServlet : Error processing the template</h2>"); | html.append("<h2>JellyServlet : Error processing the script</h2>"); | protected void error( HttpServletRequest request, HttpServletResponse response, Exception cause) throws ServletException, IOException { StringBuffer html = new StringBuffer(); html.append("<html>"); html.append("<title>Error</title>"); html.append("<body bgcolor=\"#ffffff\">"); html.append("<h2>JellyServlet : Error processing the template</h2>"); html.append("<pre>"); String why = cause.getMessage(); if (why != null && why.trim().length() > 0) { html.append(why); html.append("<br>"); } StringWriter sw = new StringWriter(); cause.printStackTrace(new PrintWriter(sw)); html.append(sw.toString()); html.append("</pre>"); html.append("</body>"); html.append("</html>"); response.getOutputStream().print(html.toString()); } |
String[] oldCommands = new String[consoleHistory .getHistoryList().size()]; consoleHistory.getHistoryList().toArray(oldCommands); consoleReader.addCompletor(new SimpleCompletor(oldCommands)); | ArrayList oldCommandsAsList = useHistoryCompletor ? new ArrayList(consoleHistory.getHistoryList()) : new ArrayList(0); if (completor != null && !completor.isEmpty()) { oldCommandsAsList.addAll(completor); } String[] oldCommands = new String[oldCommandsAsList.size()]; oldCommandsAsList.toArray(oldCommands); consoleReader.addCompletor (new SimpleCompletor (oldCommands)); | public void doTag(XMLOutput output) { if (question != null) { if (defaultInput != null) { System.out.println(question + " [" + defaultInput + "]"); } else { System.out.println(question); } // The prompt should be just before the user's input, // but it doesn't work ... //System.out.print(prompt + " "); } ConsoleReader consoleReader; try { consoleReader = new ConsoleReader(); } catch (IOException e) { logger.warn("couldnt create console reader", e); consoleReader = null; } String disableJlineProp = System.getProperty("ask.jline.disable"); boolean disableJline = (disableJlineProp != null && disableJlineProp .equals("true")); try { if (consoleReader != null && consoleReader.getTerminal().isSupported()) { // resue the static history, so our commands are remeberered consoleReader.setHistory(consoleHistory); // hate the bell! consoleReader.setBellEnabled(false); // add old commands as tab completion history String[] oldCommands = new String[consoleHistory .getHistoryList().size()]; consoleHistory.getHistoryList().toArray(oldCommands); consoleReader.addCompletor(new SimpleCompletor(oldCommands)); // read the input! input = consoleReader.readLine(); // trim the input for tab completion input = input.trim(); if (defaultInput != null && input.trim().equals("")) { input = defaultInput; } } else { BufferedReader reader = new BufferedReader( new InputStreamReader(System.in)); input = reader.readLine(); } } catch (IOException ex) { logger.warn("error setting up the console reader", ex); } context.setVariable(answer, input); } |
JButton okButton = new JButton(okAction); | JDefaultButton okButton = new JDefaultButton(okAction); | public void actionPerformed(ActionEvent evt) { // This is one of the few JDIalogs that can not get replaced // with a call to ArchitectPanelBuilder, because an About // box must have only ONE button... final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "About the Power*Architect"); JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final AboutPanel aboutPanel = new AboutPanel(); cp.add(aboutPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Action okAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { aboutPanel.applyChanges(); d.setVisible(false); } }; okAction.putValue(Action.NAME, "OK"); JButton okButton = new JButton(okAction); buttonPanel.add(okButton); cp.add(buttonPanel, BorderLayout.SOUTH); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.getRootPane().setDefaultButton(okButton); d.setContentPane(cp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } |
fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_START,"Starting new compound edit event in table edit panel")); | public TableEditPanel(SQLTable t) { super(new FormLayout()); addUndoEventListener(ArchitectFrame.getMainInstance().getProject().getUndoManager().getEventAdapter()); add(new JLabel("Table Name")); add(name = new JTextField("", 30)); add(new JLabel("Primary Key Name")); add(pkName = new JTextField("", 30)); add(new JLabel("Remarks")); add(new JScrollPane(remarks = new JTextArea(4, 30))); remarks.setLineWrap(true); remarks.setWrapStyleWord(true); editTable(t); fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_START,"Starting new compound edit event in table edit panel")); } |
|
fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_START,"Starting new compound edit event in table edit panel")); | public boolean applyChanges() { table.setPrimaryKeyName(pkName.getText()); table.setName(name.getText()); table.setRemarks(remarks.getText()); fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_END,"Ending new compound edit event in table edit panel")); return true; } |
|
fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_END,"Ending new compound edit event in table edit panel")); | public void discardChanges() { fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.PROPERTY_CHANGE_GROUP_END,"Ending new compound edit event in table edit panel")); } |
|
getBody().run( context, output); | invokeBody( output); | public void doTag(final XMLOutput output) throws Exception { getGoal(getName()).addPostGoalCallback( new PostGoalCallback() { public void firePostGoal(Goal goal) throws Exception { // lets run the body log.info( "Running post goal: " + getName() ); getBody().run( context, output); } } ); } |
getBody().run( context, output); | invokeBody( output); | public void firePostGoal(Goal goal) throws Exception { // lets run the body log.info( "Running post goal: " + getName() ); getBody().run( context, output); } |
ConnectorConfigRegistry.init(); ConnectorRegistry.load(); | try{ ConnectorConfigRegistry.init(); }catch(Exception e){ logger.log(Level.SEVERE, "Error initializing connector config registry.", e); } try{ ConnectorRegistry.load(); }catch(Exception e){ logger.log(Level.SEVERE, "Error initializing connector registry.", e); } | public static void main(String[] args) throws Exception{ Runtime.getRuntime().addShutdownHook(new Thread(){ public void run(){ logger.info("jManage shutting down..."); DBUtils.shutdownDB(); } }); if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } UserManager userManager = UserManager.getInstance(); User user = null; char[] password = null; int invalidAttempts = 0; if(args.length == 1){ password = args[0].toCharArray(); user = userManager.verifyUsernamePassword( AuthConstants.USER_ADMIN, password); /* invalid password was tried */ if(user == null){ invalidAttempts ++; } } while(user == null){ if(invalidAttempts > 0){ System.out.println("Invalid Admin Password."); } /* get the password */ password = PasswordField.getPassword("Enter password:"); /* the password should match for the admin user */ user = userManager.verifyUsernamePassword( AuthConstants.USER_ADMIN, password); invalidAttempts ++; if(invalidAttempts >= 3){ break; } } /* exit if the admin password is still invalid */ if(user == null){ System.out.println("Number of invalid attempts exceeded. Exiting !"); return; } /* set admin password as the stop key */ final JettyStopKey stopKey = new JettyStopKey(new String(password)); System.setProperty("STOP.KEY", stopKey.toString()); /* set stop.port */ System.setProperty("STOP.PORT", JManageProperties.getStopPort()); /* initialize ServiceFactory */ ServiceFactory.init(ServiceFactory.MODE_LOCAL); /* initialize crypto */ Crypto.init(password); /* clear the password */ Arrays.fill(password, ' '); /* load ACLs */ ACLStore.getInstance(); /* start the AlertEngine */ AlertEngine.getInstance().start(); /* start the application downtime service */ ApplicationDowntimeService.getInstance().start(); /* load connectors */ ConnectorConfigRegistry.init(); ConnectorRegistry.load(); /* start the application */ start(); } |
if(infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when using -doTagging"); | if(infoFileName == null && hapmapFileName == null && batchFileName == null) { die("A marker info file must be specified when tagging."); | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when using -doTagging"); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without -doTagging"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } } |
die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without -doTagging"); | die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without a tagging option"); | private void argHandler(String[] args){ argHandlerMessages = new Vector(); int maxDistance = -1; //this means that user didn't specify any output type if it doesn't get changed below blockOutputType = -1; double hapThresh = -1; double minimumMAF=-1; double spacingThresh = -1; double minimumGenoPercent = -1; double hwCutoff = -1; double missingCutoff = -1; int maxMendel = -1; boolean assocTDT = false; boolean assocCC = false; permutationCount = 0; tagging = Tagger.NONE; maxNumTags = Tagger.DEFAULT_MAXNUMTAGS; findTags = true; double cutHighCI = -1; double cutLowCI = -1; double mafThresh = -1; double recHighCI = -1; double informFrac = -1; double fourGameteCutoff = -1; double spineDP = -1; for(int i =0; i < args.length; i++) { if(args[i].equalsIgnoreCase("-help") || args[i].equalsIgnoreCase("-h")) { System.out.println(HELP_OUTPUT); System.exit(0); } else if(args[i].equalsIgnoreCase("-n") || args[i].equalsIgnoreCase("-nogui")) { nogui = true; } else if(args[i].equalsIgnoreCase("-p") || args[i].equalsIgnoreCase("-pedfile")) { i++; if( i>=args.length || (args[i].charAt(0) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(pedFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-pcloadletter")){ die("PC LOADLETTER?! What the fuck does that mean?!"); } else if (args[i].equalsIgnoreCase("-skipcheck") || args[i].equalsIgnoreCase("--skipcheck")){ skipCheck = true; } else if (args[i].equalsIgnoreCase("-excludeMarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ die("-excludeMarkers requires a list of markers"); } else { StringTokenizer str = new StringTokenizer(args[i],","); try { StringBuffer sb = new StringBuffer(); if (!quietMode) sb.append("Excluding markers: "); while(str.hasMoreTokens()) { String token = str.nextToken(); if(token.indexOf("..") != -1) { int lastIndex = token.indexOf(".."); int rangeStart = Integer.parseInt(token.substring(0,lastIndex)); int rangeEnd = Integer.parseInt(token.substring(lastIndex+2,token.length())); for(int j=rangeStart;j<=rangeEnd;j++) { if (!quietMode) sb.append(j+" "); excludedMarkers.add(new Integer(j)); } } else { if (!quietMode) sb.append(token+" "); excludedMarkers.add(new Integer(token)); } } if (!quietMode) argHandlerMessages.add(sb.toString()); } catch(NumberFormatException nfe) { die("-excludeMarkers argument should be of the format: 1,3,5..8,12"); } } } else if(args[i].equalsIgnoreCase("-ha") || args[i].equalsIgnoreCase("-l") || args[i].equalsIgnoreCase("-haps")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapsFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-info")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(infoFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-hapmap")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(hapmapFileName != null){ argHandlerMessages.add("multiple "+args[i-1] + " arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-k") || args[i].equalsIgnoreCase("-blocks")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; blockOutputType = BLOX_CUSTOM; }else{ die(args[i-1] + " requires a filename"); } } else if (args[i].equalsIgnoreCase("-png")){ outputPNG = true; } else if (args[i].equalsIgnoreCase("-smallpng") || args[i].equalsIgnoreCase("-compressedPNG")){ outputCompressedPNG = true; } else if (args[i].equalsIgnoreCase("-track")){ i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ trackFileName = args[i]; }else{ die("-track requires a filename"); } } else if(args[i].equalsIgnoreCase("-o") || args[i].equalsIgnoreCase("-output") || args[i].equalsIgnoreCase("-blockoutput")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(blockOutputType != -1){ die("Only one block output type argument is allowed."); } if(args[i].equalsIgnoreCase("SFS") || args[i].equalsIgnoreCase("GAB")){ blockOutputType = BLOX_GABRIEL; } else if(args[i].equalsIgnoreCase("GAM")){ blockOutputType = BLOX_4GAM; } else if(args[i].equalsIgnoreCase("MJD") || args[i].equalsIgnoreCase("SPI")){ blockOutputType = BLOX_SPINE; } else if(args[i].equalsIgnoreCase("ALL")) { blockOutputType = BLOX_ALL; } } else { //defaults to SFS output blockOutputType = BLOX_GABRIEL; i--; } } else if(args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--dprime") || args[i].equalsIgnoreCase("-dprime")) { outputDprime = true; } else if (args[i].equalsIgnoreCase("-c") || args[i].equalsIgnoreCase("-check")){ outputCheck = true; } else if (args[i].equalsIgnoreCase("-indcheck")){ individualCheck = true; } else if (args[i].equalsIgnoreCase("-mendel")){ mendel = true; } else if(args[i].equalsIgnoreCase("-m") || args[i].equalsIgnoreCase("-maxdistance")) { i++; maxDistance = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-batch")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ die(args[i-1] + " requires a filename"); } else{ if(batchFileName != null){ argHandlerMessages.add("multiple " + args[i-1] + " arguments found. only last batch file listed will be used"); } batchFileName = args[i]; } } else if(args[i].equalsIgnoreCase("-hapthresh")) { i++; hapThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-spacing")) { i++; spacingThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-minMAF")) { i++; minimumMAF = getDoubleArg(args,i,0,0.5); } else if(args[i].equalsIgnoreCase("-minGeno") || args[i].equalsIgnoreCase("-minGenoPercent")) { i++; minimumGenoPercent = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-hwcutoff")) { i++; hwCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-maxMendel") ) { i++; maxMendel = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-missingcutoff")) { i++; missingCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-assoctdt")) { assocTDT = true; } else if(args[i].equalsIgnoreCase("-assoccc")) { assocCC = true; } else if(args[i].equalsIgnoreCase("-randomcc")){ assocCC = true; randomizeAffection = true; } else if(args[i].equalsIgnoreCase("-ldcolorscheme")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(args[i].equalsIgnoreCase("default")){ Options.setLDColorScheme(STD_SCHEME); } else if(args[i].equalsIgnoreCase("RSQ")){ Options.setLDColorScheme(RSQ_SCHEME); } else if(args[i].equalsIgnoreCase("DPALT") ){ Options.setLDColorScheme(WMF_SCHEME); } else if(args[i].equalsIgnoreCase("GAB")) { Options.setLDColorScheme(GAB_SCHEME); } else if(args[i].equalsIgnoreCase("GAM")) { Options.setLDColorScheme(GAM_SCHEME); } else if(args[i].equalsIgnoreCase("GOLD")) { Options.setLDColorScheme(GOLD_SCHEME); } } else { //defaults to STD color scheme Options.setLDColorScheme(STD_SCHEME); i--; } } else if(args[i].equalsIgnoreCase("-blockCutHighCI")) { i++; cutHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockCutLowCI")) { i++; cutLowCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockMafThresh")) { i++; mafThresh = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockRecHighCI")) { i++; recHighCI = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockInformFrac")) { i++; informFrac = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-block4GamCut")) { i++; fourGameteCutoff = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-blockSpineDP")) { i++; spineDP = getDoubleArg(args,i,0,1); } else if(args[i].equalsIgnoreCase("-permtests")) { i++; doPermutationTest = true; permutationCount = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-customassoc")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ customAssocTestsFileName = args[i]; }else{ die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-aggressiveTagging")) { tagging = Tagger.AGGRESSIVE_TRIPLE; } else if (args[i].equalsIgnoreCase("-pairwiseTagging")){ tagging = Tagger.PAIRWISE_ONLY; } else if (args[i].equalsIgnoreCase("-printalltags")){ Options.setPrintAllTags(true); } else if(args[i].equalsIgnoreCase("-maxNumTags")){ i++; maxNumTags = getIntegerArg(args,i); } else if(args[i].equalsIgnoreCase("-tagrSqCutoff")) { i++; tagRSquaredCutOff = getDoubleArg(args,i,0,1); } else if (args[i].equalsIgnoreCase("-dontaddtags")){ findTags = false; } else if(args[i].equalsIgnoreCase("-tagLODCutoff")) { i++; Options.setTaggerLODCutoff(getDoubleArg(args,i,0,100000)); } else if(args[i].equalsIgnoreCase("-includeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die(args[i-1] + " requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceIncludeTags = new Vector(); while(str.hasMoreTokens()) { forceIncludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-includeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceIncludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-excludeTags")) { i++; if(i>=args.length || args[i].charAt(0) == '-') { die("-excludeTags requires a list of marker names."); } StringTokenizer str = new StringTokenizer(args[i],","); forceExcludeTags = new Vector(); while(str.hasMoreTokens()) { forceExcludeTags.add(str.nextToken()); } } else if (args[i].equalsIgnoreCase("-excludeTagsFile")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { forceExcludeFileName =args[i]; }else { die(args[i-1] + " requires a filename"); } } else if(args[i].equalsIgnoreCase("-chromosome") || args[i].equalsIgnoreCase("-chr")) { i++; if(!(i>=args.length) && !(args[i].charAt(0) == '-')) { chromosomeArg =args[i]; }else { die(args[i-1] + " requires a chromosome name"); } } else if(args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("-quiet")) { quietMode = true; } else { die("invalid parameter specified: " + args[i]); } } int countOptions = 0; if(pedFileName != null) { countOptions++; } if(hapsFileName != null) { countOptions++; } if(hapmapFileName != null) { countOptions++; } if(batchFileName != null) { countOptions++; } if(countOptions > 1) { die("Only one genotype input file may be specified on the command line."); } else if(countOptions == 0 && nogui) { die("You must specify a genotype input file."); } //mess with vars, set defaults, etc if(skipCheck && !quietMode) { argHandlerMessages.add("Skipping genotype file check"); } if(maxDistance == -1){ maxDistance = MAXDIST_DEFAULT; }else{ if (!quietMode) argHandlerMessages.add("Max LD comparison distance = " +maxDistance); } Options.setMaxDistance(maxDistance); if(hapThresh != -1) { Options.setHaplotypeDisplayThreshold(hapThresh); if (!quietMode) argHandlerMessages.add("Haplotype display threshold = " + hapThresh); } if(minimumMAF != -1) { CheckData.mafCut = minimumMAF; if (!quietMode) argHandlerMessages.add("Minimum MAF = " + minimumMAF); } if(minimumGenoPercent != -1) { CheckData.failedGenoCut = (int)(minimumGenoPercent*100); if (!quietMode) argHandlerMessages.add("Minimum SNP genotype % = " + minimumGenoPercent); } if(hwCutoff != -1) { CheckData.hwCut = hwCutoff; if (!quietMode) argHandlerMessages.add("Hardy Weinberg equilibrium p-value cutoff = " + hwCutoff); } if(maxMendel != -1) { CheckData.numMendErrCut = maxMendel; if (!quietMode) argHandlerMessages.add("Maximum number of Mendel errors = "+maxMendel); } if(spacingThresh != -1) { Options.setSpacingThreshold(spacingThresh); if (!quietMode) argHandlerMessages.add("LD display spacing value = "+spacingThresh); } if(missingCutoff != -1) { Options.setMissingThreshold(missingCutoff); if (!quietMode) argHandlerMessages.add("Maximum amount of missing data allowed per individual = "+missingCutoff); } if(cutHighCI != -1) { FindBlocks.cutHighCI = cutHighCI; } if(cutLowCI != -1) { FindBlocks.cutLowCI = cutLowCI; } if(mafThresh != -1) { FindBlocks.mafThresh = mafThresh; } if(recHighCI != -1) { FindBlocks.recHighCI = recHighCI; } if(informFrac != -1) { FindBlocks.informFrac = informFrac; } if(fourGameteCutoff != -1) { FindBlocks.fourGameteCutoff = fourGameteCutoff; } if(spineDP != -1) { FindBlocks.spineDP = spineDP; } if(assocTDT) { Options.setAssocTest(ASSOC_TRIO); }else if(assocCC) { Options.setAssocTest(ASSOC_CC); } if (Options.getAssocTest() != ASSOC_NONE && infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when performing association tests."); } if(doPermutationTest) { if(!assocCC && !assocTDT) { die("An association test type must be specified for permutation tests to be performed."); } } if(customAssocTestsFileName != null) { if(!assocCC && !assocTDT) { die("An association test type must be specified when using a custom association test file."); } if(infoFileName == null) { die("A marker info file must be specified when using a custom association test file."); } } if(tagging != Tagger.NONE) { if(infoFileName == null && hapmapFileName == null) { die("A marker info file must be specified when using -doTagging"); } if(forceExcludeTags == null) { forceExcludeTags = new Vector(); } else if (forceExcludeFileName != null) { die("-excludeTags and -excludeTagsFile cannot both be used"); } if(forceExcludeFileName != null) { File excludeFile = new File(forceExcludeFileName); forceExcludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(excludeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceExcludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -excludeTagsFile."); } } if(forceIncludeTags == null ) { forceIncludeTags = new Vector(); } else if (forceIncludeFileName != null) { die("-includeTags and -includeTagsFile cannot both be used"); } if(forceIncludeFileName != null) { File includeFile = new File(forceIncludeFileName); forceIncludeTags = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(includeFile)); String line; while((line = br.readLine()) != null) { if(line.length() > 0 && line.charAt(0) != '#'){ forceIncludeTags.add(line); } } }catch(IOException ioe) { die("An error occured while reading the file specified by -includeTagsFile."); } } //check that there isn't any overlap between include/exclude lists Vector tempInclude = (Vector) forceIncludeTags.clone(); tempInclude.retainAll(forceExcludeTags); if(tempInclude.size() > 0) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tempInclude.size(); i++) { String s = (String) tempInclude.elementAt(i); sb.append(s).append(","); } die("The following markers appear in both the include and exclude lists: " + sb.toString()); } if(tagRSquaredCutOff != -1) { Options.setTaggerRsqCutoff(tagRSquaredCutOff); } } else if(forceExcludeTags != null || forceIncludeTags != null || tagRSquaredCutOff != -1) { die("-tagrSqCutoff, -excludeTags, -excludeTagsFile, -includeTags and -includeTagsFile cannot be used without -doTagging"); } if(chromosomeArg != null && hapmapFileName != null) { argHandlerMessages.add("-chromosome flag ignored when loading hapmap file"); chromosomeArg = null; } if(chromosomeArg != null) { Chromosome.setDataChrom("chr" + chromosomeArg); } } |
if(logger.isLoggable(Level.FINE)) logger.fine("acl not configured:" + aclName); | public static boolean canAccess(ServiceContext context, String aclName, String targetName){ ACL acl = ACLStore.getInstance().getACL(aclName); if(acl == null){ /* if acl is not specified, user has access by default */ return true; } /* construct ACLContext from ServiceContext */ ACLContext aclContext = getACLContext(context, targetName); if(acl.isAuthorized(aclContext, context.getUser())){ return true; } return false; } |
|
final StatusComponent statusComponent = new StatusComponent("Test"); | final StatusComponent statusComponent = new StatusComponent(); | public static void main(String[] args) { final JFrame jx = new JFrame("Test"); jx.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final StatusComponent statusComponent = new StatusComponent("Test"); statusComponent.setText("Unknown error"); statusComponent.setResult(status); JPanel p = new JPanel(new BorderLayout()); jx.add(p); p.add(statusComponent, BorderLayout.CENTER); JButton toggleButton = new JButton("Toggle"); p.add(toggleButton, BorderLayout.SOUTH); toggleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Just cycle through all the values over and over switch(statusComponent.getResult().getStatus()) { case OK: status = ValidateResult.createValidateResult( Status.WARN, "Warning"); break; case WARN: status = ValidateResult.createValidateResult( Status.FAIL, "Failure"); break; case FAIL: status = ValidateResult.createValidateResult( Status.OK, "Swell"); break; } statusComponent.setResult(status); } }); jx.pack(); jx.setLocation(400, 400); jx.setVisible(true); } |
public StatusComponent(String text) { super(text); setIcon(StatusIcon.getNullIcon()); | public StatusComponent() { this(""); | public StatusComponent(String text) { super(text); setIcon(StatusIcon.getNullIcon()); } |
Stylesheet stylesheet = tag.getStylesheet(); | Stylesheet stylesheet = tag.getStylesheet(); XMLOutput oldOutput = tag.getStylesheetOutput(); tag.setStylesheetOutput(output); | public void doTag(XMLOutput output) throws Exception { StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "<applyTemplates> tag must be inside a <stylesheet> tag" ); } Stylesheet stylesheet = tag.getStylesheet(); Object source = tag.getXPathSource(); if ( select != null ) { stylesheet.applyTemplates( source, select ); } else { stylesheet.applyTemplates( source ); } // #### should support MODE!!! } |
tag.setStylesheetOutput(oldOutput); | public void doTag(XMLOutput output) throws Exception { StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class ); if (tag == null) { throw new JellyException( "<applyTemplates> tag must be inside a <stylesheet> tag" ); } Stylesheet stylesheet = tag.getStylesheet(); Object source = tag.getXPathSource(); if ( select != null ) { stylesheet.applyTemplates( source, select ); } else { stylesheet.applyTemplates( source ); } // #### should support MODE!!! } |
|
String attributeName = list.getLocalName(i); | protected TagScript createStaticTag( final String namespaceURI, final String localName, final String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName ); StaticTagScript script = new StaticTagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new StaticTag( namespaceURI, localName, qName ); } } ); configureTagScript(script); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
|
attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); | attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); script.addAttribute(attrQName, expression); | protected TagScript createStaticTag( final String namespaceURI, final String localName, final String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName ); StaticTagScript script = new StaticTagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new StaticTag( namespaceURI, localName, qName ); } } ); configureTagScript(script); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
taggedSoFar = countTagged; | public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagByVarSeq = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){ PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( maxComparisonDistance == 0 || Math.abs(((SNP)currentVarSeq).getLocation() - ((SNP)snps.get(j)).getLocation()) <= maxComparisonDistance) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } } potentialTagByVarSeq.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); debugPrint("snps to tag: " + sitesToCapture.size()); Vector potentialTags = new Vector(potentialTagByVarSeq.values()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagByVarSeq.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagByVarSeq.get(variantSequence)); } } //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); HashSet newlyTagged = addTag(curPT,potentialTagByVarSeq,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); } //loop until all snps are tagged while(sitesToCapture.size() > 0) { potentialTags = new Vector(potentialTagByVarSeq.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); HashSet newlyTagged = addTag(currentBestTag,potentialTagByVarSeq,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); taggedSoFar = countTagged; } if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } debugPrint("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); debugPrint("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } //we've done the best we can. now we check to see if there's a limit to the //num of tags we're allowed to choose. if (maxNumTags > 0){ //if so we need to chuck out the extras. figure out the utility of each tagSNP //i.e. how many SNPs for which they and their combos are the only tags while (getTagSNPs().size() > maxNumTags){ Vector tagSNPs = getTagSNPs(); potentialTagByVarSeq = new Hashtable(); Hashtable tagSeqByPotentialTag = new Hashtable(); //account for stuff tagged by snps themselves for (int i = 0; i < tagSNPs.size(); i++){ TagSequence ts = (TagSequence) tagSNPs.get(i); PotentialTag pt = new PotentialTag(ts.getSequence()); pt.addTagged(ts.getTagged()); potentialTagByVarSeq.put(ts.getSequence(),pt); tagSeqByPotentialTag.put(pt,ts); } //go through all pt's and add their utilities as members of combos Vector tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); for (int j = 0; j < b.getSnps().size(); j++){ ((PotentialTag)potentialTagByVarSeq.get(b.getSNP(j))).addTagged(ts.getTagged()); } } //now perform the steps of sorting and peeling Vector potTagVec = new Vector(potentialTagByVarSeq.values()); Collections.sort(potTagVec,ptcomp); PotentialTag dumpedPT = (PotentialTag)potTagVec.firstElement(); TagSequence dumpedTS = (TagSequence) tagSeqByPotentialTag.get(dumpedPT); Vector taggedByCurTag = dumpedTS.getTagged(); for (int j = 0; j < taggedByCurTag.size(); j++){ //note for everything tagged by this guy that they're no longer tagged by him VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); if (b.getSnps().contains(dumpedTS.getSequence())){ //this hap tag is now defunct because it was comprised in part by dumpedTS Vector taggedByHap = ts.getTagged(); for (int j = 0; j < taggedByHap.size(); j++){ VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tags.remove(ts); } } tags.remove(dumpedTS); } } int count = 0; double numOver8 = 0; meanRSq = 0; Iterator itr = snps.iterator(); while (itr.hasNext()){ SNP s = (SNP) itr.next(); TagSequence ts = s.getBestTag(); if (ts != null){ double d = getPairwiseComp(s, ts.getSequence()).getRsq(); meanRSq += d; count++; if (d >= 0.8){ numOver8++; } } } meanRSq /= count; percentOver8 = (int) Math.rint((100*numOver8) / count); return new Vector(tags); } |
|
taggedSoFar = countTagged; | public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagByVarSeq = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){ PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( maxComparisonDistance == 0 || Math.abs(((SNP)currentVarSeq).getLocation() - ((SNP)snps.get(j)).getLocation()) <= maxComparisonDistance) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } } potentialTagByVarSeq.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); debugPrint("snps to tag: " + sitesToCapture.size()); Vector potentialTags = new Vector(potentialTagByVarSeq.values()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagByVarSeq.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagByVarSeq.get(variantSequence)); } } //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); HashSet newlyTagged = addTag(curPT,potentialTagByVarSeq,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); } //loop until all snps are tagged while(sitesToCapture.size() > 0) { potentialTags = new Vector(potentialTagByVarSeq.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); HashSet newlyTagged = addTag(currentBestTag,potentialTagByVarSeq,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); taggedSoFar = countTagged; } if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } debugPrint("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); debugPrint("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } //we've done the best we can. now we check to see if there's a limit to the //num of tags we're allowed to choose. if (maxNumTags > 0){ //if so we need to chuck out the extras. figure out the utility of each tagSNP //i.e. how many SNPs for which they and their combos are the only tags while (getTagSNPs().size() > maxNumTags){ Vector tagSNPs = getTagSNPs(); potentialTagByVarSeq = new Hashtable(); Hashtable tagSeqByPotentialTag = new Hashtable(); //account for stuff tagged by snps themselves for (int i = 0; i < tagSNPs.size(); i++){ TagSequence ts = (TagSequence) tagSNPs.get(i); PotentialTag pt = new PotentialTag(ts.getSequence()); pt.addTagged(ts.getTagged()); potentialTagByVarSeq.put(ts.getSequence(),pt); tagSeqByPotentialTag.put(pt,ts); } //go through all pt's and add their utilities as members of combos Vector tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); for (int j = 0; j < b.getSnps().size(); j++){ ((PotentialTag)potentialTagByVarSeq.get(b.getSNP(j))).addTagged(ts.getTagged()); } } //now perform the steps of sorting and peeling Vector potTagVec = new Vector(potentialTagByVarSeq.values()); Collections.sort(potTagVec,ptcomp); PotentialTag dumpedPT = (PotentialTag)potTagVec.firstElement(); TagSequence dumpedTS = (TagSequence) tagSeqByPotentialTag.get(dumpedPT); Vector taggedByCurTag = dumpedTS.getTagged(); for (int j = 0; j < taggedByCurTag.size(); j++){ //note for everything tagged by this guy that they're no longer tagged by him VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); if (b.getSnps().contains(dumpedTS.getSequence())){ //this hap tag is now defunct because it was comprised in part by dumpedTS Vector taggedByHap = ts.getTagged(); for (int j = 0; j < taggedByHap.size(); j++){ VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tags.remove(ts); } } tags.remove(dumpedTS); } } int count = 0; double numOver8 = 0; meanRSq = 0; Iterator itr = snps.iterator(); while (itr.hasNext()){ SNP s = (SNP) itr.next(); TagSequence ts = s.getBestTag(); if (ts != null){ double d = getPairwiseComp(s, ts.getSequence()).getRsq(); meanRSq += d; count++; if (d >= 0.8){ numOver8++; } } } meanRSq /= count; percentOver8 = (int) Math.rint((100*numOver8) / count); return new Vector(tags); } |
|
uitr.remove(); | uitr.remove(); taggedSoFar++; | private void peelBack(Vector tagsToBePeeled){ Hashtable blockTagsByAllele = new Hashtable(); HashSet snpsInBlockTags = new HashSet(); debugPrint("starting peelback. untagged.size() = " + untagged.size()); Vector availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } ListIterator uitr = untagged.listIterator(); //try to tag things that weren't taggable in pairwise with haps while(uitr.hasNext()) { SNP curSnp = (SNP) uitr.next(); HashSet comprehensiveBlock = new HashSet(); comprehensiveBlock.add(curSnp); HashSet victor = curSnp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); alleleCorrelator.phaseAndCache(comprehensiveBlock); LocusCorrelation bestPredictor = null; Vector potentialTests = generateTests(curSnp, (Vector) tags.clone()); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), curSnp); if (lc.getRsq() >= minRSquared){ if (bestPredictor != null){ if (lc.getRsq() > bestPredictor.getRsq()){ bestPredictor = lc; } }else{ bestPredictor= lc; } } } if(bestPredictor != null) { Allele bpAllele = bestPredictor.getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (blockTagsByAllele.containsKey(bpAllele)){ TagSequence ts = (TagSequence)blockTagsByAllele.get(bpAllele); ts.addTagged(curSnp); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(curSnp); tags.add(ts); blockTagsByAllele.put(bpAllele,ts); } uitr.remove(); } } debugPrint("finished attempt at pairwise untaggables. untagged.size() = " + untagged.size()); for (int i = 0; i < tagsToBePeeled.size(); i++){ TagSequence curTag = (TagSequence) tagsToBePeeled.get(i); if (forceInclude.contains(curTag.getSequence()) || snpsInBlockTags.contains(curTag.getSequence())){ continue; } Vector taggedByCurTag = curTag.getTagged(); //a hashset that contains all snps tagged by curtag //and all tag snps in LD with any of them HashSet comprehensiveBlock = new HashSet(); availTagSNPs = new Vector(); for (int j = 0; j < tags.size(); j++){ availTagSNPs.add(((TagSequence)tags.get(j)).getSequence()); } availTagSNPs.remove(curTag.getSequence()); for (int j = 0; j < taggedByCurTag.size(); j++) { SNP snp = (SNP) taggedByCurTag.elementAt(j); comprehensiveBlock.add(snp); HashSet victor = snp.getLDList(); victor.retainAll(availTagSNPs); comprehensiveBlock.addAll(victor); } alleleCorrelator.phaseAndCache(comprehensiveBlock); Hashtable bestPredictor = new Hashtable(); boolean peelSuccessful = true; for (int k = 0; k < taggedByCurTag.size(); k++){ //look to see if we can find a predictor for each thing curTag tags SNP thisTaggable = (SNP) taggedByCurTag.get(k); Vector victor = (Vector) tags.clone(); victor.remove(curTag); Vector potentialTests = generateTests(thisTaggable, victor); for (int j = 0; j < potentialTests.size(); j++){ LocusCorrelation lc = getPairwiseComp((VariantSequence)potentialTests.get(j), thisTaggable); if (lc.getRsq() >= minRSquared){ if (bestPredictor.containsKey(thisTaggable)){ if (lc.getRsq() > ((LocusCorrelation)bestPredictor.get(thisTaggable)).getRsq()){ bestPredictor.put(thisTaggable,lc); } }else{ bestPredictor.put(thisTaggable,lc); } } } if (thisTaggable.getTags().size() == 1 && !bestPredictor.containsKey(thisTaggable)){ peelSuccessful = false; break; } } if (peelSuccessful){ for (int k = 0; k < taggedByCurTag.size(); k++){ SNP thisTaggable = (SNP) taggedByCurTag.get(k); //if more than one snp is tagged by the same if (bestPredictor.containsKey(thisTaggable)){ Allele bpAllele = ((LocusCorrelation)bestPredictor.get(thisTaggable)).getAllele(); snpsInBlockTags.addAll(((Block)bpAllele.getLocus()).getSnps()); if (blockTagsByAllele.containsKey(bpAllele)){ TagSequence ts = (TagSequence)blockTagsByAllele.get(bpAllele); ts.addTagged(thisTaggable); }else{ TagSequence ts = new TagSequence(bpAllele); ts.addTagged(thisTaggable); tags.add(ts); blockTagsByAllele.put(bpAllele,ts); } } thisTaggable.removeTag(curTag); } tags.remove(curTag); } } } |
if ( target == null ) { throw new JellyTagException( "Either a 'var' or a 'target' attribute must be defined for this tag" ); } if ( property == null ) { throw new JellyTagException( "You must define a 'property' attribute if you specify a 'target'" ); } | public void doTag(XMLOutput output) throws JellyTagException { Object answer = null; if ( value != null ) { answer = value.evaluate(context); } else { answer = getBodyText(isEncode()); } if ( var != null ) { if ( scope != null ) { context.setVariable(var, scope, answer); } else { context.setVariable(var, answer); } } else { if ( target == null ) { throw new JellyTagException( "Either a 'var' or a 'target' attribute must be defined for this tag" ); } if ( property == null ) { throw new JellyTagException( "You must define a 'property' attribute if you specify a 'target'" ); } setPropertyValue( target, property, answer ); } } |
|
attributes.put(name, expression); | attributes.put(name, new ExpressionAttribute(name,expression)); | public void addAttribute(String name, Expression expression) { if (log.isDebugEnabled()) { log.debug("adding attribute name: " + name + " expression: " + expression); } attributes.put(name, expression); } |
Expression expression = (Expression) entry.getValue(); | Expression expression = ((ExpressionAttribute) entry.getValue()).exp; | public void run(JellyContext context, XMLOutput output) throws JellyTagException { URL rootURL = context.getRootURL(); URL currentURL = context.getCurrentURL(); try { Tag tag = getTag(context); if ( tag == null ) { return; } tag.setContext(context); setContextURLs(context); if ( tag instanceof DynaTag ) { DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Class type = dynaTag.getAttributeType(name); Object value = null; if (type != null && type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluateRecurse(context); } dynaTag.setAttribute(name, value); } } else { // treat the tag as a bean DynaBean dynaBean = new ConvertingWrapDynaBean( tag ); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); DynaProperty property = dynaBean.getDynaClass().getDynaProperty(name); if (property == null) { throw new JellyException("This tag does not understand the '" + name + "' attribute" ); } Class type = property.getType(); Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluateRecurse(context); } dynaBean.set(name, value); } } tag.doTag(output); if (output != null) { output.flush(); } } catch (JellyTagException e) { handleException(e); } catch (JellyException e) { handleException(e); } catch (IOException e) { handleException(e); } catch (RuntimeException e) { handleException(e); } catch (Error e) { /* * Not sure if we should be converting errors to exceptions, * but not trivial to remove because JUnit tags throw * Errors in the normal course of operation. Hmm... */ handleException(e); } finally { context.setRootURL(rootURL); context.setCurrentURL(currentURL); } } |
PrintStream demuxOut = new PrintStream(new DemuxOutputStream(antProject, false)); PrintStream demuxErr = new PrintStream(new DemuxOutputStream(antProject, true)); System.setOut( demuxOut ); System.setErr( demuxErr ); */ | public void doTag(XMLOutput output) throws Exception { // force project to be lazily constructed getProject(); org.apache.tools.ant.Project antProject = AntTagLibrary.getProject( context ); // allow access to Ant methods via the project class context.setVariable( "project", antProject ); antProject.getBuildListeners().clear(); antProject.addBuildListener( new JellyBuildListener( output ) ); getBody().run(context, output); } |
|
this.out = out; | this.out = out; this.debug = false; | public JellyBuildListener(XMLOutput out) { this.taskStack = new Stack(); this.out = out; } |
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { if ((rawDataSource == null) && dataSourceSpecified) { throw new JellyException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context); try { conn = dataSource.getConnection(); origIsolation = conn.getTransactionIsolation(); if (origIsolation == Connection.TRANSACTION_NONE) { throw new JellyException(Resources.getMessage("TRANSACTION_NO_SUPPORT")); } if ((isolation != Connection.TRANSACTION_NONE) && (isolation != origIsolation)) { conn.setTransactionIsolation(isolation); } conn.setAutoCommit(false); } catch (SQLException e) { throw new JellyException( Resources.getMessage("ERROR_GET_CONNECTION", e.getMessage())); } boolean finished = false; try { getBody().run(context, output); finished = true; } catch (Exception e) { if (conn != null) { try { conn.rollback(); } catch (SQLException s) { // Ignore to not hide orignal exception } doFinally(); } throw e; } // lets commit try { conn.commit(); } catch (SQLException e) { throw new JellyException( Resources.getMessage("TRANSACTION_COMMIT_ERROR", e.getMessage())); } finally { doFinally(); } } |
logger.debug("about to show playpen tablepane popup..."); | public void maybeShowPopup(MouseEvent evt) { if (evt.isPopupTrigger() && !evt.isConsumed()) { TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = tp.getPlayPen(); // this allows the right-click menu to work on multiple tables simultaneously if (!tp.isSelected()) { pp.selectNone(); tp.setSelected(true); } try { // tp.selectNone(); // single column selection model for now int idx = tp.pointToColumnIndex(evt.getPoint()); if (idx >= 0) { tp.selectColumn(idx); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); return; } tp.showPopup(pp.tablePanePopup, evt.getPoint()); } } |
|
try { reader = new InputStreamReader(in, encoding); } catch (UnsupportedEncodingException e) { throw new JellyTagException("unsupported encoding",e); | if (encoding != null) { try { reader = new InputStreamReader(in, encoding); } catch (UnsupportedEncodingException e) { throw new JellyTagException("unsupported encoding",e); } } else { reader = new InputStreamReader(in); | public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException("var"); } if (file == null && uri == null) { throw new JellyTagException( "This tag must have a 'file' or 'uri' specified" ); } InputStream in = null; if (file != null) { if (! file.exists()) { throw new JellyTagException( "The file: " + file + " does not exist" ); } try { in = new FileInputStream(file); } catch (FileNotFoundException e) { throw new JellyTagException("could not find the file",e); } } else { in = context.getResourceAsStream(uri); if (in == null) { throw new JellyTagException( "Could not find uri: " + uri ); } } Reader reader = null; try { reader = new InputStreamReader(in, encoding); } catch (UnsupportedEncodingException e) { throw new JellyTagException("unsupported encoding",e); } String text = null; try { text = loadText(reader); } catch (IOException e) { throw new JellyTagException(e); } context.setVariable(var, text); } |
childContext.setVariable(var, childContext); | childContext.setVariable(var, message); | public void doTag(XMLOutput output) throws JellyTagException { ConsumerTag tag = (ConsumerTag) findAncestorWithClass(ConsumerTag.class); if (tag == null) { throw new JellyTagException("This tag must be nested within a ConsumerTag like the subscribe tag"); } final JellyContext childContext = context.newJellyContext(); final Script script = getBody(); final XMLOutput childOutput = output; MessageListener listener = new MessageListener() { public void onMessage(Message message) { childContext.setVariable(var, childContext); try { script.run(childContext, childOutput); } catch (Exception e) { log.error("Caught exception processing message: " + message + ". Exception: " + e, e); } } }; // perform the consumption tag.setMessageListener(listener); } |
childContext.setVariable(var, childContext); | childContext.setVariable(var, message); | public void onMessage(Message message) { childContext.setVariable(var, childContext); try { script.run(childContext, childOutput); } catch (Exception e) { log.error("Caught exception processing message: " + message + ". Exception: " + e, e); } } |
if (thisPair == null){ continue; } | Vector doMJD(){ // find blocks by searching for stretches between two markers A,B where // D prime is > 0.8 for all informative combinations of A, (A+1...B) // set coloring based on LOD and D' for (int i = 0; i < dPrime.length; i++){ for (int j = i+1; j < dPrime[i].length; j++){ PairwiseLinkage thisPair = dPrime[i][j]; if (thisPair == null){ continue; } double d = thisPair.getDPrime(); double l = thisPair.getLOD(); Color boxColor = null; if (l > 2) { if (d < 0.5) { //high LOD, low D' boxColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red double blgr = (255-32)*2*(1-d); //boxColor = new Color(255, (int) blgr, (int) blgr); boxColor = new Color(224, (int) blgr, (int) blgr); } } else if (d > 0.99) { //high D', low LOD blueish color boxColor = new Color(192, 192, 240); } else { //no LD boxColor = Color.white; } thisPair.setColor(boxColor); } } int baddies; int verticalExtent=0; int horizontalExtent=0; Vector blocks = new Vector(); for (int i = 0; i < dPrime.length; i++){ baddies=0; //find how far LD from marker i extends for (int j = i+1; j < dPrime[i].length; j++){ PairwiseLinkage thisPair = dPrime[i][j]; if (thisPair == null){ continue; } //LD extends if D' > 0.8 if (thisPair.getDPrime() < 0.8){ //LD extends through one 'bad' marker if (baddies < 1){ baddies++; } else { verticalExtent = j-1; break; } } verticalExtent=j; } //now we need to find a stretch of LD of all markers between i and j //start with the longest possible block of LD and work backwards to find //one which is good for (int m = verticalExtent; m > i; m--){ for (int k = i; k < m; k++){ PairwiseLinkage thisPair = dPrime[k][m]; if(thisPair.getDPrime() < 0.8){ if (baddies < 1){ baddies++; } else { break; } } horizontalExtent=k+1; } //is this a block of LD? //previously, this algorithm was more complex and made some calls better //but caused major problems in others. since the guessing is somewhat //arbitrary, this new and simple method is fine. if(horizontalExtent == m){ blocks.add(i + " " + m); i=m; } } } return stringVec2intVec(blocks); } |
|
if (((SNP)markerInfo.elementAt(x)).getMAF() < mafThresh){ | if (Chromosome.getMarker(x).getMAF() < mafThresh){ | Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double mafThresh = 0.10; double[] cutLowCIVar = {0,0,0.80,0.50,0.50}; double[] maxDist = {0,0,20000,30000,1000000}; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first set up a filter of markers which fail the MAF threshhold boolean[] skipMarker = new boolean[dPrime.length]; for (int x = 0; x < dPrime.length; x++){ if (((SNP)markerInfo.elementAt(x)).getMAF() < mafThresh){ skipMarker[x]=true; }else{ skipMarker[x]=false; } } //next 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]; if (thisPair == null){ continue; } //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); //color in squares if (lowCI > cutLowCI && highCI >= cutHighCI) { thisPair.setColor(new Color(224, 0, 0)); //strong LD }else if (highCI > recHighCI) { thisPair.setColor(new Color(192, 192, 240)); //uninformative } else { thisPair.setColor(Color.white); //recomb } if (skipMarker[x] || skipMarker[y]) continue; 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 long sep; //compute actual separation sep = ((SNP)markerInfo.elementAt(y)).getPosition() - ((SNP)markerInfo.elementAt(x)).getPosition(); 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 boolean unplaced = true; for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); unplaced = false; break; } } if (unplaced){strongPairs.add(addMe);} } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; Vector thisBlock; int[] blockArray; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; thisBlock = new Vector(); int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); int sep = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //next, count the number of markers in the block. for (int x = first; x <=last ; x++){ if(!skipMarker[x]) numInGroup++; } //skip it if it is too long in bases for it's size in markers if (numInGroup < 4 && sep > maxDist[numInGroup]) continue; thisBlock.add(new Integer(first)); //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ if (skipMarker[y]) continue; thisBlock.add(new Integer(y)); //loop over columns in row y for (int x = first; x < y; x++){ if (skipMarker[x]) continue; PairwiseLinkage thisPair = dPrime[x][y]; if (thisPair == null){ continue; } //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 //for small blocks use different CI cutoffs if (numInGroup < 5){ if (lowCI > cutLowCIVar[numInGroup] && highCI >= cutHighCI) numStrong++; }else{ if (lowCI > cutLowCI && highCI >= cutHighCI) numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination } } //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; } blockArray = new int[thisBlock.size()]; for (int z = 0; z < thisBlock.size(); z++){ blockArray[z] = ((Integer)thisBlock.elementAt(z)).intValue(); } // System.out.println(first + " " + last + " " + numStrong + " " + numRec); 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(blockArray); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ if (first < ((int[])blocks.elementAt(b))[0]){ blocks.insertElementAt(blockArray, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(blockArray); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return blocks; } |
sep = ((SNP)markerInfo.elementAt(y)).getPosition() - ((SNP)markerInfo.elementAt(x)).getPosition(); | sep = Chromosome.getMarker(y).getPosition() - Chromosome.getMarker(x).getPosition(); | Vector doSFS(){ double cutHighCI = 0.98; double cutLowCI = 0.70; double mafThresh = 0.10; double[] cutLowCIVar = {0,0,0.80,0.50,0.50}; double[] maxDist = {0,0,20000,30000,1000000}; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first set up a filter of markers which fail the MAF threshhold boolean[] skipMarker = new boolean[dPrime.length]; for (int x = 0; x < dPrime.length; x++){ if (((SNP)markerInfo.elementAt(x)).getMAF() < mafThresh){ skipMarker[x]=true; }else{ skipMarker[x]=false; } } //next 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]; if (thisPair == null){ continue; } //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); //color in squares if (lowCI > cutLowCI && highCI >= cutHighCI) { thisPair.setColor(new Color(224, 0, 0)); //strong LD }else if (highCI > recHighCI) { thisPair.setColor(new Color(192, 192, 240)); //uninformative } else { thisPair.setColor(Color.white); //recomb } if (skipMarker[x] || skipMarker[y]) continue; 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 long sep; //compute actual separation sep = ((SNP)markerInfo.elementAt(y)).getPosition() - ((SNP)markerInfo.elementAt(x)).getPosition(); 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 boolean unplaced = true; for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); unplaced = false; break; } } if (unplaced){strongPairs.add(addMe);} } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; Vector thisBlock; int[] blockArray; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; thisBlock = new Vector(); int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); int sep = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //next, count the number of markers in the block. for (int x = first; x <=last ; x++){ if(!skipMarker[x]) numInGroup++; } //skip it if it is too long in bases for it's size in markers if (numInGroup < 4 && sep > maxDist[numInGroup]) continue; thisBlock.add(new Integer(first)); //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ if (skipMarker[y]) continue; thisBlock.add(new Integer(y)); //loop over columns in row y for (int x = first; x < y; x++){ if (skipMarker[x]) continue; PairwiseLinkage thisPair = dPrime[x][y]; if (thisPair == null){ continue; } //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 //for small blocks use different CI cutoffs if (numInGroup < 5){ if (lowCI > cutLowCIVar[numInGroup] && highCI >= cutHighCI) numStrong++; }else{ if (lowCI > cutLowCI && highCI >= cutHighCI) numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination } } //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; } blockArray = new int[thisBlock.size()]; for (int z = 0; z < thisBlock.size(); z++){ blockArray[z] = ((Integer)thisBlock.elementAt(z)).intValue(); } // System.out.println(first + " " + last + " " + numStrong + " " + numRec); 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(blockArray); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ if (first < ((int[])blocks.elementAt(b))[0]){ blocks.insertElementAt(blockArray, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(blockArray); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return blocks; } |
double mafThresh = 0.10; | double mafThresh = 0.05; | static Vector doSFS(PairwiseLinkage[][] dPrime){ double cutHighCI = 0.98; double cutLowCI = 0.70; double mafThresh = 0.10; double[] cutLowCIVar = {0,0,0.80,0.50,0.50}; double[] maxDist = {0,0,20000,30000,1000000}; double recHighCI = 0.90; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first set up a filter of markers which fail the MAF threshhold boolean[] skipMarker = new boolean[dPrime.length]; for (int x = 0; x < dPrime.length; x++){ if (Chromosome.getFilteredMarker(x).getMAF() < mafThresh){ skipMarker[x]=true; }else{ skipMarker[x]=false; } } //next 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]; if (thisPair == null){ continue; } //get the right bits double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); //color in squares if (lowCI > cutLowCI && highCI >= cutHighCI) { thisPair.setColor(new Color(224, 0, 0)); //strong LD }else if (highCI > recHighCI) { thisPair.setColor(new Color(192, 192, 240)); //uninformative } else { thisPair.setColor(Color.white); //recomb } if (skipMarker[x] || skipMarker[y]) continue; 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 long sep; //compute actual separation sep = Chromosome.getFilteredMarker(y).getPosition() - Chromosome.getFilteredMarker(x).getPosition(); 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 boolean unplaced = true; for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); unplaced = false; break; } } if (unplaced){strongPairs.add(addMe);} } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; Vector thisBlock; int[] blockArray; for (int v = 0; v < strongPairs.size(); v++){ numStrong = 0; numRec = 0; numInGroup = 0; thisBlock = new Vector(); int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); int sep = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //next, count the number of markers in the block. for (int x = first; x <=last ; x++){ if(!skipMarker[x]) numInGroup++; } //skip it if it is too long in bases for it's size in markers if (numInGroup < 4 && sep > maxDist[numInGroup]) continue; thisBlock.add(new Integer(first)); //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ if (skipMarker[y]) continue; thisBlock.add(new Integer(y)); //loop over columns in row y for (int x = first; x < y; x++){ if (skipMarker[x]) continue; PairwiseLinkage thisPair = dPrime[x][y]; if (thisPair == null){ continue; } //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 //for small blocks use different CI cutoffs if (numInGroup < 5){ if (lowCI > cutLowCIVar[numInGroup] && highCI >= cutHighCI) numStrong++; }else{ if (lowCI > cutLowCI && highCI >= cutHighCI) numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination } } //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; } blockArray = new int[thisBlock.size()]; for (int z = 0; z < thisBlock.size(); z++){ blockArray[z] = ((Integer)thisBlock.elementAt(z)).intValue(); } // System.out.println(first + " " + last + " " + numStrong + " " + numRec); 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(blockArray); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ if (first < ((int[])blocks.elementAt(b))[0]){ blocks.insertElementAt(blockArray, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(blockArray); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return blocks; } |
validateAppName(config.getName()); | validateAppName(config.getName(), null); | public static void addApplication(ApplicationConfig config) throws DuplicateApplicationNameException { synchronized(writeLock){ // validate the application name validateAppName(config.getName()); applicationConfigs.add(config); saveConfig(); } } |
validateAppName(config.getName()); | validateAppName(config.getName(), config.getApplicationId()); | public static void updateApplication(ApplicationConfig config) throws DuplicateApplicationNameException { assert config != null: "application config is null"; synchronized(writeLock){ // validate the application name validateAppName(config.getName()); int index = applicationConfigs.indexOf(config); if(index != -1){ applicationConfigs.remove(index); applicationConfigs.add(index, config); }else{ /* its part of a cluster */ assert config.isCluster() == false; ApplicationConfig clusterConfig = config.getClusterConfig(); assert clusterConfig != null; index = clusterConfig.getApplications().indexOf(config); assert index != -1: "application not found in cluster"; clusterConfig.getApplications().remove(index); clusterConfig.getApplications().add(index, config); } saveConfig(); } } |
private static void validateAppName(String appName) | private static void validateAppName(String appName, String applicationId) | private static void validateAppName(String appName) throws DuplicateApplicationNameException { for(Iterator it=getApplications().iterator(); it.hasNext(); ){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if((appConfig.getName().toUpperCase()).equals(appName.toUpperCase())) { throw new DuplicateApplicationNameException(appName); } } } |
if((appConfig.getName().toUpperCase()).equals(appName.toUpperCase())) { | if(!appConfig.getApplicationId().equals(applicationId) && (appConfig.getName().toUpperCase()).equals(appName.toUpperCase())) { | private static void validateAppName(String appName) throws DuplicateApplicationNameException { for(Iterator it=getApplications().iterator(); it.hasNext(); ){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if((appConfig.getName().toUpperCase()).equals(appName.toUpperCase())) { throw new DuplicateApplicationNameException(appName); } } } |
} | logger.debug("min:("+minx+","+miny+"),max:("+maxx+","+maxy+")"); } | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); } } Dimension min = getMinimumSize(); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width || vpSize.height > usedSpace.height) { return vpSize; } } // default return usedSpace; } |
Dimension userDim = new Dimension(maxx-minx,maxy-miny); logger.debug("userDim is: " + userDim); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); } } Dimension min = getMinimumSize(); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width || vpSize.height > usedSpace.height) { return vpSize; } } // default return usedSpace; } |
|
if (vpSize.width > usedSpace.width || | if (vpSize.width > usedSpace.width && | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); } } Dimension min = getMinimumSize(); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width || vpSize.height > usedSpace.height) { return vpSize; } } // default return usedSpace; } |
logger.debug("preferred size is usedSpace?: " + usedSpace); | public Dimension getPreferredSize() { Rectangle cbounds = null; //int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE, maxx = 0, maxy = 0; int minx = 0, miny = 0, maxx = 0, maxy = 0; for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); if (c.isVisible()) { cbounds = c.getBounds(cbounds); minx = Math.min(cbounds.x, minx); miny = Math.min(cbounds.y, miny); maxx = Math.max(cbounds.x + cbounds.width , maxx); maxy = Math.max(cbounds.y + cbounds.height, maxy); } } Dimension min = getMinimumSize(); Dimension usedSpace = new Dimension((int) ((double) Math.max(maxx - minx, min.width) * zoom), (int) ((double) Math.max(maxy - miny, min.height) * zoom)); // but, make sure we return a preferred size that is at least as big as the Viewport Dimension vpSize = getViewportSize(); if (vpSize != null) { if (vpSize.width > usedSpace.width || vpSize.height > usedSpace.height) { return vpSize; } } // default return usedSpace; } |
|
logger.debug("viewport size is NULL"); | public Dimension getViewportSize() { Container c = SwingUtilities.getAncestorOfClass(JViewport.class, this); if (c != null) { JViewport jvp = (JViewport) c; return jvp.getSize(); } else { return null; } } |
|
Integer suffix = (Integer) tableNames.get(key); if (suffix == null) { tableNames.put(key, new Integer(0)); } else { int newSuffix = suffix.intValue()+1; tableNames.put(key, new Integer(newSuffix)); | logger.debug("before add: " + Arrays.toString(tableNames.toArray())); if (!tableNames.add(key)) { boolean done = false; int newSuffix = 0; while (!done) { newSuffix++; done = tableNames.add(key+"_"+newSuffix); } | public synchronized TablePane importTableCopy(SQLTable source, Point preferredLocation) throws ArchitectException { SQLTable newTable = SQLTable.getDerivedInstance(source, db); // adds newTable to db String key = source.getTableName().toLowerCase(); Integer suffix = (Integer) tableNames.get(key); if (suffix == null) { tableNames.put(key, new Integer(0)); } else { int newSuffix = suffix.intValue()+1; tableNames.put(key, new Integer(newSuffix)); newTable.setTableName(source.getTableName()+"_"+newSuffix); } TablePane tp = new TablePane(newTable); logger.info("adding table "+newTable); add(tp, preferredLocation); tp.revalidate(); // create exported relationships if the importing tables exist in pp Iterator sourceKeys = source.getExportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isInfoEnabled()) { logger.info("Looking for fk table "+r.getFkTable().getName()+" in playpen"); } TablePane fkTablePane = findTablePaneByName(r.getFkTable().getName()); if (fkTablePane != null) { logger.info("FOUND IT!"); SQLTable fkTable = fkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(newTable); newTable.addExportedKey(newRel); newRel.setFkTable(fkTable); fkTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = newTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = fkTable.getColumnByName(m.getFkColumn().getName()); if (pkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink pkCol "+m.getPkColumn().getName()+" in new table"); } if (fkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } // create imported relationships if the exporting tables exist in pp sourceKeys = source.getImportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isDebugEnabled()) { logger.info("Looking for pk table "+r.getPkTable().getName()+" in playpen"); } TablePane pkTablePane = findTablePaneByName(r.getPkTable().getName()); if (pkTablePane != null) { logger.info("FOUND IT!"); SQLTable pkTable = pkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(pkTable); pkTable.addExportedKey(newRel); newRel.setFkTable(newTable); newTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = pkTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = newTable.getColumnByName(m.getFkColumn().getName()); if (fkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink fkCol "+m.getPkColumn().getName()+" in new table"); } if (pkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } return tp; } |
logger.debug("after add: " + Arrays.toString(tableNames.toArray())); | public synchronized TablePane importTableCopy(SQLTable source, Point preferredLocation) throws ArchitectException { SQLTable newTable = SQLTable.getDerivedInstance(source, db); // adds newTable to db String key = source.getTableName().toLowerCase(); Integer suffix = (Integer) tableNames.get(key); if (suffix == null) { tableNames.put(key, new Integer(0)); } else { int newSuffix = suffix.intValue()+1; tableNames.put(key, new Integer(newSuffix)); newTable.setTableName(source.getTableName()+"_"+newSuffix); } TablePane tp = new TablePane(newTable); logger.info("adding table "+newTable); add(tp, preferredLocation); tp.revalidate(); // create exported relationships if the importing tables exist in pp Iterator sourceKeys = source.getExportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isInfoEnabled()) { logger.info("Looking for fk table "+r.getFkTable().getName()+" in playpen"); } TablePane fkTablePane = findTablePaneByName(r.getFkTable().getName()); if (fkTablePane != null) { logger.info("FOUND IT!"); SQLTable fkTable = fkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(newTable); newTable.addExportedKey(newRel); newRel.setFkTable(fkTable); fkTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = newTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = fkTable.getColumnByName(m.getFkColumn().getName()); if (pkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink pkCol "+m.getPkColumn().getName()+" in new table"); } if (fkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } // create imported relationships if the exporting tables exist in pp sourceKeys = source.getImportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isDebugEnabled()) { logger.info("Looking for pk table "+r.getPkTable().getName()+" in playpen"); } TablePane pkTablePane = findTablePaneByName(r.getPkTable().getName()); if (pkTablePane != null) { logger.info("FOUND IT!"); SQLTable pkTable = pkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(pkTable); pkTable.addExportedKey(newRel); newRel.setFkTable(newTable); newTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = pkTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = newTable.getColumnByName(m.getFkColumn().getName()); if (fkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink fkCol "+m.getPkColumn().getName()+" in new table"); } if (pkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } return tp; } |
|
tableNames = new HashMap(); | tableNames = new HashSet(); | public void setDatabase(SQLDatabase newdb) { if (newdb == null) throw new NullPointerException("db must be non-null"); this.db = newdb; db.setIgnoreReset(true); if (db.getConnectionSpec() == null) { DBConnectionSpec dbcs = new DBConnectionSpec(); dbcs.setName("Target Database"); dbcs.setDisplayName("Target Database"); db.setConnectionSpec(dbcs); } try { ArchitectUtils.listenToHierarchy(this, db); } catch (ArchitectException ex) { logger.error("Couldn't listen to database", ex); } tableNames = new HashMap(); } |
mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); | void setupTablePanePopup() { ArchitectFrame af = ArchitectFrame.getMainInstance(); tablePanePopup = new JPopupMenu(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(af.insertColumnAction); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem(); mi.setAction(af.editTableAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(bringToFrontAction); tablePanePopup.add(mi); mi = new JMenuItem(); mi.setAction(sendToBackAction); tablePanePopup.add(mi); tablePanePopup.addSeparator(); mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); tablePanePopup.add(mi); if (logger.isDebugEnabled()) { tablePanePopup.addSeparator(); mi = new JMenuItem("Show listeners"); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { List selection = getSelectedItems(); if (selection.size() == 1) { TablePane tp = (TablePane) selection.get(0); JOptionPane.showMessageDialog(tp, new JScrollPane(new JList(new java.util.Vector(tp.getModel().getSQLObjectListeners())))); } else { JOptionPane.showMessageDialog(PlayPen.this, "You can only show listeners on one item at a time"); } } }); tablePanePopup.add(mi); mi = new JMenuItem("Show Selection List"); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { List selection = getSelectedItems(); if (selection.size() == 1) { TablePane tp = (TablePane) selection.get(0); JOptionPane.showMessageDialog(tp, new JScrollPane(new JList(new java.util.Vector(tp.columnSelection)))); } else { JOptionPane.showMessageDialog(PlayPen.this, "You can only show selected columns on one item at a time"); } } }); tablePanePopup.add(mi); } } |
|
if (dbcsDialog == null) { final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Target Database Connection"); JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(db.getConnectionSpec()); cp.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(cp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); dbcsDialog = d; } | final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Target Database Connection"); JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(db.getConnectionSpec()); cp.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(cp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); dbcsDialog = d; | public void showDbcsDialog() { if (dbcsDialog == null) { final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Target Database Connection"); JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(db.getConnectionSpec()); cp.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(cp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); dbcsDialog = d; } dbcsDialog.setVisible(true); } |
parent.populateColumns(); | public void populate() throws ArchitectException { try { if (type == COLUMNS) { parent.populateColumns(); } else if (type == IMPORTED_KEYS) { parent.populateRelationships(); } else if (type == EXPORTED_KEYS) { // XXX: not implemented yet } else { throw new IllegalArgumentException("Unknown folder type: "+type); } } finally { populated = true; } } |
|
populate(); | populateColumns(); | public synchronized List getColumns() throws ArchitectException { populate(); return columnsFolder.getChildren(); } |
source.populate(); | source.populateColumns(); source.populateRelationships(); | public static SQLTable getDerivedInstance(SQLTable source, SQLDatabase parent) throws ArchitectException { source.populate(); SQLTable t = new SQLTable(parent); t.columnsFolder.populated = true; t.importedKeysFolder.populated = true; t.exportedKeysFolder.populated = true; t.tableName = source.tableName; t.remarks = source.remarks; t.primaryKeyName = source.getName()+"_pk"; t.inherit(source); parent.addChild(t); return t; } |
if (columnsFolder == null || importedKeysFolder == null || exportedKeysFolder == null) { return false; } else { return columnsFolder.isPopulated() && importedKeysFolder.isPopulated() && exportedKeysFolder.isPopulated(); } | return true; | public boolean isPopulated() { if (columnsFolder == null || importedKeysFolder == null || exportedKeysFolder == null) { return false; } else { return columnsFolder.isPopulated() && importedKeysFolder.isPopulated() && exportedKeysFolder.isPopulated(); } } |
populateColumns(); populateRelationships(); | public void populate() throws ArchitectException { populateColumns(); populateRelationships(); } |
|
SQLRelationship.addRelationshipsToTable(this); | SQLRelationship.addImportedRelationshipsToTable(this); | public synchronized void populateRelationships() throws ArchitectException { if (!columnsFolder.isPopulated()) throw new IllegalStateException("Table must be populated before relationships are added"); if (importedKeysFolder.isPopulated()) return; int oldSize = importedKeysFolder.children.size(); try { SQLRelationship.addRelationshipsToTable(this); } finally { importedKeysFolder.populated = true; int newSize = importedKeysFolder.children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } try { importedKeysFolder.fireDbChildrenInserted (changedIndices, importedKeysFolder.children.subList(oldSize, newSize)); } catch (IndexOutOfBoundsException ex) { logger.error("Index out of bounds while adding imported keys to table " +getName()+" where oldSize="+oldSize+"; newSize="+newSize +"; imported keys="+importedKeysFolder.children); } } } } |
importedKeysFolder.populated = true; | public synchronized void populateRelationships() throws ArchitectException { if (!columnsFolder.isPopulated()) throw new IllegalStateException("Table must be populated before relationships are added"); if (importedKeysFolder.isPopulated()) return; int oldSize = importedKeysFolder.children.size(); try { SQLRelationship.addRelationshipsToTable(this); } finally { importedKeysFolder.populated = true; int newSize = importedKeysFolder.children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } try { importedKeysFolder.fireDbChildrenInserted (changedIndices, importedKeysFolder.children.subList(oldSize, newSize)); } catch (IndexOutOfBoundsException ex) { logger.error("Index out of bounds while adding imported keys to table " +getName()+" where oldSize="+oldSize+"; newSize="+newSize +"; imported keys="+importedKeysFolder.children); } } } } |
|
fileMenu.setMnemonic(KeyEvent.VK_F); | menuItem = new JMenuItem("Check for update"); menuItem.addActionListener(this); fileMenu.add(menuItem); fileMenu.addSeparator(); | public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); gbrowseItem = new JMenuItem(DOWNLOAD_GBROWSE); gbrowseItem.addActionListener(this); gbrowseItem.setEnabled(false); fileMenu.add(gbrowseItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } colorMenuItems[Options.getLDColorScheme()].setSelected(true); displayMenu.add(colorMenu); spacingItem = new JMenuItem("LD Display Spacing"); spacingItem.setMnemonic(KeyEvent.VK_S); spacingItem.addActionListener(this); spacingItem.setEnabled(false); displayMenu.add(spacingItem); displayMenu.setEnabled(false); //analysis menu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); analysisMenu.setEnabled(false); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* Configuration.readConfigFile(); if(Configuration.isCheckForUpdate()) { Object[] options = {"Yes", "Not now", "Never ask again"}; int n = JOptionPane.showOptionDialog(this, "Would you like to check if a new version " + "of haploview is available?", "Check for update", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if(n == JOptionPane.YES_OPTION) { UpdateChecker uc = new UpdateChecker(); if(uc.checkForUpdate()) { JOptionPane.showMessageDialog(this, "A new version of Haploview is available!\n Visit http://www.broad.mit.edu/mpg/haploview/ to download the new version\n (current version: " + Constants.VERSION + " newest version: " + uc.getNewVersion() + ")" , "Update Available", JOptionPane.INFORMATION_MESSAGE); } } else if(n == JOptionPane.CANCEL_OPTION) { Configuration.setCheckForUpdate(false); Configuration.writeConfigFile(); } } */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
fileMenu.setMnemonic(KeyEvent.VK_F); | public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); gbrowseItem = new JMenuItem(DOWNLOAD_GBROWSE); gbrowseItem.addActionListener(this); gbrowseItem.setEnabled(false); fileMenu.add(gbrowseItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } colorMenuItems[Options.getLDColorScheme()].setSelected(true); displayMenu.add(colorMenu); spacingItem = new JMenuItem("LD Display Spacing"); spacingItem.setMnemonic(KeyEvent.VK_S); spacingItem.addActionListener(this); spacingItem.setEnabled(false); displayMenu.add(spacingItem); displayMenu.setEnabled(false); //analysis menu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); analysisMenu.setEnabled(false); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* Configuration.readConfigFile(); if(Configuration.isCheckForUpdate()) { Object[] options = {"Yes", "Not now", "Never ask again"}; int n = JOptionPane.showOptionDialog(this, "Would you like to check if a new version " + "of haploview is available?", "Check for update", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if(n == JOptionPane.YES_OPTION) { UpdateChecker uc = new UpdateChecker(); if(uc.checkForUpdate()) { JOptionPane.showMessageDialog(this, "A new version of Haploview is available!\n Visit http://www.broad.mit.edu/mpg/haploview/ to download the new version\n (current version: " + Constants.VERSION + " newest version: " + uc.getNewVersion() + ")" , "Update Available", JOptionPane.INFORMATION_MESSAGE); } } else if(n == JOptionPane.CANCEL_OPTION) { Configuration.setCheckForUpdate(false); Configuration.writeConfigFile(); } } */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
} else if (command.equals("Quit")){ | } else if(command.equals("Check for update")) { final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { UpdateDisplayDialog udp = new UpdateDisplayDialog(window,"Update Check",uc); udp.pack(); udp.setVisible(true); } else { JOptionPane.showMessageDialog(window, "Your version of Haploview is up to date.", "Update Check", JOptionPane.INFORMATION_MESSAGE); } } window.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }; setCursor(new Cursor(Cursor.WAIT_CURSOR)); worker.start(); }else if (command.equals("Quit")){ | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(READ_GENOTYPES)){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command.equals(READ_MARKERS)){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command.equals(READ_ANALYSIS_TRACK)){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command.equals(DOWNLOAD_GBROWSE)){ GBrowseDialog gbd = new GBrowseDialog(this, "Connect to HapMap Info Server"); gbd.pack(); gbd.setVisible(true); }else if (command.equals(READ_BLOCKS_FILE)){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command.equals(CUST_BLOCKS)){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command.equals(CLEAR_BLOCKS)){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); /*for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true);*/ //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue()); dPrimeDisplay.colorDPrime(); changeKey(); //exporting clauses }else if (command.equals(EXPORT_PNG)){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command.equals(EXPORT_TEXT)){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command.equals(EXPORT_OPTIONS)){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command.equals("Select All")){ checkPanel.selectAll(); }else if (command.equals("Rescore Markers")){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); JTable jt = checkPanel.getTable(); jt.repaint(); }else if (command.equals("LD Display Spacing")){ ProportionalSpacingDialog spaceDialog = new ProportionalSpacingDialog(this, "Adjust LD Spacing"); spaceDialog.pack(); spaceDialog.setVisible(true); }else if (command.equals("Tutorial")){ showHelp(); } else if (command.equals("Quit")){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command.equals(viewItems[i])) tabs.setSelectedIndex(i); } } } |
public Object construct(){ dPrimeDisplay=null; changeKey(); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); if (checkPanel != null){ JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc = new JTabbedPane(); try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } metaAssoc.add("Single Marker", tdtPanel); HaploAssocPanel htp = new HaploAssocPanel(theData.getHaplotypes()); metaAssoc.add("Haplotypes", htp); tabs.addTab("Association Results", metaAssoc); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); | public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); | public Object construct(){ dPrimeDisplay=null; changeKey(); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(window); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(Options.getAssocTest() != ASSOC_NONE) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; JTabbedPane metaAssoc = new JTabbedPane(); try{ tdtPanel = new TDTPanel(theData.getPedFile()); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } metaAssoc.add("Single Marker", tdtPanel); HaploAssocPanel htp = new HaploAssocPanel(theData.getHaplotypes()); metaAssoc.add("Haplotypes", htp); tabs.addTab("Association Results", metaAssoc); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } |
JLayeredPane jlp = window.getLayeredPane(); JLabel updateLabel = new JLabel("test"); updateLabel.setBounds(100,100,200,200); updateLabel.setOpaque(true); updateLabel.setBackground(Color.red); jlp.add(updateLabel, JLayeredPane.POPUP_LAYER); window.setLayeredPane(jlp); | final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.BOLD, 12); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new Timer(); updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6500); | public static void main(String[] args) { //set defaults Options.setMissingThreshold(1.0); Options.setSpacingThreshold(0.0); Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); Options.setLDColorScheme(STD_SCHEME); Options.setShowGBrowse(false); //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up JLayeredPane jlp = window.getLayeredPane(); JLabel updateLabel = new JLabel("test"); updateLabel.setBounds(100,100,200,200); updateLabel.setOpaque(true); updateLabel.setBackground(Color.red); //updateLabel.setBorder(BorderFactory.createCompoundBorder()); jlp.add(updateLabel, JLayeredPane.POPUP_LAYER); window.setLayeredPane(jlp); } } } }; worker.start(); //setup view object window.setTitle(TITLE_STRING); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); //parse command line stuff for input files or prompt data dialog String[] inputArray = new String[2]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
window.setTitle(TITLE_STRING); window.setSize(800,600); | public static void main(String[] args) { //set defaults Options.setMissingThreshold(1.0); Options.setSpacingThreshold(0.0); Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); Options.setLDColorScheme(STD_SCHEME); Options.setShowGBrowse(false); //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up JLayeredPane jlp = window.getLayeredPane(); JLabel updateLabel = new JLabel("test"); updateLabel.setBounds(100,100,200,200); updateLabel.setOpaque(true); updateLabel.setBackground(Color.red); //updateLabel.setBorder(BorderFactory.createCompoundBorder()); jlp.add(updateLabel, JLayeredPane.POPUP_LAYER); window.setLayeredPane(jlp); } } } }; worker.start(); //setup view object window.setTitle(TITLE_STRING); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); //parse command line stuff for input files or prompt data dialog String[] inputArray = new String[2]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
|
assert getName() != null; | public boolean execute() { try { CommandHandler handler = CommandHandlerFactory.getHandler(getName()); return handler.execute(new HandlerContext(this)); } catch (InvalidCommandException e) { throw new RuntimeException(e); } } |
|
Document document = null; if (xml == null) { document = parseBody(output); } else { document = parse(xml); } | Document document = getXmlDocument(output); | public void doTag(XMLOutput output) throws Exception { if (getVar() == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Document document = null; if (xml == null) { document = parseBody(output); } else { document = parse(xml); } context.setVariable(getVar(), document); } |
registerTag("transform", TransformTag.class); | public XMLTagLibrary() { registerTag("out", ExprTag.class); registerTag("if", IfTag.class); registerTag("forEach", ForEachTag.class); registerTag("parse", ParseTag.class); registerTag("set", SetTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("element", ElementTag.class); registerTag("attribute", AttributeTag.class); registerTag("copy", CopyTag.class); registerTag("copyOf", CopyOfTag.class); } |
|
nfMarker.setGroupingUsed(false); | public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getUnfilteredSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.setColor(this.getBackground()); g.fillRect(0,0,pref.width, pref.height); if (!forExport){ g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(Locale.US); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(Locale.US); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(Locale.US); int markerCount = Chromosome.getUnfilteredSize(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; //block labels g.setColor(Color.black); g.drawString("Block " + (i+1), left, top - CHAR_HEIGHT); for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(Chromosome.realIndex[markerNums[z]]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; //figure out which allele is the major allele for each marker int[] majorAllele = new int[filteredHaplos[i][0].getGeno().length]; for (int k = 0; k < majorAllele.length; k++){ majorAllele[k] = Chromosome.getMarker(markerNums[k]).getMajor(); } for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) if (alleleDisp == 0){ g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else if (alleleDisp == 1){ g.drawImage(blackNumImages[theGeno[k]], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); }else{ if (theGeno[k] == majorAllele[k]){ g.setColor(dullBlue); }else{ g.setColor(dullRed); } g.fillRect(left + k*CHAR_WIDTH, above + j*ROW_HEIGHT + (ROW_HEIGHT - CHAR_WIDTH)/2, CHAR_WIDTH, CHAR_WIDTH); } } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines double crossValue = (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); if (multidprimeArray[i] > 0.99){ //draw 1.0 vals specially g.drawImage(blackNumImages[1], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[10], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 2*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); g.drawImage(blackNumImages[0], left + (LINE_SPAN - 9*CHAR_WIDTH/2)/2 + 3*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); }else{ for (int m = 0; m < 3; m++) { g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } } } left += LINE_SPAN; } } |
|
for(Iterator it=application.getApplications().iterator(); it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); | for(ApplicationConfig appConfig : application.getApplications()){ | private Element createApplicationClusterElement(ApplicationConfig application){ assert application.isCluster(); Element applicationElement = createApplicationElement(application); Element childApplicationsElement = new Element(ConfigConstants.APPLICATIONS); applicationElement.addContent(childApplicationsElement); for(Iterator it=application.getApplications().iterator(); it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); Element childAppElement = createApplicationElement(appConfig); childApplicationsElement.addContent(childAppElement); } return applicationElement; } |
if(!application.isCluster()){ Element dashboardsElement = createDashboardsElement(application); applicationElement.addContent(dashboardsElement); } | private Element createApplicationElement(ApplicationConfig application){ Element applicationElement = null; if(application.isCluster()){ applicationElement = new Element(ConfigConstants.APPLICATION_CLUSTER); }else{ applicationElement = new Element(ConfigConstants.APPLICATION); } // <application id="1234" name="Weblogic 6.1" server="localhost" port="7001" username="system" password="12345678" type="Weblogic"> applicationElement.setAttribute(ConfigConstants.APPLICATION_ID, application.getApplicationId()); applicationElement.setAttribute(ConfigConstants.APPLICATION_NAME, application.getName()); if(application.getHost() != null){ applicationElement.setAttribute(ConfigConstants.HOST, application.getHost()); applicationElement.setAttribute(ConfigConstants.PORT, String.valueOf(application.getPort())); } if(application.getURL() != null){ applicationElement.setAttribute(ConfigConstants.URL, application.getURL()); } if(application.getUsername() != null){ applicationElement.setAttribute(ConfigConstants.USERNAME, application.getUsername()); } if(application.getPassword() != null){ String encryptedPassword = Crypto.encryptToString(application.getPassword()); applicationElement.setAttribute(ConfigConstants.PASSWORD, encryptedPassword); } if(!application.isCluster()){ applicationElement.setAttribute(ConfigConstants.APPLICATION_TYPE, application.getType()); } final Map params = application.getParamValues(); if(params != null){ for(Iterator param=params.keySet().iterator(); param.hasNext(); ){ String paramName = (String)param.next(); Element paramElement = new Element(ConfigConstants.PARAMETER); Element paramNameElement = new Element(ConfigConstants.PARAMETER_NAME); Element paramValueElement = new Element(ConfigConstants.PARAMETER_VALUE); paramNameElement.setText(paramName); paramValueElement.setText((String)params.get(paramName)); paramElement.addContent(paramNameElement); paramElement.addContent(paramValueElement); applicationElement.addContent(paramElement); } } /* add mbeans */ Element mbeansElement = createMBeansElement(application); applicationElement.addContent(mbeansElement); /* add alerts*/ Element alertsElement = createAlertsElement(application); applicationElement.addContent(alertsElement); if(!application.isCluster()){ /* add graphs */ Element graphsElement = createGraphsElement(application); applicationElement.addContent(graphsElement); } return applicationElement; } |
|
public java.util.List listMissingTargetTables() { logger.error("listMissingTargetTables is not implemented"); return java.util.Collections.EMPTY_LIST; | public List listMissingTargetTables() throws SQLException, ArchitectException { List missingTables = new LinkedList(); Iterator targetTableIt = playpen.getDatabase().getTables().iterator(); while (targetTableIt.hasNext()) { SQLTable t = (SQLTable) targetTableIt.next(); String tableStatus = checkTargetTable(t); if (tableStatus != null) { missingTables.add(tableStatus); } } return missingTables; | public java.util.List listMissingTargetTables() { logger.error("listMissingTargetTables is not implemented"); return java.util.Collections.EMPTY_LIST; } |
logger.debug("run PL LOADER Engine"); | logger.debug("Running PL Engine"); | public synchronized void setupDialog() { if (d != null) return; d = new JDialog(ArchitectFrame.getMainInstance(), "Export ETL Transactions to PL Repository"); // set export defaults if necessary if (plexp.getFolderName() == null || plexp.getFolderName().trim().length() == 0) { plexp.setFolderName(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_FOLDER")); } if (plexp.getJobId() == null || plexp.getJobId().trim().length() == 0) { plexp.setJobId(PLUtils.toPLIdentifier(architectFrame.getProject().getName()+"_JOB")); } JPanel plp = new JPanel(new BorderLayout(12,12)); plp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final PLExportPanel plPanel = new PLExportPanel(); plPanel.setPLExport(plexp); plp.add(plPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.applyChanges(); if (plexp.getPlDBCS() == null) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getPlUsername().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader User Name.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getJobId().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader Job ID.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { plexp.export(playpen.getDatabase()); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getPLConnectionSpec().getEngineExeutableName()); StringBuffer commandLine = new StringBuffer(1000); commandLine.append(engineExe.getPath()); commandLine.append(" USER_PROMPT=N"); commandLine.append(" JOB=").append(plexp.getJobId()); commandLine.append(" USER=").append(plPanel.getPLConnectionSpec().getEngineConnectString()); commandLine.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); commandLine.append(" APPEND_TO_JOB_ERR_IND=N"); commandLine.append(" SHOW_PROGRESS=100" ); logger.debug(commandLine.toString()); try { Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc)); d.pack(); d.setLocationRelativeTo(plPanel); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } finally { d.setVisible(false); } } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { plPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); plp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(plp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); } |
logger.debug("run PL LOADER Engine"); | logger.debug("Running PL Engine"); | public void actionPerformed(ActionEvent evt) { plPanel.applyChanges(); if (plexp.getPlDBCS() == null) { JOptionPane.showMessageDialog(plPanel, "You have to select a target database from the list.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getPlUsername().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader User Name.", "Error", JOptionPane.ERROR_MESSAGE); return; } if (plexp.getJobId().trim().length() == 0) { JOptionPane.showMessageDialog(plPanel, "You have to specify the PowerLoader Job ID.", "Error", JOptionPane.ERROR_MESSAGE); return; } try { plexp.export(playpen.getDatabase()); if (plPanel.isSelectedRunPLEngine()) { logger.debug("run PL LOADER Engine"); File plIni = new File(architectFrame.getUserSettings().getETLUserSettings().getPlDotIniPath()); File plDir = plIni.getParentFile(); File engineExe = new File(plDir, plPanel.getPLConnectionSpec().getEngineExeutableName()); StringBuffer commandLine = new StringBuffer(1000); commandLine.append(engineExe.getPath()); commandLine.append(" USER_PROMPT=N"); commandLine.append(" JOB=").append(plexp.getJobId()); commandLine.append(" USER=").append(plPanel.getPLConnectionSpec().getEngineConnectString()); commandLine.append(" DEBUG=N SEND_EMAIL=N SKIP_PACKAGES=N CALC_DETAIL_STATS=N COMMIT_FREQ=100 APPEND_TO_JOB_LOG_IND=N"); commandLine.append(" APPEND_TO_JOB_ERR_IND=N"); commandLine.append(" SHOW_PROGRESS=100" ); logger.debug(commandLine.toString()); try { Process proc = Runtime.getRuntime().exec(commandLine.toString()); JDialog d = new JDialog(architectFrame, "Power*Loader Engine"); d.setContentPane(new EngineExecPanel(commandLine.toString(), proc)); d.pack(); d.setLocationRelativeTo(plPanel); d.setVisible(true); } catch (IOException ie){ JOptionPane.showMessageDialog(playpen, "Unexpected Exception running Engine:\n"+ie); logger.error(ie); } } } catch (PLSecurityException ex) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+ex.getMessage()); logger.error("Got exception while exporting Trans", ex); } catch (SQLException esql) { JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+esql.getMessage()); logger.error("Got exception while exporting Trans", esql); } catch (ArchitectException arex){ JOptionPane.showMessageDialog (architectFrame, "Can't export Transaction: "+arex.getMessage()); logger.error("Got exception while exporting Trans", arex); } finally { d.setVisible(false); } } |
Relationship r = new Relationship(pp, pkTable, fkTable, identifying); | SQLRelationship model = new SQLRelationship(); model.setName(pkTable.getModel().getName()+"_"+fkTable.getModel().getName()+"_fk"); model.setIdentifying(identifying); model.setPkTable(pkTable.getModel()); model.setFkTable(fkTable.getModel()); pkTable.getModel().addExportedKey(model); fkTable.getModel().addImportedKey(model); java.util.List pkColListCopy = new ArrayList(pkTable.getModel().getColumns().size()); pkColListCopy.addAll(pkTable.getModel().getColumns()); Iterator pkCols = pkColListCopy.iterator(); while (pkCols.hasNext()) { SQLColumn pkCol = (SQLColumn) pkCols.next(); if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol = (SQLColumn) pkCol.clone(); SQLColumn match = fkTable.getModel().getColumnByName(pkCol.getName()); if (match != null) { if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { fkCol = match; } else { int decision = JOptionPane.showConfirmDialog(pp, "The primary key column " + pkCol.getName() + " already exists " + " in the child table. Continue using new name " + pkCol.getName() + "_1 ?", "Column Name Conflict", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.YES_OPTION) { fkCol.setName(generateUniqueColumnName(pkCol,fkTable.getModel())); } else { model = null; return; } fkTable.getModel().addColumn(fkCol); } } else { fkTable.getModel().addColumn(fkCol); } if (identifying && fkCol.getPrimaryKeySeq() == null) { fkCol.setPrimaryKeySeq(new Integer(fkTable.getModel().pkSize())); } model.addMapping(pkCol, fkCol); } Relationship r = new Relationship(pp, model); | protected void doCreateRelationship() { try { Relationship r = new Relationship(pp, pkTable, fkTable, identifying); pp.add(r); r.repaint(); // XXX: shouldn't be necessary, but it is. } catch (ArchitectException ex) { logger.error("Couldn't create relationship", ex); JOptionPane.showMessageDialog(pp, "Couldn't create relationship: "+ex.getMessage()); } } |
tag.setAttributeValue( getName(), getBodyText( false ) ); | tag.setAttributeValue(getName(), getBodyText(false), getURI()); | public void doTag(XMLOutput output) throws JellyTagException { ElementTag tag = (ElementTag) findAncestorWithClass( ElementTag.class ); if ( tag == null ) { throw new JellyTagException( "<attribute> tag must be enclosed inside an <element> tag" ); } tag.setAttributeValue( getName(), getBodyText( false ) ); } |
} catch (ConnectionFailedException e){ | } catch (Exception e){ | public boolean isQualified(ApplicationConfig applicationConfig) { ServerConnection serverConnection = null; try { serverConnection = ServerConnector.getServerConnection(applicationConfig); ObjectInfo objectInfo = serverConnection.getObjectInfo(objectName); return objectInfo != null; } catch (ConnectionFailedException e){ logger.log(Level.FINE, new StringBuilder().append( "Error finding mbean "+objectName+" for:").append( applicationConfig.getName()).toString(), e); } finally{ ServiceUtils.close(serverConnection); } return false; } |
public CheckDataException(String s){ super(s); | public CheckDataException() { super(); | public CheckDataException(String s){ super(s); } |
super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; if (!isNew) { oldName = dbcsPanel.getDbcs().getName(); } else { oldName = null; } | this(dbcsPanel, isNew, ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni()); | public DBCS_OkAction(DBCSPanel dbcsPanel, boolean isNew) { super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; if (!isNew) { oldName = dbcsPanel.getDbcs().getName(); } else { oldName = null; } } |
PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); | public void actionPerformed(ActionEvent e) { logger.debug("DBCS Action invoked"); ArchitectDataSource newDS = dbcsPanel.getDbcs(); String curName = null; for (Component c : ((TextPanel)dbcsPanel.getComponents()[0]).getComponents()) { if ("dbNameField".equals(c.getName())){ curName = ((JTextField) c).getText(); } } if (curName == null ) { throw new ArchitectRuntimeException(new ArchitectException("DBCS Panel improperly intialized")); } if (isNew) { dbcsPanel.applyChanges(); if ("".equals(newDS.getName().trim())) { JOptionPane.showMessageDialog(newConnectionDialog,"A connection must have at least 1 character that is not whitespace"); newConnectionDialog.setVisible(true); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); if (plDotIni.getDataSource(newDS.getName()) == null ) { plDotIni.addDataSource(newDS); if (connectionSelectionCallBack != null) { connectionSelectionCallBack.selectDBConnection(newDS); } } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+curName+"\" already exists"); newConnectionDialog.setVisible(true); } } } else if ("".equals(curName.trim())) { JOptionPane.showMessageDialog(newConnectionDialog,"A connection must have at least 1 character that is not whitespace"); newConnectionDialog.setVisible(true); } else if (curName.equals(oldName)) { logger.debug("The current Name is the same as the old name"); dbcsPanel.applyChanges(); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); ArchitectDataSource dataSource = plDotIni.getDataSource(curName); if (dataSource == null ) { dbcsPanel.applyChanges(); } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+curName+"\" already exists"); newConnectionDialog.setVisible(true); } } } |
|
null, | appForm.getURL(), | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { ApplicationForm appForm = (ApplicationForm)actionForm; String appId = ApplicationConfig.getNextApplicationId(); Integer port = appForm.getPort() != null && !"".equals(appForm.getPort()) ? new Integer(appForm.getPort()) : null; ApplicationConfig config = ApplicationConfigFactory.create(appId, appForm.getName(), appForm.getType(), appForm.getHost(), port, null, appForm.getUsername(), appForm.getPassword(), null); ApplicationConfigManager.addApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application "+ "\""+config.getName()+"\""); return mapping.findForward(Forwards.SUCCESS); } |
byte a1 = currentInd.getMarkerA(i); byte a2 = currentInd.getMarkerB(i); | byte a1 = a[0]; byte a2 = a[1]; | private void buildCCSet(PedFile pf, Vector affectedStatus, TreeSet snpsToBeTested){ ArrayList results = new ArrayList(); int numMarkers = Chromosome.getUnfilteredSize(); Vector indList = pf.getUnrelatedIndividuals(); int numInds = indList.size(); if(affectedStatus == null || affectedStatus.size() != indList.size()) { affectedStatus = new Vector(indList.size()); for(int i=0;i<indList.size();i++) { Individual tempInd = ((Individual)indList.get(i)); affectedStatus.add(new Integer(tempInd.getAffectedStatus())); } } boolean[] useable = new boolean[indList.size()]; Arrays.fill(useable, false); //this loop determines who is eligible to be used for the case/control association test for(int i=0;i<useable.length;i++) { Individual tempInd = ((Individual)indList.get(i)); Family tempFam = pf.getFamily(tempInd.getFamilyID()); //need to check to make sure we don't include both parents and kids of trios //so, we only set useable[i] to true if Individual at index i is not the child of a trio in the indList if (!(tempFam.containsMember(tempInd.getMomID()) && tempFam.containsMember(tempInd.getDadID()))){ useable[i] = true; } else{ try{ if (!(indList.contains(tempFam.getMember(tempInd.getMomID())) || indList.contains(tempFam.getMember(tempInd.getDadID())))){ useable[i] = true; } }catch (PedFileException pfe){ } } } for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ byte allele1 = 0, allele2 = 0; int[][] counts = new int[2][2]; Individual currentInd; for (int j = 0; j < numInds; j++){ if(useable[j]) { currentInd = (Individual)indList.get(j); int cc = ((Integer)affectedStatus.get(j)).intValue(); if (cc == 0) continue; if (cc == 2) cc = 0; byte a1 = currentInd.getMarkerA(i); byte a2 = currentInd.getMarkerB(i); if (a1 >= 5 && a2 >= 5){ counts[cc][0]++; counts[cc][1]++; if (allele1 == 0){ allele1 = (byte)(a1 - 4); allele2 = (byte)(a2 - 4); } }else{ //seed the alleles as soon as they're found if (allele1 == 0){ allele1 = a1; if (a1 != a2){ allele2 = a2; } }else if (allele2 == 0){ if (a1 != allele1){ allele2 = a1; }else if (a2 != allele1){ allele2 = a2; } } if (a1 != 0){ if (a1 == allele1){ counts[cc][0] ++; }else{ counts[cc][1] ++; } } if (a2 != 0){ if (a2 == allele1){ counts[cc][0]++; }else{ counts[cc][1]++; } } } } } int[] g1 = {allele1}; int[] g2 = {allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setCaseCount(counts[0][0]); thisSNP1.setControlCount(counts[1][0]); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setCaseCount(counts[0][1]); thisSNP2.setControlCount(counts[1][1]); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getName(), currentMarker)); } } this.results = new Vector(results); } |
if(usedParents.contains(mom) || usedParents.contains(dad)) { | if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { | private void buildParenTDTTrioSet(PedFile pf, Vector permuteInd, TreeSet snpsToBeTested) throws PedFileException{ Vector results = new Vector(); Vector indList = pf.getAllIndividuals(); if(permuteInd == null || permuteInd.size() != indList.size()) { permuteInd = new Vector(); for (int i = 0; i < indList.size(); i++){ permuteInd.add(new Boolean(false)); } } //todo: need to make sure each set of parents only used once int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ int discordantNotTallied=0; int discordantTallied = 0; Individual currentInd; Family currentFam; HashSet usedParents = new HashSet(); AssociationResult.TallyTrio tt = new AssociationResult.TallyTrio(); for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentFam.containsMember(currentInd.getMomID()) && currentFam.containsMember(currentInd.getDadID()) && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = currentFam.getMember(currentInd.getMomID()); Individual dad = currentFam.getMember(currentInd.getDadID()); if(usedParents.contains(mom) || usedParents.contains(dad)) { continue; } if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i); byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } if(((Boolean)permuteInd.get(j)).booleanValue()) { tt.tallyTrioInd(dadU, dadT); tt.tallyTrioInd(momU, momT); } else { tt.tallyTrioInd(dadT, dadU); tt.tallyTrioInd(momT, momU); } if(mom.getAffectedStatus() != dad.getAffectedStatus()) { //discordant parental phenotypes if(!(dad1 == mom1 && dad2 == mom2) && !(dad1 == mom2 && dad2 == mom1)) { if(mom.getAffectedStatus() == 2) { tt.tallyDiscordantParents(momT,momU,dadT,dadU); } else if(dad.getAffectedStatus() == 2) { tt.tallyDiscordantParents(dadT,dadU,momT,momU); } discordantTallied++; }else { discordantNotTallied++; } } usedParents.add(mom); usedParents.add(dad); } } int[] g1 = {tt.allele1}; int[] g2 = {tt.allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setTransCount(tt.counts[0][0]); thisSNP1.setUntransCount(tt.counts[1][0]); thisSNP1.setDiscordantAlleleCounts(tt.discordantAlleleCounts); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setTransCount(tt.counts[0][1]); thisSNP2.setUntransCount(tt.counts[1][1]); thisSNP2.setDiscordantAlleleCounts(tt.getDiscordantCountsAllele2()); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getName(), currentMarker)); } } this.results = results; } |
if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i); | byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = dad.getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; thisMarker = mom.getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; | private void buildParenTDTTrioSet(PedFile pf, Vector permuteInd, TreeSet snpsToBeTested) throws PedFileException{ Vector results = new Vector(); Vector indList = pf.getAllIndividuals(); if(permuteInd == null || permuteInd.size() != indList.size()) { permuteInd = new Vector(); for (int i = 0; i < indList.size(); i++){ permuteInd.add(new Boolean(false)); } } //todo: need to make sure each set of parents only used once int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ int discordantNotTallied=0; int discordantTallied = 0; Individual currentInd; Family currentFam; HashSet usedParents = new HashSet(); AssociationResult.TallyTrio tt = new AssociationResult.TallyTrio(); for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentFam.containsMember(currentInd.getMomID()) && currentFam.containsMember(currentInd.getDadID()) && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = currentFam.getMember(currentInd.getMomID()); Individual dad = currentFam.getMember(currentInd.getDadID()); if(usedParents.contains(mom) || usedParents.contains(dad)) { continue; } if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i); byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } if(((Boolean)permuteInd.get(j)).booleanValue()) { tt.tallyTrioInd(dadU, dadT); tt.tallyTrioInd(momU, momT); } else { tt.tallyTrioInd(dadT, dadU); tt.tallyTrioInd(momT, momU); } if(mom.getAffectedStatus() != dad.getAffectedStatus()) { //discordant parental phenotypes if(!(dad1 == mom1 && dad2 == mom2) && !(dad1 == mom2 && dad2 == mom1)) { if(mom.getAffectedStatus() == 2) { tt.tallyDiscordantParents(momT,momU,dadT,dadU); } else if(dad.getAffectedStatus() == 2) { tt.tallyDiscordantParents(dadT,dadU,momT,momU); } discordantTallied++; }else { discordantNotTallied++; } } usedParents.add(mom); usedParents.add(dad); } } int[] g1 = {tt.allele1}; int[] g2 = {tt.allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setTransCount(tt.counts[0][0]); thisSNP1.setUntransCount(tt.counts[1][0]); thisSNP1.setDiscordantAlleleCounts(tt.discordantAlleleCounts); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setTransCount(tt.counts[0][1]); thisSNP2.setUntransCount(tt.counts[1][1]); thisSNP2.setDiscordantAlleleCounts(tt.getDiscordantCountsAllele2()); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getName(), currentMarker)); } } this.results = results; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.