List of usage examples for java.awt Graphics drawImage
public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer);
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
/** * paints this log item panel and all contained log items as specified. * /*from ww w .jav a 2 s.c o m*/ * @param g * the graphics object used for painting */ public void paintComponent(Graphics grx) { Graphics gr = grx.create(); if (this.isOpaque()) { gr.setColor(colorBg); gr.fillRect(0, 0, getWidth(), getHeight()); } if ((int) gr.getClipBounds().getMinX() < coUtil.getClipL() || (int) gr.getClipBounds().getMaxX() > coUtil.getClipR() || (int) gr.getClipBounds().getMinY() < coUtil.getClipU() || (int) gr.getClipBounds().getMaxY() > coUtil.getClipB()) { modelBuffer = null; } if (modelBuffer == null) { this.setToolTipText(null); if (this.getWidth() <= SCREENLENGTH) { coUtil.setClipL(0); coUtil.setClipR(this.getWidth()); } else { int x1 = (SCREENLENGTH - gr.getClipBounds().width) / 2; int x2 = (int) gr.getClipBounds().getMinX() - x1; if (x2 <= 0) { coUtil.setClipL(0); coUtil.setClipR(SCREENLENGTH); } else if (x2 + SCREENLENGTH >= this.getWidth()) { coUtil.setClipR(this.getWidth()); coUtil.setClipL(this.getWidth() - SCREENLENGTH); } else { coUtil.setClipL(x2); coUtil.setClipR(x2 + SCREENLENGTH); } } if (this.getHeight() <= SCREENLENGTH) { coUtil.setClipU(0); coUtil.setClipB(this.getHeight()); } else { int y1 = (SCREENLENGTH - gr.getClipBounds().height) / 2; int y2 = (int) gr.getClipBounds().getMinY() - y1; if (y2 <= 0) { coUtil.setClipU(0); coUtil.setClipB(SCREENLENGTH); } else if (y2 + SCREENLENGTH >= this.getHeight()) { coUtil.setClipU(this.getHeight() - SCREENLENGTH); coUtil.setClipB(this.getHeight()); } else { coUtil.setClipU(y2); coUtil.setClipB(y2 + SCREENLENGTH); } } coUtil.updateMilli2pixelsRatio(getWidth(), BORDER); if (dcop.isSizeCheckBoxSelected()) { drawModelBuffer(getWidth(), getHeight(), true); } else { drawModelBuffer_NO_SIZE(getWidth(), getHeight(), true); } } grx.drawImage(modelBuffer, coUtil.getClipL(), coUtil.getClipU(), this); // to do box for zoom if (p1 != null && p2 != null) { int x1 = Math.min(p1.x, p2.x); int y1 = Math.min(p1.y, p2.y); int width = Math.abs(p1.x - p2.x); int height = Math.abs(p1.y - p2.y); grx.drawRect(x1, y1, width, height); } }
From source file:base.BasePlayer.AminoTable.java
void drawScreen(Graphics g) { if (!isEnabled()) { return;/*from w w w . ja va 2s . c om*/ } buf.setColor(Color.black); buf.fillRect(0, 0, VariantHandler.tableScroll.getViewport().getWidth(), tablescroll.getViewport().getHeight()); if (VariantHandler.writetofile.isSelected()) { buf.setColor(Color.white); if (FileRead.output != null && Main.drawCanvas.loading && Draw.variantcalculator) { buf.drawString("Writing results to " + FileRead.outputName, 10, 20); } else { buf.drawString("Press annotate to write results straight to file", 10, 20); } g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null); return; } //Header Draw genemutcount = 0; hoverVar = null; hoverSample = -1; headerHover = -1; geneHeaderHover = -1; if (!mouseDrag) { resizeColumn = -1; } firstrow = tablescroll.getVerticalScrollBar().getValue() / rowHeight - samplecount - listAdd - aminoarray.size(); if (firstrow < 0) { firstrow = 0; } for (int i = 0; i < genearray.size(); i++) { dot = false; if ((i + 1 + samplecount + aminoarray.size() + listAdd) * rowHeight < tablescroll.getVerticalScrollBar() .getValue()) { continue; } if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue() + tablescroll.getViewport().getHeight()) { break; } if (mouseY >= (rowHeight * (i + genemutcount + 1)) && mouseY < (rowHeight * (i + genemutcount + 2))) { hoverNode = genearray.get(i); } try { buf.setColor(Color.darkGray); buf.drawLine(4, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } textWidth = (int) fm.getStringBounds("" + (i + 1) + ". " + genearray.get(i).getName(), buf) .getWidth(); if (genearray.get(i).intergenic) { if (genearray.get(i).varnodes.get(0).getTranscripts() == null) { buf.drawString((i + 1) + ". " + genearray.get(i).getName(), 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) { buf.drawString( (i + 1) + ". " + genearray.get(i).getName() + " ... " + genearray.get(i).varnodes.get(0).getTranscripts().get(1).getGenename(), 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (genearray.get(i).varnodes.get(0).getPosition() < genearray.get(i).getStart()) { buf.drawString((i + 1) + ". " + " ... " + genearray.get(i).getName(), 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString((i + 1) + ". " + genearray.get(i).getName() + " ... ", 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } else { buf.drawString((i + 1) + ". " + genearray.get(i).getName(), 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) (headerlengths[1][0] + 1), (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) (headerlengths[1][1]), rowHeight - 1); if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } mutcountbuffer = new StringBuffer("" + genearray.get(i).mutations + " ("); buf.drawString(mutcountbuffer.toString(), (int) (headerlengths[1][0] + 5), (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (genearray.get(i).nonsense > 0) { buf.setColor(Color.red); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString("" + genearray.get(i).nonsense, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(genearray.get(i).nonsense); dot = true; } if (genearray.get(i).missense > 0) { if (dot) { buf.setColor(Color.white); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(", "); } textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.setColor(Color.yellow); buf.drawString("" + genearray.get(i).missense, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(genearray.get(i).missense); dot = true; } if (genearray.get(i).synonymous > 0) { if (dot) { buf.setColor(Color.white); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(", "); } textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.setColor(Color.green); buf.drawString("" + genearray.get(i).synonymous, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(genearray.get(i).synonymous); dot = true; } if (genearray.get(i).utr > 0) { if (dot) { buf.setColor(Color.white); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(", "); } buf.setColor(Color.lightGray); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString("" + genearray.get(i).utr, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(genearray.get(i).utr); dot = true; } if (genearray.get(i).intronic > 0) { if (dot) { buf.setColor(Color.white); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(", "); } buf.setColor(Color.gray); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString("" + genearray.get(i).intronic, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append(genearray.get(i).intronic); dot = true; } if (genearray.get(i).intergenic) { buf.setColor(Color.gray); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString("" + genearray.get(i).mutations, (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); mutcountbuffer.append("" + genearray.get(i).mutations); } buf.setColor(Color.white); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth(); buf.drawString(") ", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.gray); textWidth = (int) fm.getStringBounds(mutcountbuffer.toString() + ") ", buf).getWidth(); if (genearray.get(i).samples.size() == 1) { buf.drawString(" 1 sample", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString(" " + genearray.get(i).samples.size() + " samples", (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) (headerlengths[2][0]) + 1, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } if (genearray.get(i).intergenic) { if (genearray.get(i).varnodes.get(0).getTranscripts() == null) { buf.drawString(genearray.get(i).getChrom(), (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) { buf.drawString( genearray.get(i).getChrom() + ":" + MethodLibrary.formatNumber(genearray.get(i).getEnd()) + "-" + MethodLibrary.formatNumber(genearray.get(i).varnodes.get(0) .getTranscripts().get(1).getStart()), (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (genearray.get(i).varnodes.get(0).getPosition() < genearray.get(i).getStart()) { buf.drawString( genearray.get(i).getChrom() + ":1-" + MethodLibrary.formatNumber(genearray.get(i).varnodes.get(0) .getTranscripts().get(1).getStart()), (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString( genearray.get(i).getChrom() + ":" + MethodLibrary.formatNumber(genearray.get(i).getEnd()) + "-end", (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } else { buf.drawString( genearray.get(i).getChrom() + ":" + MethodLibrary.formatNumber(genearray.get(i).getStart()) + "-" + MethodLibrary.formatNumber(genearray.get(i).getEnd()), (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) (headerlengths[3][0]) + 1, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } if (genearray.get(i).intergenic) { if (genearray.get(i).varnodes.get(0).getTranscripts() == null) { buf.drawString("-", (int) (headerlengths[3][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) { buf.drawString( genearray.get(i).getDescription() + ";" + genearray.get(i).varnodes.get(0).getTranscripts().get(1).getGene() .getDescription(), (int) (headerlengths[3][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } else { buf.drawString(genearray.get(i).getDescription(), (int) (headerlengths[3][0]) + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.darkGray); buf.drawLine(3, rowHeight + 3, 3, (rowHeight * (i + genemutcount + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3); for (int r = 0; r < headerlengths.length; r++) { buf.drawLine((int) (headerlengths[r][0]), (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) (headerlengths[r][0]), (rowHeight * (i + genemutcount + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3); } if (selectedNode != null && selectedNode.equals(genearray.get(i))) { hoverSample = -1; genemutcount = aminoarray.size() + 1; listAdd = 1; // buf.drawLine(10, (rowHeight*(i+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+3, this.getWidth(), (rowHeight*(i+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+3); drawGeneheader( (rowHeight * (i + listAdd + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); for (int s = 0; s < aminoarray.size(); s++) { buf.setColor(Color.darkGray); buf.drawLine(21, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("nonsense")) { textcolor = Color.red; } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("missense")) { textcolor = Color.yellow; } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("synonymous")) { textcolor = Color.green; } else if (aminoarray.get(s).getRow()[3].contains("UTR")) { textcolor = Color.lightGray; } else { textcolor = Color.gray; } buf.setColor(textcolor); if (mouseY >= (rowHeight * (i + s + listAdd + 2)) && mouseY < (rowHeight * (i + s + listAdd + 3))) { hoverNode = null; hoverVar = aminoarray.get(s).getNode(); hoverString = aminoarray.get(s).getRow(); buf.setColor(Color.white); hoverSample = -1; if (aminoarray.get(s).getRow()[1].equals("1")) { for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getSample().getIndex(); hoverSampleNode = aminoarray.get(s).getNode().vars.get(v).getValue().get(0); hoverBase = aminoarray.get(s).getRow()[5]; break; } } } // hoverSample = -1; } if (!aminoarray.get(s).getRow()[1].equals("1")) { buf.drawString("Multiple", 24, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { buf.drawString( aminoarray.get(s).getNode().vars.get(v).getValue().get(0).getSample() .getName(), 24, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); break; } } } if (hoverVar != null && hoverString.equals(aminoarray.get(s).getRow())) { //TODO textcolor = Color.white; } for (int h = 1; h < 4; h++) { buf.setColor(Color.black); buf.fillRect((int) geneheader.get(h)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(h)[2], rowHeight - 1); buf.setColor(textcolor); if (h == 3) { if (aminoarray.get(s).getRow()[5].length() == 1) { buf.drawString( Main.getBase.get(aminoarray.get(s).getNode().getRefBase()) + ">" + aminoarray.get(s).getRow()[5], (int) geneheader.get(h)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString(aminoarray.get(s).getRow()[5], (int) geneheader.get(h)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(4)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(4)[2], rowHeight - 1); buf.setColor(textcolor); buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(4)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(h)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } if (aminoarray.get(s).getRow()[1].equals("1")) { buf.setColor(Color.black); buf.fillRect((int) geneheader.get(5)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(5)[2], rowHeight - 1); buf.setColor(textcolor); for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0).isHomozygous()) { buf.drawString( "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getCoverage() + ")", (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (Control.controlData.controlsOn) { cases = 2; casefreq = 2 / (double) (Main.varsamples * 2 - 2); } } else { buf.drawString( "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getCoverage() + ")", (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (Control.controlData.controlsOn) { cases = 1; casefreq = 1 / (double) (Main.varsamples * 2 - 1); } } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(6)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getQuality(), (int) geneheader.get(6)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } else { //TODO piirra mustat boksit buf.setColor(Color.black); buf.fillRect((int) geneheader.get(5)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); if (Control.controlData.controlsOn) { cases = 0; for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { for (int j = 0; j < aminoarray.get(s).getNode().vars.get(v).getValue() .size(); j++) { if (aminoarray.get(s).getNode().vars.get(v).getValue() .get(j).alleles != null) { continue; } if (aminoarray.get(s).getNode().vars.get(v).getValue().get(j) .isHomozygous()) { cases += 2; } else { cases += 1; } } } } casefreq = cases / (double) (Main.varsamples * 2 - cases); } } buf.setColor(textcolor); buf.drawString(aminoarray.get(s).getRow()[4], (int) geneheader.get(7)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); // buf.setColor(Color.black); if (Control.controlData.controlsOn) { buf.setColor(textcolor); for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { vararray = aminoarray.get(s).getNode().vars.get(v).getValue(); controlarray = new SampleNode[Control.controlData.fileArray.size()]; if (vararray.get(vararray.size() - 1).alleles != null) { for (int e = vararray.size() - 1; e > 0; e--) { if (vararray.get(e).alleles == null) { break; } controlarray[vararray.get(e).getControlSample().getIndex()] = vararray .get(e); } } for (int e = 0; e < controlarray.length; e++) { if (Control.controlData.fileArray.get(e).controlOn) { if (controlarray[e] == null) { buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString("0", (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString("-", (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + MethodLibrary.round(controlarray[e].alleles / (double) controlarray[e].allelenumber, 5), (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + MethodLibrary.round(casefreq / (controlarray[e].alleles / (double) (controlarray[e].allelenumber - controlarray[e].alleles)), 2) + " (p=" + MethodLibrary.round( fe.getRightTailedP(cases, Main.varsamples * 2 - cases, controlarray[e].alleles, controlarray[e].allelenumber - controlarray[e].alleles), 2) + ")", (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } else { buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(Color.darkGray); buf.drawString("Apply controls", (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(Color.darkGray); buf.drawString("-", (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } } else { buf.setColor(Color.darkGray); for (int e = geneheaderlength; e < geneheader.size(); e++) { if (geneheader.get(e)[0] instanceof ControlFile) { buf.drawString("Apply controls", (int) geneheader.get(e)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } buf.setColor(Color.lightGray); } vararray = null; //if(Main.bedCanvas.bedOn) { for (int a = 0; a < aminoarray.size(); a++) { bedarray = MethodLibrary.makeTrackArray(aminoarray.get(a).getNode(), aminoarray.get(a).getRow()[5]); if (bedarray != null) { for (int b = 0; b < bedarray.length; b++) { buf.setColor(Color.black); if (b == bedarray.length - 1) { buf.fillRect( (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 12, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth() - (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1], rowHeight - 1); } else { buf.fillRect( (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 12, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[2], rowHeight - 1); } buf.setColor(Color.white); if (bedarray[b] != null) { buf.drawString(bedarray[b].toString(), (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 14, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } /*if(c < header.size()-1-Main.bedCanvas.bedTrack.size()) { buf.setColor(Color.black); buf.fillRect((int)header.get(c+1)[1]+1, (rowHeight*(i+genemutcount+1))-tablescroll.getVerticalScrollBar().getValue()+4, (int)header.get(c)[2], rowHeight-1); }*/ // } buf.setColor(Color.darkGray); for (int j = 0; j < geneheader.size(); j++) { buf.drawLine((int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); } if (selectedVar != null && selectedString.equals(aminoarray.get(s).getRow()) && Integer.parseInt(selectedString[1]) > 1) { pointer = 0; //TODO for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey().equals(selectedString[5])) { for (int l = 0; l < aminoarray.get(s).getNode().vars.get(v).getValue() .size(); l++) { if (aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).alleles != null) { break; } if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .getSample().annotation) { continue; } if (mouseY > (rowHeight * (i + s + pointer + 4)) && mouseY < (rowHeight * (i + s + pointer + 5))) { textcolor = Color.white; hoverVar = aminoarray.get(s).getNode(); hoverString = aminoarray.get(s).getRow(); hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .getSample().getIndex(); hoverSampleNode = aminoarray.get(s).getNode().vars.get(v).getValue() .get(l); hoverBase = aminoarray.get(s).getRow()[5]; } else { textcolor = Color.lightGray; } // if(aminoarray.get(s).getNode().getSamples().get(l).getVariation().equals(selectedString[5])) { buf.setColor(textcolor); buf.drawString( aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .getSample().getName(), 30, (rowHeight * (i + s + pointer + 4)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); pointer++; // } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(5)[1] + 10, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .isHomozygous()) { buf.drawString( "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getCoverage() + ")", (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString( "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getCoverage() + ")", (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(6)[1] + 10, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + aminoarray.get(s).getNode().vars .get(v).getValue().get(l).getQuality(), (int) geneheader.get(6)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.darkGray); for (int j = 5; j < 7; j++) { buf.drawLine((int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue(), (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight + 2); } } } } listAdd = Integer.parseInt(selectedString[1]) + 1; genemutcount = aminoarray.size() + listAdd; buf.setColor(Color.darkGray); buf.drawLine(21, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); } } } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); } } buf.setColor(Color.darkGray); buf.drawLine(4, (rowHeight * (genearray.size() + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (genearray.size() + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); drawHeader(); if (headerHover == -1 && geneHeaderHover == -1) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } else { if (resizeColumn == -1) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); } } g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null); }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from w w w.ja v a2s . c om * * @param g2 _more_ * @param comp _more_ * @param ptsIdx _more_ * @param ul _more_ * * @return _more_ */ private Rectangle drawDial(Graphics g2, JComponent comp, int ptsIdx, Point ul) { if (ptsIdx >= dialPts.length) { return null; } int w = comp.getWidth(); int h = comp.getHeight(); boolean useUpperLeft = false; if (comp instanceof ChartPanel) { int desiredWidth = dialPts[ptsIdx][2]; double scale = w / (double) desiredWidth; if (scale != 0) { h = (int) (h / scale); } comp.setSize(new Dimension(desiredWidth, h)); } else if (comp instanceof JLabel) { //Don't set size for labels useUpperLeft = true; } else { comp.setSize(new Dimension(dialPts[ptsIdx][2], dialPts[ptsIdx][3])); } try { int x = ul.x + dialPts[ptsIdx][0] - (useUpperLeft ? 0 : dialPts[ptsIdx][2] / 2); int y = ul.y + dialPts[ptsIdx][1] - (useUpperLeft ? 0 : dialPts[ptsIdx][3] / 2); Image image = ImageUtils.getImage(comp); g2.translate(x, y); g2.drawImage(image, 0, 0, null); return new Rectangle(x, y, comp.getWidth(), comp.getHeight()); } catch (Exception exc) { exc.printStackTrace(); } return null; }
From source file:base.BasePlayer.BedCanvas.java
void drawScreen(Graphics g) { if (Main.readingbeds) { buf.setColor(Draw.backColor);//from w w w. j a v a 2 s .c om buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), nodeImage.getHeight()); buf.drawString("Loading tracks...", 10, Main.bedScroll.getViewport().getHeight()); g.drawImage(bufImage, 0, 0, null); return; } if (this.trackDivider.size() > 0 && this.trackDivider.get(this.trackDivider.size() - 1) != 1.0) { for (int i = 0; i < Main.bedCanvas.trackDivider.size(); i++) { Main.bedCanvas.trackDivider.set(i, ((i + 1) * (this.getHeight() / (double) trackDivider.size()) / this.getHeight())); } } drawSidebar(); if (Settings.wallpaper == null) { buf.setColor(Draw.backColor); buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), this.getHeight()); } else { buf.drawImage(Settings.wallpaper, Main.sidebarWidth - 4, 0, this); buf.setColor(Draw.backColor); buf.fillRect(Main.sidebarWidth - 4, 0, this.getWidth(), this.getHeight()); } //buf.setColor(Color.gray); if (!zoomDrag && !resize) { try { drawNodes(); } catch (Exception e) { e.printStackTrace(); } } if (resizer && !mouseDrag) { resizer = false; } if (resize) { buf.drawImage(nodeImage, Main.sidebarWidth - 4, 0, nodeImage.getWidth(), (int) (Main.vardivider * Main.varPaneDivider.getY()), null); } else { buf.drawImage(nodeImage, Main.sidebarWidth - 4, 0, null); } for (int i = 0; i < bedTrack.size(); i++) { if (i < bedTrack.size() - 1) { buf.setColor(Color.lightGray); buf.drawLine(0, (int) (trackDivider.get(i) * this.getHeight()), this.getWidth(), (int) (trackDivider.get(i) * this.getHeight())); buf.setColor(Color.gray); buf.drawLine(0, (int) (trackDivider.get(i) * this.getHeight()) + 1, this.getWidth(), (int) (trackDivider.get(i) * this.getHeight()) + 1); if (!lineZoomer && mouseY < (int) (trackDivider.get(i) * this.getHeight()) + 4 && mouseY > (int) (trackDivider.get(i) * this.getHeight()) - 4) { resizer = true; if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) { resizeDivider = i; setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); } } } if (bedTrack.get(i).graph && bedTrack.get(i).minvalue != Double.MAX_VALUE && bedTrack.get(i).getHead().getNext() != null) { if (!buf.getColor().equals(Color.white)) { buf.setColor(Color.white); } if (bedTrack.get(i).getLogscale().isSelected()) { scaletext = "Log scale [" + MethodLibrary.round(bedTrack.get(i).minvalue, 2) + ", " + MethodLibrary.round(bedTrack.get(i).maxvalue, 2) + "]"; scalewidth = buf.getFontMetrics().stringWidth(scaletext); buf.fillRoundRect(Main.sidebarWidth + 5, (int) (trackDivider.get(i) * this.getHeight()) - 5 - (Main.defaultFontSize + 4), scalewidth + 4, Main.defaultFontSize + 4, 4, 4); buf.setColor(Color.black); buf.drawString(scaletext, Main.sidebarWidth + 7, (int) (trackDivider.get(i) * this.getHeight()) - 9); } else { scaletext = "Scale [" + MethodLibrary.round(bedTrack.get(i).minvalue, 2) + ", " + MethodLibrary.round(bedTrack.get(i).maxvalue, 2) + "]"; scalewidth = buf.getFontMetrics().stringWidth(scaletext); buf.fillRoundRect(Main.sidebarWidth + 5, (int) (trackDivider.get(i) * this.getHeight()) - 5 - (Main.defaultFontSize + 4), scalewidth + 4, Main.defaultFontSize + 4, 4, 4); buf.setColor(Color.black); buf.drawString(scaletext, Main.sidebarWidth + 7, (int) (trackDivider.get(i) * this.getHeight()) - 9); } buf.setColor(Color.black); } } if (overlap) { drawInfo(); } if (!resizer && !overlapping) { if (getCursor().getType() != Cursor.DEFAULT_CURSOR) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } if (Main.drawCanvas.splits.get(0).pixel > 1) { // Middle line buf.setColor(Color.black); buf.setStroke(Draw.dashed); buf.drawLine((Main.drawCanvas.getDrawWidth()) / 2 + Main.sidebarWidth - 2, 0, ((Main.drawCanvas.getDrawWidth())) / 2 + Main.sidebarWidth - 2, Main.bedScroll.getViewport().getHeight()); buf.drawLine( (int) ((Main.drawCanvas.getDrawWidth()) / 2 + Main.drawCanvas.splits.get(0).pixel + Main.sidebarWidth - 2), 0, (int) (((Main.drawCanvas.getDrawWidth())) / 2 + Main.drawCanvas.splits.get(0).pixel + Main.sidebarWidth - 2), Main.bedScroll.getViewport().getHeight()); // buf.setStroke(Draw.doubleStroke); buf.setStroke(Draw.basicStroke); } for (int i = 1; i < Main.drawCanvas.splits.size(); i++) { buf.setColor(Color.gray); buf.fillRect(Main.drawCanvas.splits.get(i).offset - 3, 0, 5, this.getHeight()); buf.setColor(Color.lightGray); buf.fillRect(Main.drawCanvas.splits.get(i).offset - 1, 0, 2, this.getHeight()); } if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) { drawZoom(); } g.drawImage(bufImage, 0, 0, null); }
From source file:FourByFour.java
public void paint(Graphics g) { if (board != null) { board.render2D(gc);/*from w ww.j av a 2 s .co m*/ g.drawImage(backbuffer, 0, 0, this); } }
From source file:org.opencms.applet.upload.FileUploadApplet.java
/** * @see java.awt.Component#paint(Graphics) *///from w ww . j ava 2 s .c om public void paint(Graphics g) { // create the box m_offscreen = createImage(getSize().width, getSize().height); m_offgraphics = m_offscreen.getGraphics(); m_offgraphics.setColor(getColor("bgColor")); m_offgraphics.fillRect(0, 0, getSize().width, getSize().height); m_offgraphics.setColor(getColor("outerBorderRightBottom")); m_offgraphics.drawLine(0, getSize().height - 1, getSize().width - 1, getSize().height - 1); m_offgraphics.drawLine(getSize().width - 1, 0, getSize().width - 1, getSize().height - 1); m_offgraphics.setColor(getColor("outerBorderLeftTop")); m_offgraphics.drawLine(0, 0, getSize().width - 1, 0); m_offgraphics.drawLine(0, 0, 0, getSize().height - 1); m_offgraphics.setColor(getColor("innerBorderRightBottom")); m_offgraphics.drawLine(1, getSize().height - 2, getSize().width - 2, getSize().height - 2); m_offgraphics.drawLine(getSize().width - 2, 1, getSize().width - 2, getSize().height - 2); m_offgraphics.setColor(getColor("innerBorderLeftTop")); m_offgraphics.drawLine(1, 1, getSize().width - 2, 1); m_offgraphics.drawLine(1, 1, 1, getSize().height - 2); m_offgraphics.setColor(getColor("bgHeadline")); m_offgraphics.fillRect(4, 4, getSize().width - 5, 18); m_offgraphics.setColor(getColor("innerBorderRightBottom")); m_offgraphics.drawLine(10, getSize().height - 11, getSize().width - 11, getSize().height - 11); m_offgraphics.drawLine(getSize().width - 11, 25, getSize().width - 11, getSize().height - 11); m_offgraphics.setColor(getColor("innerBorderLeftTop")); m_offgraphics.drawLine(10, 25, getSize().width - 11, 25); m_offgraphics.drawLine(10, 25, 10, getSize().height - 11); // draw title int cx = 10; int cy = 17; m_offgraphics.setFont(m_font); m_offgraphics.setColor(getColor("colorHeadline")); m_offgraphics.drawString(m_action, cx, cy); m_offgraphics.setColor(getColor("colorText")); // draw process message if (m_outputMode >= 3) { cx = Math.max((getSize().width - m_metrics.stringWidth(m_message)) / 2, 0); } else { cx = 25; } cy = 41; m_offgraphics.drawString(m_message, cx, cy); // draw process bar during zip creation if (m_outputMode == 2) { float bar = new Float(m_step).floatValue() / new Float(m_resources).floatValue(); String barText = "(" + m_step + " / " + m_resources + ")"; m_offgraphics.drawRect(25, 50, 450, 20); m_offgraphics.setColor(Color.white); m_offgraphics.fillRect(26, 51, 449, 19); m_offgraphics.setColor(getColor("progessBar")); m_offgraphics.fillRect(26, 51, new Float(bar * 449).intValue(), 19); int progressWith = m_metrics.stringWidth(barText); cx = Math.max((getSize().width - progressWith) / 2, 0); cy = 64; m_offgraphics.setColor(Color.black); m_offgraphics.drawString(barText, cx, cy); } // show floater during upload if (m_outputMode == 3) { m_offgraphics.drawImage(m_floater, m_floaterPos, 57, this); m_offgraphics.drawImage(m_source, 30, 47, this); m_offgraphics.drawImage(m_target, 440, 47, this); } // copy the offcreen graphics to the applet g.drawImage(m_offscreen, 0, 0, null); }
From source file:ded.ui.DiagramController.java
@Override public void paint(Graphics g) { // Swing JPanel is double buffered already, but that is not // sufficient to avoid rendering bugs on Apple computers // with HiDPI/Retina displays. This is an attempt at a // hack that might circumvent it, effectively triple-buffering // the rendering step. if (this.tripleBufferMode != 0) { // The idea here is if I create an in-memory image with no // initial association with the display, whatever hacks Apple // has added should not kick in, and I get unscaled pixel // rendering. BufferedImage bi;//w ww .j a v a2 s . c o m if (this.tripleBufferMode == -1) { // This is not right because we might be drawing on a // different screen than the "default" screen. Also, I // am worried that a "compatible" image might be one // subject to the scaling effects I'm trying to avoid. GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); bi = gc.createCompatibleImage(this.getWidth(), this.getHeight()); } else { // This is not ideal because the color representation // for this hidden image may not match that of the display, // necessitating a conversion during 'drawImage'. try { bi = new BufferedImage(this.getWidth(), this.getHeight(), this.tripleBufferMode); } catch (IllegalArgumentException e) { // This would happen if 'tripleBufferMode' were invalid. if (this.tripleBufferMode == BufferedImage.TYPE_INT_ARGB) { // I don't know how this could happen. Re-throw. this.log("creating a BufferedImage with TYPE_INT_ARGB failed: " + Util.getExceptionMessage(e)); this.log("re-throwing exception..."); throw e; } else { // Change it to something known to be valid and try again. this.log("creating a BufferedImage with imageType " + this.tripleBufferMode + " failed: " + Util.getExceptionMessage(e)); this.log("switching type to TYPE_INT_ARGB and re-trying..."); this.tripleBufferMode = BufferedImage.TYPE_INT_ARGB; this.paint(g); return; } } } Graphics g2 = bi.createGraphics(); this.innerPaint(g2); g2.dispose(); g.drawImage(bi, 0, 0, null /*imageObserver*/); } else { this.innerPaint(g); } if (this.fpsMeasurementMode) { // Immediately trigger another paint cycle. this.repaint(); } }
From source file:com.jcraft.weirdx.Draw.java
@SuppressWarnings("unused") static void reqPolyFillRectangle(Client c, XDrawable d, GC gc) throws IOException { int n = c.length; //int foo;//from ww w .j a v a 2 s . c o m Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCSubwindowMode); if (graphics == null) { c.client.readPad(n * 4); return; } if (gc.clip_mask != null && gc.clip_mask instanceof ClipPixmap && (d instanceof XPixmap) && ((XPixmap) d).data != null) { XPixmap p = (XPixmap) d; byte[] data = p.data; XPixmap cpixmap = (XPixmap) (gc.clip_mask.getMask()); short x, y; int ww, hh; byte f = (byte) gc.fgPixel; while (n != 0) { x = (short) c.client.readShort(); y = (short) c.client.readShort(); ww = c.client.readShort(); hh = c.client.readShort(); n -= 2; if (x < 0) { ww += x; x = 0; } if (y < 0) { hh += y; y = 0; } if (d.width <= x || d.height <= y) continue; if (ww <= 0 || hh <= 0) continue; // if((x+ww)<=0 || (y+hh)<=0) continue; if (ww > cpixmap.width) ww = cpixmap.width; if (hh > cpixmap.height) hh = cpixmap.height; if (ww > d.width) ww = d.width; if (hh > d.height) hh = d.height; for (int i = 0; i < hh; i++) { for (int j = 0; j < ww; j++) { if (p.data[(i + y) * p.width + x + j] == 0) { p.data[(i + y) * p.width + x + j] = f; } } } } return; } /* if(gc.clip_mask!=null && (d instanceof Pixmap) && gc.clip_mask.width==d.width && gc.clip_mask.height==d.height && ((Pixmap)d).data!=null){ Pixmap p=(Pixmap)d; // for(int i=0;i<p.height;i++){ // for(int j=0;j<p.width;j++){ // System.out.print(p.data[i*p.width+j]+" "); // } // System.out.println(""); // } byte f=(byte)gc.fgPixel; for(int i=0;i<gc.clip_mask.height;i++){ for(int j=0;j<gc.clip_mask.width;j++){ if(p.data[i*gc.clip_mask.width+j]==0){ p.data[i*gc.clip_mask.width+j]=f; } } } // for(int i=0;i<((Pixmap)d).height;i++){ // for(int j=0;j<((Pixmap)d).width;j++){ // System.out.print(((Pixmap)d).data[i*((Pixmap)d).width+j]+" "); // } // System.out.println(""); // } while(n!=0){ c.client.readPad(8); n-=2; } return; } */ if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask()); if (rec == null) { while (n > 0) { c.client.readPad(8); n -= 2; } return; } } XPixmap p = null; if (((gc.attr & GC.fillStyle) == GC.FillOpaqueStippled) || ((gc.attr & GC.fillStyle) == GC.FillStippled)) { p = gc.stipple; } if (((gc.attr & GC.fillStyle) == GC.FillTiled)) { p = gc.tile.pixmap; } short x, y; int ww, hh; int sx = d.width; int sy = d.height; int lx = 0; int ly = 0; while (n != 0) { x = (short) c.client.readShort(); y = (short) c.client.readShort(); ww = c.client.readShort(); hh = c.client.readShort(); n -= 2; if (x < 0) { ww += x; x = 0; } if (y < 0) { hh += y; y = 0; } if (d.width <= x || d.height <= y) continue; if (ww <= 0 || hh <= 0) continue; if (x < sx) sx = x; ; if (lx < x + ww) lx = x + ww; if (y < sy) sy = y; if (ly < y + hh) ly = y + hh; if (((gc.attr & GC.fillStyle) == GC.FillOpaqueStippled) || ((gc.attr & GC.fillStyle) == GC.FillStippled) || ((gc.attr & GC.fillStyle) == GC.FillTiled)) { java.awt.Shape tmp = null; ww += x; hh += y; if ((p.width > ww - x) || (p.height > hh - y)) { tmp = graphics.getClip(); graphics.clipRect(x, y, ww - x, hh - y); } graphics.drawImage(p.img, x, y, Screen.screen[0].root.ddxwindow); if (tmp != null) graphics.setClip(tmp); for (int i = x + p.width; i < ww; i += p.width) { int www = p.width; int hhh = p.height; if (i + www > ww) www = ww - i; if (y + hhh >= hh) hhh = hh - y; graphics.copyArea(x, y, www, hhh, i - x, 0); } for (int j = y + p.height; j < hh; j += p.height) { int hhh = p.height; if (j + hhh >= hh) hhh = hh - j; graphics.copyArea(x, y, ww - x, hhh, 0, j - y); } } else { graphics.fillRect(x, y, ww, hh); } } if (sx < 0) sx = 0; if (sy < 0) sy = 0; if (d instanceof XWindow) { ((XWindow) d).draw(sx, sy, lx - sx + 2, ly - sy + 2); } if (gc.function == GC.GXxor || gc.function == GC.GXinvert) { graphics.setPaintMode(); } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { d.restoreClip(); } }
From source file:base.BasePlayer.BedTable.java
void drawScreen2(Graphics g) { buf.setColor(Color.black);//from w w w. j ava 2s . c om buf.fillRect(0, 0, this.getWidth(), this.getHeight()); //Header Draw if (aminoarray.size() > 0) { samplecount = 0; genemutcount = 0; for (int i = 0; i < aminoarray.size(); i++) { if ((i + 1) * rowHeight < tablescroll.getVerticalScrollBar().getValue()) { continue; } if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue() + this.getHeight()) { break; } /*if(mouseY >= (rowHeight*(i+samplecount+1)) && mouseY < (rowHeight*(i+samplecount+2))) { hoverNode = aminoarray.get(i).getNode(); hoverString = aminoarray.get(i).getRow(); }*/ for (int j = 0; j < aminoarray.get(i).getRow().length; j++) { try { // buf.setColor(Color.gray); // buf.drawLine(this.getWidth()/header.length*(j+1), rowHeight, this.getWidth()/header.length*(j+1), this.getHeight()); if (selectedNode != null && selectedNode.equals(aminoarray.get(i).getNode())) { // samplecount = selectedNode.getSamples().size(); /* buf.setColor(Color.black); buf.fillRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length, rowHeight); buf.setColor(Color.darkGray); buf.drawRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length, rowHeight); */ buf.setColor(Color.yellow); if (j < 2) { buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * (i + 1)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.yellow); for (int s = 0; s < samplecount; s++) { if (j == 2) { buf.setColor(Color.yellow); // buf.drawString(selectedNode.getSamples().get(s).getSample().getName(), 10, (rowHeight*(i+s+2))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); } buf.setColor(Color.black); buf.fillRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + s + 2))) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length + 1, rowHeight); buf.setColor(Color.yellow); buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * ((i + s + 2))) + 2 - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } /* for(int s = 0; s<samplecount; s++) { buf.setColor(Color.black); buf.fillRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length+1, rowHeight); buf.setColor(Color.yellow); buf.drawString(aminoarray.get(i).getRow()[j], 10+this.getWidth()/header.length*j, (rowHeight*((i+1)+samplecount))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); buf.drawString(selectedNode.getSamples().get(s).getSample().getName(), 10, (rowHeight*(i+s+2))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); } */ } else { buf.setColor(Color.black); buf.fillRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + 1) + samplecount)) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length, rowHeight); buf.setColor(Color.darkGray); buf.drawRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + 1) + samplecount)) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length, rowHeight); if (hoverNode != null && hoverNode.equals(aminoarray.get(i).getNode())) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * ((i + 1) + samplecount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } catch (Exception e) { e.printStackTrace(); ErrorLog.addError(e.getStackTrace()); } } } } for (int i = 0; i < header.length; i++) { buf.setColor(Color.darkGray); buf.fillRect(i * this.getWidth() / header.length, 0, this.getWidth() / header.length + 1, rowHeight); buf.setColor(Color.white); buf.drawString(header[i], i * this.getWidth() / header.length + 4, rowHeight - 2); buf.setColor(Color.black); buf.drawLine(i * this.getWidth() / header.length, 0, i * this.getWidth() / header.length, rowHeight); } g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null); }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void showKeggPathway(String sub, Path p) throws IOException { final BufferedImage selimg = ImageIO.read(Files.newInputStream(p)); if (selimg != null) { JFrame frame = new JFrame(sub); frame.setSize(800, 600);/*from ww w . jav a 2 s .com*/ final JComponent c = new JComponent() { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(selimg, 0, 0, this); } }; Dimension dim = new Dimension(selimg.getWidth(), selimg.getHeight()); c.setSize(dim); c.setPreferredSize(dim); JScrollPane sc2 = new JScrollPane(c); frame.add(sc2); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } }