List of usage examples for java.awt RenderingHints VALUE_COLOR_RENDER_SPEED
Object VALUE_COLOR_RENDER_SPEED
To view the source code for java.awt RenderingHints VALUE_COLOR_RENDER_SPEED.
Click Source Link
From source file:juicebox.mapcolorui.HeatmapRenderer.java
public boolean render(int originX, int originY, int width, int height, final MatrixZoomData zd, final MatrixZoomData controlZD, final MatrixType displayOption, final NormalizationType normalizationType, final ExpectedValueFunction df, Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); int chr1 = zd.getChr1Idx(); int chr2 = zd.getChr2Idx(); int x = originX; int y = originY; boolean isWholeGenome = chr1 == 0 && chr2 == 0; boolean sameChr = (chr1 == chr2); if (sameChr) { // Data is transposable, transpose if necessary. Convention is to use lower diagonal if (x > y) { //noinspection SuspiciousNameCombination x = originY;/* w w w. j a v a 2 s .com*/ y = originX; int tmp = width; width = height; height = tmp; } } int maxX = x + width - 1; int maxY = y + height - 1; if (displayOption == MatrixType.PEARSON) { BasicMatrix bm = zd.getPearsons(df); ((HiCColorScale) pearsonColorScale).setMin(bm.getLowerValue()); ((HiCColorScale) pearsonColorScale).setMax(bm.getUpperValue()); renderMatrix(bm, originX, originY, width, height, pearsonColorScale, g); } else { // Iterate through blocks overlapping visible region List<Block> blocks = zd.getNormalizedBlocksOverlapping(x, y, maxX, maxY, normalizationType); if (blocks == null) { return false; } boolean hasControl = controlZD != null && (displayOption == MatrixType.CONTROL || displayOption == MatrixType.RATIO); Map<Integer, Block> controlBlocks = new HashMap<Integer, Block>(); if (hasControl) { List<Block> ctrls = controlZD.getNormalizedBlocksOverlapping(x, y, maxX, maxY, normalizationType); for (Block b : ctrls) { controlBlocks.put(b.getNumber(), b); } } String key = zd.getKey() + displayOption; ColorScale cs = getColorScale(key, displayOption, isWholeGenome, blocks); double averageCount = zd.getAverageCount(); // Will get overwritten for intra-chr double ctrlAverageCount = controlZD == null ? 1 : controlZD.getAverageCount(); for (Block b : blocks) { Collection<ContactRecord> recs = b.getContactRecords(); if (recs != null) { Map<String, ContactRecord> controlRecords = new HashMap<String, ContactRecord>(); if (hasControl) { Block cb = controlBlocks.get(b.getNumber()); if (cb != null) { for (ContactRecord ctrlRec : cb.getContactRecords()) { controlRecords.put(ctrlRec.getKey(), ctrlRec); } } } for (ContactRecord rec : recs) { double score = Double.NaN; if (displayOption == MatrixType.OE || displayOption == MatrixType.EXPECTED) { double expected = 0; if (chr1 == chr2) { if (df != null) { int binX = rec.getBinX(); int binY = rec.getBinY(); int dist = Math.abs(binX - binY); expected = df.getExpectedValue(chr1, dist); } } else { expected = (averageCount > 0 ? averageCount : 1); } if (displayOption == MatrixType.OE) { score = rec.getCounts() / expected; } else { score = expected; } } else if (displayOption == MatrixType.CONTROL && hasControl) { ContactRecord ctrlRecord = controlRecords.get(rec.getKey()); if (ctrlRecord != null) score = ctrlRecord.getCounts(); } else if (displayOption == MatrixType.RATIO && hasControl) { ContactRecord ctrlRecord = controlRecords.get(rec.getKey()); if (ctrlRecord != null && ctrlRecord.getCounts() > 0) { double num = rec.getCounts() / averageCount; double den = ctrlRecord.getCounts() / ctrlAverageCount; score = num / den; } } else { score = rec.getCounts(); } if (Double.isNaN(score)) continue; Color color = cs.getColor((float) score); g.setColor(color); int px = rec.getBinX() - originX; int py = rec.getBinY() - originY; if (px > -1 && py > -1 && px <= width && py <= height) { g.fillRect(px, py, HiCGlobals.BIN_PIXEL_WIDTH, HiCGlobals.BIN_PIXEL_WIDTH); } if (sameChr && (rec.getBinX() != rec.getBinY())) { px = (rec.getBinY() - originX); py = (rec.getBinX() - originY); if (px > -1 && py > -1 && px <= width && py <= height) { g.fillRect(px, py, HiCGlobals.BIN_PIXEL_WIDTH, HiCGlobals.BIN_PIXEL_WIDTH); } } } } } } return true; }
From source file:org.squidy.designer.shape.VisualShape.java
@Override protected final void paint(PPaintContext paintContext) { super.paint(paintContext); Graphics2D g = paintContext.getGraphics(); // Set default font. g.setFont(internalFont);/* w w w. jav a2 s.co m*/ // if (!renderingHintsSet) { if (isRenderPrimitive()) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } else { // Use anti aliasing -> May slow down performance. g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DEFAULT); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } // renderingHintsSet = true; // } // Paint the shapes visual representation. paintShape(paintContext); // Allows visual debugging if enabled. if (DebugConstants.ENABLED) { paintDebug(paintContext); } }