List of usage examples for java.awt RenderingHints VALUE_ANTIALIAS_OFF
Object VALUE_ANTIALIAS_OFF
To view the source code for java.awt RenderingHints VALUE_ANTIALIAS_OFF.
Click Source Link
From source file:anl.verdi.plot.jfree.XYBlockRenderer.java
/** * Draws the block representing the specified item. * * @param g2 the graphics device. * @param state the state./*from w ww . j av a 2s . c o m*/ * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = 0.0; double max = paintScale.getUpperBound(); double min = paintScale.getLowerBound(); if (dataset instanceof XYZDataset) z = ((XYZDataset) dataset).getZValue(series, item); //NOTE: so to get the max/min color instead of unknown (Qun He, UNC, 03/19/2009) if (z > max) z = max; if (z < min) z = min; Color p = (Color) this.paintScale.getPaint(z); double xx0 = domainAxis.valueToJava2D(x + this.xOffset, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y + this.yOffset, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + this.blockWidth + this.xOffset, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + this.blockHeight + this.yOffset, dataArea, plot.getRangeAxisEdge()); Rectangle2D block; PlotOrientation orientation = plot.getOrientation(); if (orientation.equals(PlotOrientation.HORIZONTAL)) { block = new Rectangle2D.Double(Math.min(yy0, yy1), Math.min(xx0, xx1), Math.abs(yy1 - yy0), Math.abs(xx0 - xx1)); } else { block = new Rectangle2D.Double(Math.min(xx0, xx1), Math.min(yy0, yy1), Math.abs(xx1 - xx0), Math.abs(yy1 - yy0)); } g2.setColor(p); g2.fill(block); if (gridLinesEnabled) { boolean aaOn = false; if (g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING) == RenderingHints.VALUE_ANTIALIAS_ON) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); aaOn = true; } g2.setPaint(gridLineColor); g2.setStroke(gridLineStroke); g2.draw(block); if (aaOn) g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { g2.setStroke(basicStroke); g2.draw(block); } }
From source file:gui.QTLResultsPanel.java
private JPanel getChart(Trait trait) { JFreeChart chart = ChartFactory.createXYLineChart(null, "Position (cM)", "LOD Score", null, PlotOrientation.VERTICAL, true, true, false); setChartData(chart, trait);//from w w w .ja v a 2 s .c o m RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); chart.setRenderingHints(rh); chart.removeLegend(); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(255, 255, 220)); plot.setDomainGridlinePaint(new Color(128, 128, 128)); plot.setRangeGridlinePaint(new Color(128, 128, 128)); ValueAxis axis = plot.getRangeAxis(); if (trait.maxLOD <= 3) { axis.setUpperBound(3); } PermResult result = trait.getPermResult(); if (result != null) { float[] dashPattern = { 5, 5 }; BasicStroke s1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0); ValueMarker m1 = new ValueMarker(result.getSig90(), new Color(0, 0, 60), s1, null, null, 1.0f); ValueMarker m2 = new ValueMarker(result.getSig95(), new Color(0, 0, 60), s1, null, null, 1.0f); plot.addRangeMarker(m1); plot.addRangeMarker(m2); if (result.getSig95() > trait.maxLOD && result.getSig95() >= 3) { axis.setUpperBound(result.getSig95() * (1.05)); } } chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); return chartPanel; }
From source file:com.github.lucapino.sheetmaker.renderer.JavaTemplateRenderer.java
private void processTextElement(Graphics2D g2, Element textElement) { int x = Integer.valueOf(textElement.getAttributeValue("X")); int y = Integer.valueOf(textElement.getAttributeValue("Y")); int width = Integer.valueOf(textElement.getAttributeValue("Width")); int height = Integer.valueOf(textElement.getAttributeValue("Height")); String alignment = textElement.getAttributeValue("TextAlignment"); boolean multiline = Boolean.valueOf(textElement.getAttributeValue("Multiline").toLowerCase()); boolean antiAlias = textElement.getAttributeValue("TextQuality").equalsIgnoreCase("antialias"); Font font = parseFont(textElement.getAttributeValue("Font")); logger.info("Using font " + font); // now get the textim4java performance String text = textElement.getAttributeValue("Text"); // if text matches pattern of %VARIABLE%{MODIFIER} logger.info("parsing token {}", text); Matcher matcher = pattern.matcher(text); int start = 0; while (matcher.find(start)) { // apply modification text = text.replace(matcher.group(), applyModifier(matcher.group())); start = matcher.end();//from www . jav a 2 s . c o m } BufferedImage tmpImage; if (width > 0 && height > 0) { // create a transparent tmpImage tmpImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); } else { FontMetrics fm = g2.getFontMetrics(font); Rectangle outlineBounds = fm.getStringBounds(text, g2).getBounds(); // we need to create a transparent image to paint tmpImage = new BufferedImage(outlineBounds.width, outlineBounds.height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = tmpImage.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); // } g2d.setFont(font); Color textColor = new Color(Integer.valueOf(textElement.getAttributeValue("ForeColor"))); g2d.setColor(textColor); Composite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .8f); g2d.setComposite(comp); drawString(g2d, text, new Rectangle(0, 0, width, height), Align.valueOf(alignment), 0, multiline); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); tmpImage = processActions(textElement, tmpImage); //// Graphics2D g2d = tmpImage.createGraphics(); // // set current font // g2.setFont(font); //// g2d.setComposite(AlphaComposite.Clear); //// g2d.fillRect(0, 0, width, height); //// g2d.setComposite(AlphaComposite.Src); // // TODO: we have to parse it // int strokeWidth = Integer.valueOf(textElement.getAttributeValue("StrokeWidth")); // // the color of the outline // if (strokeWidth > 0) { //// Color strokeColor = new Color(Integer.valueOf(textElement.getAttributeValue("StrokeColor"))); //// AffineTransform affineTransform; //// affineTransform = g2d.getTransform(); //// affineTransform.translate(width / 2 - (outlineBounds.width / 2), height / 2 //// + (outlineBounds.height / 2)); //// g2d.transform(affineTransform); //// // backup stroke width and color //// Stroke originalStroke = g2d.getStroke(); //// Color originalColor = g2d.getColor(); //// g2d.setColor(strokeColor); //// g2d.setStroke(new BasicStroke(strokeWidth)); //// g2d.draw(shape); //// g2d.setClip(shape); //// // restore stroke width and color //// g2d.setStroke(originalStroke); //// g2d.setColor(originalColor); // } //// // get the text color // Color textColor = new Color(Integer.valueOf(textElement.getAttributeValue("ForeColor"))); // g2.setColor(textColor); //// g2d.setBackground(Color.BLACK); //// g2d.setStroke(new BasicStroke(2)); //// g2d.setColor(Color.WHITE); // // draw the text // // drawString(g2, text, new Rectangle(x, y, width, height), Align.valueOf(alignment), 0, multiline); // g2.drawString(text, x, y); // Rectangle rect = new Rectangle(x, y, width, height); // defines the desired size and position // FontMetrics fm = g2.getFontMetrics(); // FontRenderContext frc = g2.getFontRenderContext(); // TextLayout tl = new TextLayout(text, g2.getFont(), frc); // AffineTransform transform = new AffineTransform(); // transform.setToTranslation(rect.getX(), rect.getY()); // if (Boolean.valueOf(textElement.getAttributeValue("AutoSize").toLowerCase())) { // double scaleY // = rect.getHeight() / (double) (tl.getOutline(null).getBounds().getMaxY() // - tl.getOutline(null).getBounds().getMinY()); // transform.scale(rect.getWidth() / (double) fm.stringWidth(text), scaleY); // } // Shape shape = tl.getOutline(transform); // g2.setClip(shape); // g2.fill(shape.getBounds()); // if (antiAlias) { // we need to restore antialias to none // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); // } // g2.drawString(text, x, y); // alway resize // BicubicScaleFilter scaleFilter = new BicubicScaleFilter(width, height); // tmpImage = scaleFilter.filter(tmpImage, null); // draw the image to the source g2.drawImage(tmpImage, x, y, width, height, null); try { ScreenImage.writeImage(tmpImage, "/tmp/images/" + textElement.getAttributeValue("Name") + ".png"); } catch (IOException ex) { } }
From source file:MyJava3D.java
public void setAntiAlias(boolean aa) { AntiAlias = aa ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; }
From source file:de.fhg.igd.mapviewer.AbstractTileOverlayPainter.java
/** * Configure the given graphics/*from w w w. j a v a2 s . c o m*/ * * @param gfx the graphics device */ protected void configureGraphics(Graphics2D gfx) { if (antialiasing) { gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } }
From source file:lucee.runtime.img.Image.java
public void setAntiAliasing(boolean antiAlias) throws ExpressionException { this.antiAlias = antiAlias ? ANTI_ALIAS_ON : ANTI_ALIAS_OFF; Graphics2D graphics = getGraphics(); if (antiAlias) { graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else {/*from w ww. ja v a 2 s .c om*/ graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } }
From source file:freemind.controller.Controller.java
public Object setEdgesRenderingHint(Graphics2D g) { Object renderingHint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, (getAntialiasEdges()) ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); return renderingHint; }
From source file:freemind.controller.Controller.java
public void setTextRenderingHint(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, (getAntialiasAll()) ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, (getAntialiasAll()) ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); }
From source file:DefaultGraphics2D.java
/** * Get the rendering context of the <code>Font</code> within this * <code>Graphics2D</code> context. The {@link FontRenderContext} * encapsulates application hints such as anti-aliasing and fractional * metrics, as well as target device specific information such as * dots-per-inch. This information should be provided by the application when * using objects that perform typographical formatting, such as * <code>Font</code> and <code>TextLayout</code>. This information should * also be provided by applications that perform their own layout and need * accurate measurements of various characteristics of glyphs such as advance * and line height when various rendering hints have been applied to the text * rendering./* w ww . ja v a 2s . co m*/ * * @return a reference to an instance of FontRenderContext. * @see java.awt.font.FontRenderContext * @see java.awt.Font#createGlyphVector(FontRenderContext,char[]) * @see java.awt.font.TextLayout * @since JDK1.2 */ public FontRenderContext getFontRenderContext() { // // Find if antialiasing should be used. // Object antialiasingHint = hints.get(RenderingHints.KEY_TEXT_ANTIALIASING); boolean isAntialiased = true; if (antialiasingHint != RenderingHints.VALUE_TEXT_ANTIALIAS_ON && antialiasingHint != RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT) { // If antialias was not turned off, then use the general rendering // hint. if (antialiasingHint != RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) { antialiasingHint = hints.get(RenderingHints.KEY_ANTIALIASING); // Test general hint if (antialiasingHint != RenderingHints.VALUE_ANTIALIAS_ON && antialiasingHint != RenderingHints.VALUE_ANTIALIAS_DEFAULT) { // Antialiasing was not requested. However, if it was not turned // off explicitly, use it. if (antialiasingHint == RenderingHints.VALUE_ANTIALIAS_OFF) isAntialiased = false; } } else isAntialiased = false; } // // Find out whether fractional metrics should be used. // boolean useFractionalMetrics = true; if (hints.get(RenderingHints.KEY_FRACTIONALMETRICS) == RenderingHints.VALUE_FRACTIONALMETRICS_OFF) useFractionalMetrics = false; FontRenderContext frc = new FontRenderContext(defaultTransform, isAntialiased, useFractionalMetrics); return frc; }
From source file:org.forester.archaeopteryx.TreePanel.java
final void setTextAntialias() { if ((_phylogeny != null) && !_phylogeny.isEmpty()) { if (_phylogeny.getNumberOfExternalNodes() <= LIMIT_FOR_HQ_RENDERING) { _rendering_hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } else {//from ww w . ja v a2 s . c o m _rendering_hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); } } if (getMainPanel().getOptions().isAntialiasScreen()) { if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR) { _rendering_hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } else { _rendering_hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } try { _rendering_hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); } catch (final Throwable e) { _rendering_hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } } else { _rendering_hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); _rendering_hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } }