List of usage examples for java.awt Graphics2D fill
public abstract void fill(Shape s);
From source file:savant.view.swing.GraphPane.java
private void renderCurrentSelected(Graphics2D g2) { // Temporarily shift the origin g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(0, getOffset());// w ww . j a v a2 s .c o m for (Track t : tracks) { if (t.getRenderer().hasMappedValues()) { List<Shape> currentSelected = t.getRenderer().getCurrentSelectedShapes(this); if (currentSelected.size() > 0) { boolean arcMode = t.getDrawingMode() == DrawingMode.ARC_PAIRED; for (Shape selectedShape : currentSelected) { if (selectedShape != currentOverShape) { if (arcMode) { g2.setColor(Color.GREEN); g2.draw(selectedShape); } else { //g2.setColor(Color.GREEN); g2.setColor(new Color(0, 255, 0, 150)); g2.fill(selectedShape); if (selectedShape.getBounds().getWidth() > 5) { g2.setColor(Color.BLACK); g2.draw(selectedShape); } } } } } break; } } if (currentOverShape != null) { if (tracks[0].getDrawingMode() == DrawingMode.ARC_PAIRED) { g2.setColor(Color.RED); g2.draw(currentOverShape); //get record pair BAMIntervalRecord rec1 = (BAMIntervalRecord) currentOverRecord; BAMIntervalRecord rec2 = ((BAMTrack) tracks[0]).getMate(rec1); //mate //render reads with mismatches ((BAMTrackRenderer) tracks[0].getRenderer()).renderReadsFromArc(g2, this, rec1, rec2, prevRange); } else { g2.setColor(new Color(255, 0, 0, 150)); g2.fill(currentOverShape); if (currentOverShape.getBounds() != null && currentOverShape.getBounds().getWidth() > 5 && currentOverShape.getBounds().getHeight() > 3) { g2.setColor(Color.BLACK); g2.draw(currentOverShape); } } } //shift the origin back g2.translate(0, -getOffset()); }
From source file:savant.view.swing.GraphPane.java
@Override protected void paintComponent(Graphics g) { if (tracks != null && tracks.length > 0) { LOG.trace("GraphPane.paintComponent(" + tracks[0].getName() + ")"); }/*from w w w . j ava 2 s .c o m*/ super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; boolean trueRender = render(g2); GraphPaneController gpc = GraphPaneController.getInstance(); int h = getHeight(); // Aiming adjustments. if (gpc.isAiming() && mouseInside) { g2.setColor(Color.BLACK); Font thickfont = g2.getFont().deriveFont(Font.BOLD, 15.0F); g2.setFont(thickfont); int genomeX = gpc.getMouseXPosition(); double genomeY = gpc.getMouseYPosition(); String target = ""; target += "X: " + MiscUtils.numToString(genomeX); if (!Double.isNaN(genomeY)) { target += " Y: " + MiscUtils.numToString(genomeY); } g2.drawLine(mouseX, 0, mouseX, h); if (genomeY != -1) { g.drawLine(0, mouseY, this.getWidth(), mouseY); } g2.drawString(target, mouseX + 5, mouseY - 5); } double x1 = transformXPos(gpc.getMouseClickPosition()); double x2 = transformXPos(gpc.getMouseReleasePosition()); double width = x1 - x2; selectionRect = new Rectangle2D.Double(width < 0 ? x1 : x2, 0.0, Math.max(2.0, Math.abs(width)), h); if (gpc.isPanning()) { // Panning adjustments (none). } else if (gpc.isZooming() || gpc.isSelecting()) { // Zooming adjustments. Rectangle2D rectangle = new Rectangle2D.Double(selectionRect.getX(), selectionRect.getY() - 10.0, selectionRect.getWidth(), selectionRect.getHeight() + 10.0); g2.setColor(Color.gray); g2.setStroke( new BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3f, new float[] { 4f }, 4f)); g2.draw(rectangle); if (gpc.isZooming()) { g.setColor(ColourSettings.getColor(ColourKey.GRAPH_PANE_ZOOM_FILL)); } else if (gpc.isSelecting()) { g.setColor(ColourSettings.getColor(ColourKey.GRAPH_PANE_SELECTION_FILL)); } g2.fill(selectionRect); } // Plumbing adjustments. Range xRange = getXRange(); if (gpc.isPlumbing()) { g2.setColor(Color.BLACK); double spos = transformXPos(gpc.getMouseXPosition()); g2.draw(new Line2D.Double(spos, 0, spos, h)); double rpos = transformXPos(gpc.getMouseXPosition() + 1); g2.draw(new Line2D.Double(rpos, 0, rpos, h)); } // Spotlight if (gpc.isSpotlight() && !gpc.isZooming()) { int center = gpc.getMouseXPosition(); int left = center - gpc.getSpotlightSize() / 2; int right = left + gpc.getSpotlightSize(); g2.setColor(new Color(0, 0, 0, 200)); // draw left of spotlight if (left >= xRange.getFrom()) { g2.fill(new Rectangle2D.Double(0.0, 0.0, transformXPos(left), h)); } // draw right of spotlight if (right <= xRange.getTo()) { double pix = transformXPos(right); g2.fill(new Rectangle2D.Double(pix, 0, getWidth() - pix, h)); } } if (isLocked()) { drawMessage((Graphics2D) g, "Locked"); } if (trueRender) { gpc.delistRenderingGraphpane(this); } }
From source file:savant.view.tracks.BAMTrackRenderer.java
private Shape renderRead(Graphics2D g2, GraphPaneAdapter gp, BAMIntervalRecord rec, int level, Range range, double readHeight) { SAMRecord samRec = rec.getSAMRecord(); boolean reverseStrand = samRec.getReadNegativeStrandFlag(); ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); Color readColor = cs.getColor(reverseStrand ? ColourKey.REVERSE_STRAND : ColourKey.FORWARD_STRAND); Color override = rec.getColor(); if (override != null) { readColor = override;//www .ja v a2 s. c o m } if ((Boolean) instructions.get(DrawingInstruction.MAPPING_QUALITY)) { int alpha = getConstrainedAlpha(samRec.getMappingQuality()); readColor = new Color(readColor.getRed(), readColor.getGreen(), readColor.getBlue(), alpha); } // cutoffs to determine when not to draw double leftMostX = gp.transformXPos(range.getFrom()); double rightMostX = gp.transformXPos(range.getTo() + 1); //y = gp.transformYPos(0) - (level + 1)*unitHeight; double x = gp.transformXPos(rec.getInterval().getStart()); double y = gp.transformYPos(0) - (level + 1) * readHeight - gp.getOffset(); double w = rec.getInterval().getLength() * gp.getUnitWidth(); // cut off x and w so no drawing happens off-screen double x2; if (rightMostX < x + w) { x2 = rightMostX; } else { x2 = x + w; } if (leftMostX > x) { x = leftMostX; } w = x2 - x; Shape pointyBar = getPointyBar(reverseStrand, x, y, w, readHeight); // Only fill in the read if we're not going to slam bases on top of it. boolean baseQuality = (Boolean) instructions.get(DrawingInstruction.BASE_QUALITY); if (lastMode != DrawingMode.SEQUENCE && !baseQuality) { g2.setColor(readColor); g2.fill(pointyBar); } // Render individual bases/mismatches as appropriate for the current mode. if (lastMode != DrawingMode.STANDARD || baseQuality) { renderBases(g2, gp, samRec, level, refSeq, range, readHeight); } // Draw outline, if there's room if (pointyBar.getBounds().getHeight() >= 4.0) { g2.setColor(cs.getColor(ColourKey.INTERVAL_LINE)); g2.draw(pointyBar); } return pointyBar; }
From source file:savant.view.tracks.BAMTrackRenderer.java
/** * Render the individual bases on top of the read. Depending on the drawing * mode this can be either bases read or mismatches. */// w w w. java 2 s .c o m private void renderBases(Graphics2D g2, GraphPaneAdapter gp, SAMRecord samRecord, int level, byte[] refSeq, Range range, double unitHeight) { ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); boolean baseQualityEnabled = (Boolean) instructions.get(DrawingInstruction.BASE_QUALITY); boolean drawingAllBases = lastMode == DrawingMode.SEQUENCE || baseQualityEnabled; double unitWidth = gp.getUnitWidth(); int offset = gp.getOffset(); // Cutoffs to determine when not to draw double leftMostX = gp.transformXPos(range.getFrom()); double rightMostX = gp.transformXPos(range.getTo()) + unitWidth; int alignmentStart = samRecord.getAlignmentStart(); byte[] readBases = samRecord.getReadBases(); byte[] baseQualities = samRecord.getBaseQualities(); boolean sequenceSaved = readBases.length > 0; Cigar cigar = samRecord.getCigar(); // Absolute positions in the reference sequence and the read bases, set after each cigar operator is processed int sequenceCursor = alignmentStart; int readCursor = alignmentStart; List<Rectangle2D> insertions = new ArrayList<Rectangle2D>(); FontMetrics fm = g2.getFontMetrics(MISMATCH_FONT); Rectangle2D charRect = fm.getStringBounds("G", g2); boolean fontFits = charRect.getWidth() <= unitWidth && charRect.getHeight() <= unitHeight; if (fontFits) { g2.setFont(MISMATCH_FONT); } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (CigarElement cigarElement : cigar.getCigarElements()) { int operatorLength = cigarElement.getLength(); CigarOperator operator = cigarElement.getOperator(); Rectangle2D.Double opRect = null; double opStart = gp.transformXPos(sequenceCursor); double opWidth = operatorLength * unitWidth; // Cut off start and width so no drawing happens off-screen, must be done in the order w, then x, since w depends on first value of x double x2 = Math.min(rightMostX, opStart + opWidth); opStart = Math.max(leftMostX, opStart); opWidth = x2 - opStart; switch (operator) { case D: // Deletion if (opWidth > 0.0) { renderDeletion(g2, gp, opStart, level, operatorLength, unitHeight); } break; case I: // Insertion insertions.add(new Rectangle2D.Double(gp.transformXPos(sequenceCursor), gp.transformYPos(0) - ((level + 1) * unitHeight) - gp.getOffset(), unitWidth, unitHeight)); break; case M: // Match or mismatch case X: case EQ: // some SAM files do not contain the read bases if (sequenceSaved || operator == CigarOperator.X) { for (int i = 0; i < operatorLength; i++) { // indices into refSeq and readBases associated with this position in the cigar string int readIndex = readCursor - alignmentStart + i; boolean mismatched = false; if (operator == CigarOperator.X) { mismatched = true; } else { int refIndex = sequenceCursor + i - range.getFrom(); if (refIndex >= 0 && refSeq != null && refIndex < refSeq.length) { mismatched = refSeq[refIndex] != readBases[readIndex]; } } if (mismatched || drawingAllBases) { Color col; if ((mismatched && lastMode != DrawingMode.STANDARD) || lastMode == DrawingMode.SEQUENCE) { col = cs.getBaseColor((char) readBases[readIndex]); } else { col = cs.getColor(samRecord.getReadNegativeStrandFlag() ? ColourKey.REVERSE_STRAND : ColourKey.FORWARD_STRAND); } if (baseQualityEnabled && col != null) { col = new Color(col.getRed(), col.getGreen(), col.getBlue(), getConstrainedAlpha( (int) Math.round((baseQualities[readIndex] * 0.025) * 255))); } double xCoordinate = gp.transformXPos(sequenceCursor + i); double top = gp.transformYPos(0) - ((level + 1) * unitHeight) - offset; if (col != null) { opRect = new Rectangle2D.Double(xCoordinate, top, unitWidth, unitHeight); g2.setColor(col); g2.fill(opRect); } if (lastMode != DrawingMode.SEQUENCE && mismatched && fontFits) { // If it's a real mismatch, we want to draw the base letter (space permitting). g2.setColor(new Color(10, 10, 10)); String s = new String(readBases, readIndex, 1); charRect = fm.getStringBounds(s, g2); g2.drawString(s, (float) (xCoordinate + (unitWidth - charRect.getWidth()) * 0.5), (float) (top + fm.getAscent() + (unitHeight - charRect.getHeight()) * 0.5)); } } } } break; case N: // Skipped opRect = new Rectangle2D.Double(opStart, gp.transformYPos(0) - ((level + 1) * unitHeight) - offset, opWidth, unitHeight); g2.setColor(cs.getColor(ColourKey.SKIPPED)); g2.fill(opRect); break; default: // P - passing, H - hard clip, or S - soft clip break; } if (operator.consumesReadBases()) { readCursor += operatorLength; } if (operator.consumesReferenceBases()) { sequenceCursor += operatorLength; } } for (Rectangle2D ins : insertions) { drawInsertion(g2, ins.getX(), ins.getY(), ins.getWidth(), ins.getHeight()); } }
From source file:savant.view.tracks.BAMTrackRenderer.java
/** * Render the black rectangle which indicates a deletion. *//*from ww w .j av a2s. c o m*/ private void renderDeletion(Graphics2D g2, GraphPaneAdapter gp, double opStart, int level, int operatorLength, double unitHeight) { double width = operatorLength * gp.getUnitWidth(); if (width < 1.0) { width = 1.0; } Rectangle2D opRect = new Rectangle2D.Double(opStart, gp.transformYPos(0) - (level + 1) * unitHeight - gp.getOffset(), width, unitHeight); g2.setColor(Color.BLACK); g2.fill(opRect); }
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 .java2 s.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); } } } }
From source file:savant.view.tracks.BAMTrackRenderer.java
/** * Draw two read-shapes: one for forward and one for reverse. *///from w ww. j a v a 2 s.co m private void drawStrandLegends(Graphics2D g2, int x, int y) { ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); Shape pointyBar = getPointyBar(false, x, y - 12, 36.0, 12.0); g2.setColor(cs.getColor(ColourKey.FORWARD_STRAND)); g2.fill(pointyBar); g2.setColor(cs.getColor(ColourKey.INTERVAL_LINE)); g2.draw(pointyBar); pointyBar = getPointyBar(true, x, y - 12 + LEGEND_LINE_HEIGHT, 36.0, 12.0); g2.setColor(cs.getColor(ColourKey.REVERSE_STRAND)); g2.fill(pointyBar); g2.setColor(cs.getColor(ColourKey.INTERVAL_LINE)); g2.draw(pointyBar); g2.setColor(Color.BLACK); g2.setFont(LEGEND_FONT); g2.drawString(ColourKey.FORWARD_STRAND.getName(), x + 45, y); g2.drawString(ColourKey.REVERSE_STRAND.getName(), x + 45, y + LEGEND_LINE_HEIGHT); }
From source file:savant.view.tracks.ContinuousTrackRenderer.java
@Override public void render(Graphics2D g2, GraphPaneAdapter gp) throws RenderingException { renderPreCheck();/* www. java 2 s . co m*/ AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE); gp.setXRange(axisRange.getXRange()); gp.setYRange(axisRange.getYRange()); if (gp.needsToResize()) return; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); Color fillcolor = cs.getColor(ColourKey.CONTINUOUS_FILL); Color linecolor = cs.getColor(ColourKey.CONTINUOUS_LINE); GeneralPath path = new GeneralPath(); double xFormXPos = Double.NaN, xFormYPos = Double.NaN; double yPixel0 = gp.transformYPos(0.0); LOG.debug("h=" + gp.getHeight() + ", yMin=" + gp.getYRange().getFrom() + ", unitHeight=" + gp.getUnitHeight() + " \u27A4 yPixel0=" + yPixel0); double maxData = 0; boolean haveOpenPath = false; boolean haveData = false; if (data != null) { for (int i = 0; i < data.size(); i++) { ContinuousRecord continuousRecord = (ContinuousRecord) data.get(i); int xPos = continuousRecord.getPosition(); float yPos = continuousRecord.getValue(); if (Float.isNaN(yPos)) { // Hit a position with no data. May need to close off the current path. if (haveOpenPath) { path.lineTo(xFormXPos, yPixel0); path.closePath(); haveOpenPath = false; } } else { haveData = true; xFormXPos = gp.transformXPos(xPos);//+gp.getUnitWidth()/2; xFormYPos = gp.transformYPos(yPos); if (!haveOpenPath) { // Start our path off with a vertical line. path.moveTo(xFormXPos, yPixel0); haveOpenPath = true; } path.lineTo(xFormXPos, xFormYPos); Rectangle2D rec = new Rectangle2D.Double( xFormXPos - ((xFormXPos - path.getCurrentPoint().getX()) / 2), 0, Math.max(xFormXPos - path.getCurrentPoint().getX(), 1), gp.getHeight()); recordToShapeMap.put(continuousRecord, rec); xFormXPos = gp.transformXPos(xPos + 1); path.lineTo(xFormXPos, xFormYPos); } if (yPos > maxData) { maxData = yPos; } } } if (!haveData) { throw new RenderingException("No data in range", RenderingException.INFO_PRIORITY); } if (haveOpenPath) { // Path needs to be closed. path.lineTo(xFormXPos, yPixel0); path.closePath(); } g2.setColor(fillcolor); g2.fill(path); g2.setColor(linecolor); g2.draw(path); if (axisRange.getYRange().getFrom() < 0) { g2.setColor(Color.darkGray); g2.draw(new Line2D.Double(0.0, yPixel0, gp.getWidth(), yPixel0)); } }
From source file:savant.view.tracks.TrackRenderer.java
public void drawFeatureLabel(Graphics2D g2, String geneName, double startXPos, double y) { FontMetrics fm = g2.getFontMetrics(); double stringstartx = startXPos - fm.stringWidth(geneName) - 5; if (stringstartx <= 0) { Rectangle2D r = fm.getStringBounds(geneName, g2); int b = 2; Color textColor = g2.getColor(); g2.setColor(new Color(255, 255, 255, 200)); g2.fill(new RoundRectangle2D.Double(3.0, y - (fm.getHeight() - fm.getDescent()) - b, r.getWidth() + 2 * b, r.getHeight() + 2 * b, 8.0, 8.0)); g2.setColor(textColor);/*from w w w.j a v a 2s . c om*/ g2.drawString(geneName, 5.0F, (float) y); } else { g2.drawString(geneName, (float) stringstartx, (float) y); } }
From source file:savant.view.tracks.TrackRenderer.java
/** * Shared by BAMTrackRenderer and RichIntervalTrackRenderer to draw the white diamond * which indicates an insertion./*from w w w .j a v a2 s . com*/ */ public Shape drawInsertion(Graphics2D g2, double x, double y, double unitWidth, double unitHeight) { ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); g2.setColor(cs.getColor(ColourKey.INSERTED_BASE)); double w = unitWidth * 0.5; Path2D.Double rhombus = new Path2D.Double(); rhombus.moveTo(x, y); rhombus.lineTo(x + w, y + unitHeight * 0.5); rhombus.lineTo(x, y + unitHeight); rhombus.lineTo(x - w, y + unitHeight * 0.5); rhombus.closePath(); g2.fill(rhombus); return rhombus; }