List of usage examples for java.awt.geom Arc2D OPEN
int OPEN
To view the source code for java.awt.geom Arc2D OPEN.
Click Source Link
From source file:savant.view.tracks.BAMTrackRenderer.java
private void renderArcPairedMode(Graphics2D g2, GraphPaneAdapter gp) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LOG.debug("YMAX for ARC mode: " + ((AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE)).getYMax()); AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE); ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); int discordantMin = (Integer) instructions.get(DrawingInstruction.DISCORDANT_MIN); int discordantMax = (Integer) instructions.get(DrawingInstruction.DISCORDANT_MAX); //LOG.info("discordantMin=" + discordantMin + " discordantMax=" + discordantMax); // set up colors Color normalArcColor = makeTransparent(cs.getColor(ColourKey.CONCORDANT_LENGTH)); Color invertedReadColor = makeTransparent(cs.getColor(ColourKey.ONE_READ_INVERTED)); Color evertedPairColor = makeTransparent(cs.getColor(ColourKey.EVERTED_PAIR)); Color discordantLengthColor = makeTransparent(cs.getColor(ColourKey.DISCORDANT_LENGTH)); Color unmappedMateColor = makeTransparent(cs.getColor(ColourKey.UNMAPPED_MATE)); // set graph pane's range parameters gp.setXRange(axisRange.getXRange()); gp.setYRange(axisRange.getYRange()); // iterate through the data and draw LOG.debug("BAMTrackRenderer.renderArcMatePairMode: " + data.size() + " records."); for (Record record : data) { BAMIntervalRecord bamRecord = (BAMIntervalRecord) record; SAMRecord samRecord = bamRecord.getSAMRecord(); SAMReadUtils.PairedSequencingProtocol prot = (SAMReadUtils.PairedSequencingProtocol) instructions .get(DrawingInstruction.PAIRED_PROTOCOL); SAMReadUtils.PairMappingType type = SAMReadUtils.getPairType(samRecord, prot); if (samRecord.getReadPairedFlag() && type != null) { if (samRecord.getMateUnmappedFlag()) { // Read with unmapped mate. int alignmentStart = samRecord.getAlignmentStart(); double x = gp.transformXPos(alignmentStart); double radius = 4.0; double top = gp.transformYPos(axisRange.getYRange().getTo() * 0.25) + radius; g2.setColor(unmappedMateColor); g2.setStroke(ONE_STROKE); Path2D flower = new Path2D.Double(); flower.moveTo(x, gp.transformYPos(0.0)); flower.lineTo(x, top);//from www . j av a 2s . c o m flower.moveTo(x - radius, top - radius); flower.lineTo(x + radius, top + radius); flower.moveTo(x - radius, top + radius); flower.lineTo(x + radius, top - radius); //flower.append(new Ellipse2D.Double(x - radius, top - radius, radius * 2.0, radius * 2.0), false); g2.draw(flower); recordToShapeMap.put(record, flower); // mates map to different chrs } else if (!samRecord.getMateReferenceName().equals(samRecord.getReferenceName())) { int alignmentStart = samRecord.getAlignmentStart(); double x = gp.transformXPos(alignmentStart); double arrowWidth = 10; double arrowHeight = 15; double top = gp.transformYPos(axisRange.getYRange().getTo() * 0.9); g2.setColor(invertedReadColor); g2.setStroke(TWO_STROKE); Path2D stem = new Path2D.Double(); stem.moveTo(x, gp.transformYPos(0.0)); stem.lineTo(x, top + arrowHeight); g2.draw(stem); Path2D pointer = new Path2D.Double(); pointer.moveTo(x, top); pointer.lineTo(x - arrowWidth / 2, top + arrowHeight); pointer.lineTo(x + arrowWidth / 2, top + arrowHeight); pointer.lineTo(x, top); g2.fill(pointer); pointer.append(stem, false); //flower.append(new Ellipse2D.Double(x - radius, top - radius, radius * 2.0, radius * 2.0), false); //g2.draw(pointer); recordToShapeMap.put(record, pointer); // mates map to the same chr } else { // Paired read with normal mate. int arcLength = Math.abs(samRecord.getInferredInsertSize()); // skip reads with a zero insert length--probably mapping errors if (arcLength == 0) { continue; } int alignmentStart; int mateAlignmentStart = samRecord.getMateAlignmentStart(); if (samRecord.getAlignmentStart() > mateAlignmentStart) { if (!(mateAlignmentStart < LocationController.getInstance().getRangeStart())) { // this is the second in the pair, and it doesn't span the beginning of the range, so don't draw anything continue; } else { // switch the mate start/end for the read start/end to deal with reversed position alignmentStart = mateAlignmentStart; } } else { alignmentStart = samRecord.getAlignmentStart(); } // at this point alignmentStart/End refers the the start end of the first occurrence in the pair int intervalStart; switch (type) { case INVERTED_READ: case INVERTED_MATE: intervalStart = alignmentStart; g2.setColor(invertedReadColor); g2.setStroke(TWO_STROKE); break; case EVERTED: intervalStart = alignmentStart; g2.setColor(evertedPairColor); g2.setStroke(TWO_STROKE); break; default: // make sure arclength is over our threshold /*if (threshold != 0.0d && threshold < 1.0d && arcLength < axisRange.getXRange().getLength()*threshold) { continue; } else if (threshold > 1.0d && arcLength < threshold) { continue; }*/ intervalStart = alignmentStart; if (arcLength > discordantMax || arcLength < discordantMin) { g2.setColor(discordantLengthColor); g2.setStroke(TWO_STROKE); } else { g2.setColor(normalArcColor); g2.setStroke(ONE_STROKE); } break; } int arcHeight = arcLength; double rectWidth = arcLength * gp.getUnitWidth(); double rectHeight = arcHeight * 2 * gp.getUnitHeight(); double xOrigin = gp.transformXPos(intervalStart); double yOrigin = gp.transformYPos(arcHeight); Arc2D arc = new Arc2D.Double(xOrigin, yOrigin, rectWidth, rectHeight, -180, -180, Arc2D.OPEN); g2.draw(arc); recordToShapeMap.put(record, arc); } } } }