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:nz.ac.massey.cs.gql4jung.browser.resultviews.GraphBasedResultView.java
@Override public void display(final MotifInstance instance, DirectedGraph<Vertex, Edge> graph) { DirectedGraph<VisualVertex, VisualEdge> g = instance == null ? new DirectedSparseGraph<VisualVertex, VisualEdge>() : this.asGraph(instance); //SimpleGraphView sgv = new SimpleGraphView(); //We create our graph in here // The Layout<V, E> is parameterized by the vertex and edge types Layout<VisualVertex, VisualEdge> layout = settings.getLayout(g); layout.setSize(graphPane.getSize()); VisualizationViewer<VisualVertex, VisualEdge> vv = new VisualizationViewer<VisualVertex, VisualEdge>( layout);/*from w ww. j a v a 2s .c o m*/ if (!settings.isUseAntiAliasing()) { Map hints = new HashMap(); hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); vv.setRenderingHints(hints); } configureRenderer(vv.getRenderContext(), instance); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.setPreferredSize(graphPane.getSize()); //Sets the viewing area size vv.setBackground(settings.getBackground()); graphPane.removeAll(); graphPane.add(vv); graphPane.revalidate(); // pick the vertices that are part of the pattern - this brings them into the foreground /* for (VisualVertex v:g.getVertices()){ if (v.isInMotif()) { vv.getPickedVertexState().pick(v,true); } } */ //vv.addMouseListener(popupListener); // Create a graph mouse and add it to the visualization component DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(gm); vv.setVertexToolTipTransformer(new Transformer<VisualVertex, String>() { @Override public String transform(VisualVertex v) { return getToolTip(v); } }); }
From source file:org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler.java
/** {@inheritDoc} */ public IFPainter startPageContent() throws IFException { int bitmapWidth; int bitmapHeight; double scale; Point2D offset = null;//from w w w. j av a2 s. co m if (targetBitmapSize != null) { //Fit the generated page proportionally into the given rectangle (in pixels) double scale2w = 1000 * targetBitmapSize.width / this.currentPageDimensions.getWidth(); double scale2h = 1000 * targetBitmapSize.height / this.currentPageDimensions.getHeight(); bitmapWidth = targetBitmapSize.width; bitmapHeight = targetBitmapSize.height; //Centering the page in the given bitmap offset = new Point2D.Double(); if (scale2w < scale2h) { scale = scale2w; double h = this.currentPageDimensions.height * scale / 1000; offset.setLocation(0, (bitmapHeight - h) / 2.0); } else { scale = scale2h; double w = this.currentPageDimensions.width * scale / 1000; offset.setLocation((bitmapWidth - w) / 2.0, 0); } } else { //Normal case: just scale according to the target resolution scale = scaleFactor * getUserAgent().getTargetResolution() / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION; bitmapWidth = (int) ((this.currentPageDimensions.width * scale / 1000f) + 0.5f); bitmapHeight = (int) ((this.currentPageDimensions.height * scale / 1000f) + 0.5f); } //Set up bitmap to paint on this.currentImage = createBufferedImage(bitmapWidth, bitmapHeight); Graphics2D graphics2D = this.currentImage.createGraphics(); // draw page background if (!getSettings().hasTransparentPageBackground()) { graphics2D.setBackground(getSettings().getPageBackgroundColor()); graphics2D.setPaint(getSettings().getPageBackgroundColor()); graphics2D.fillRect(0, 0, bitmapWidth, bitmapHeight); } //Set rendering hints graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); if (getSettings().isAntiAliasingEnabled() && this.currentImage.getColorModel().getPixelSize() > 1) { graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } if (getSettings().isQualityRenderingEnabled()) { graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } else { graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); } graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); //Set up initial coordinate system for the page if (offset != null) { graphics2D.translate(offset.getX(), offset.getY()); } graphics2D.scale(scale / 1000f, scale / 1000f); return new Java2DPainter(graphics2D, getContext(), getFontInfo()); }
From source file:org.apache.pdfbox.pdfviewer.PageDrawer.java
/** * Fill the path./*from ww w .j a va 2 s.c o m*/ * * @param windingRule The winding rule this path will use. * * @throws IOException If there is an IO error while filling the path. */ public void fillPath(int windingRule) throws IOException { graphics.setComposite(getGraphicsState().getNonStrokeJavaComposite()); Paint nonStrokingPaint = getGraphicsState().getNonStrokingColor().getJavaColor(); if (nonStrokingPaint == null) { nonStrokingPaint = getGraphicsState().getNonStrokingColor().getPaint(pageSize.height); } if (nonStrokingPaint == null) { LOG.info("ColorSpace " + getGraphicsState().getNonStrokingColor().getColorSpace().getName() + " doesn't provide a non-stroking color, using white instead!"); nonStrokingPaint = Color.WHITE; } graphics.setPaint(nonStrokingPaint); getLinePath().setWindingRule(windingRule); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setClip(getGraphicsState().getCurrentClippingPath()); graphics.fill(getLinePath()); getLinePath().reset(); }
From source file:org.apache.pdfbox.pdfviewer.PageDrawer.java
/** * Stroke the path./*from w w w .j a v a 2 s . co m*/ * * @throws IOException If there is an IO error while stroking the path. */ public void strokePath() throws IOException { graphics.setComposite(getGraphicsState().getStrokeJavaComposite()); Paint strokingPaint = getGraphicsState().getStrokingColor().getJavaColor(); if (strokingPaint == null) { strokingPaint = getGraphicsState().getStrokingColor().getPaint(pageSize.height); } if (strokingPaint == null) { LOG.info("ColorSpace " + getGraphicsState().getStrokingColor().getColorSpace().getName() + " doesn't provide a stroking color, using white instead!"); strokingPaint = Color.WHITE; } graphics.setPaint(strokingPaint); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setClip(getGraphicsState().getCurrentClippingPath()); GeneralPath path = getLinePath(); graphics.draw(path); path.reset(); }
From source file:org.apache.pdfbox.pdfviewer.PageDrawer.java
/** * Fill with Shading. Called by SHFill operator. * * @param shadingName The name of the Shading Dictionary to use for this fill instruction. * * @throws IOException If there is an IO error while shade-filling the clipping area. *///w w w . j av a2 s. co m public void shFill(COSName shadingName) throws IOException { PDShadingResources shading = getResources().getShadings().get(shadingName.getName()); LOG.debug("Shading = " + shading.toString()); int shadingType = shading.getShadingType(); Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Paint paint = null; switch (shadingType) { case 1: // TODO LOG.debug("Function based shading not yet supported"); break; case 2: paint = new AxialShadingPaint((PDShadingType2) shading, ctm, pageSize.height); break; case 3: paint = new RadialShadingPaint((PDShadingType3) shading, ctm, pageSize.height); break; case 4: case 5: case 6: case 7: // TODO LOG.debug("Shading type " + shadingType + " not yet supported"); break; default: throw new IOException("Invalid ShadingType " + shadingType + " for Shading " + shadingName); } graphics.setComposite(getGraphicsState().getNonStrokeJavaComposite()); graphics.setPaint(paint); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.fill(getGraphicsState().getCurrentClippingPath()); }
From source file:org.apache.pdfbox.rendering.PageDrawer.java
@Override public void fillPath(int windingRule) throws IOException { graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(getNonStrokingPaint()); setClip();/*from www . j a v a2 s . c o m*/ linePath.setWindingRule(windingRule); // disable anti-aliasing for rectangular paths, this is a workaround to avoid small stripes // which occur when solid fills are used to simulate piecewise gradients, see PDFBOX-2302 // note that we ignore paths with a width/height under 1 as these are fills used as strokes, // see PDFBOX-1658 for an example Rectangle2D bounds = linePath.getBounds2D(); boolean noAntiAlias = isRectangular(linePath) && bounds.getWidth() > 1 && bounds.getHeight() > 1; if (noAntiAlias) { graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if (!(graphics.getPaint() instanceof Color)) { // apply clip to path to avoid oversized device bounds in shading contexts (PDFBOX-2901) Area area = new Area(linePath); area.intersect(new Area(graphics.getClip())); graphics.fill(area); } else { graphics.fill(linePath); } linePath.reset(); if (noAntiAlias) { // JDK 1.7 has a bug where rendering hints are reset by the above call to // the setRenderingHint method, so we re-set all hints, see PDFBOX-2302 setRenderingHints(); } }
From source file:org.apache.pdflens.views.pagesview.PageDrawer.java
/** * Fill the path./*from ww w . j a va 2 s .c om*/ * * @param windingRule The winding rule this path will use. * * @throws IOException If there is an IO error while filling the path. */ public void fillPath(int windingRule) throws IOException { graphics.setColor(getGraphicsState().getNonStrokingColor().getJavaColor()); getLinePath().setWindingRule(windingRule); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setClip(getGraphicsState().getCurrentClippingPath()); graphics.fill(getLinePath()); getLinePath().reset(); }
From source file:org.apache.pdflens.views.pagesview.PageDrawer.java
/** * Stroke the path.//from w w w .j a v a2 s.co m * * @throws IOException If there is an IO error while stroking the path. */ public void strokePath() throws IOException { graphics.setColor(getGraphicsState().getStrokingColor().getJavaColor()); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setClip(getGraphicsState().getCurrentClippingPath()); GeneralPath path = getLinePath(); graphics.draw(path); path.reset(); }
From source file:org.geowebcache.georss.GeometryRasterMaskBuilder.java
/** * @param geom a geometry to mask the affected tiles for, in this matrix's gridSubSet coordinate * reference system/*w w w . ja v a 2 s . c om*/ */ public void setMasksForGeometry(final Geometry geom) { if (geom == null || geom.isEmpty()) { return; } final int startLevel = getStartLevel(); final int maxLevel = startLevel + getNumLevels() - 1; // loop over only up to the configured max masking level final int endLevel = Math.min(maxLevel, this.maxMaskLevel); if (logger.isDebugEnabled()) { logger.debug("Geom: " + geom); } if (aggregatedGeomBounds == null) { aggregatedGeomBounds = new Envelope(geom.getEnvelopeInternal()); } else { aggregatedGeomBounds.expandToInclude(geom.getEnvelopeInternal()); } for (int level = startLevel; level <= endLevel; level++) { final Geometry geometryInGridCrs = transformToGridCrs(geom, level); if (logger.isDebugEnabled()) { logger.debug("Geom in grid CRS: " + geometryInGridCrs); } final Geometry bufferedGeomInGridCrs = geometryInGridCrs.buffer(TILE_BUFFER_RATIO); if (logger.isDebugEnabled()) { logger.debug("Buffered Geom in grid CRS: " + bufferedGeomInGridCrs); } // do not generalize in LiteShape, it affects the expected masked pixels boolean generalize = false; // shape used identity transform, as the geometry is already projected Shape shape = new LiteShape(bufferedGeomInGridCrs, IDENTITY, generalize); Graphics2D graphics = getGraphics(level); /* * Disable antialiasing explicitly, otherwise the rendering will pick the platform's * default potentially producing missing pixels */ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setColor(Color.WHITE); graphics.fill(shape); } }
From source file:org.pentaho.reporting.engine.classic.core.layout.output.RenderUtility.java
public static DefaultImageReference createImageFromDrawable(final DrawableWrapper drawable, final StrictBounds rect, final StyleSheet box, final OutputProcessorMetaData metaData) { final int imageWidth = (int) StrictGeomUtility.toExternalValue(rect.getWidth()); final int imageHeight = (int) StrictGeomUtility.toExternalValue(rect.getHeight()); if (imageWidth == 0 || imageHeight == 0) { return null; }//from w ww . j a va 2s. c om final double scale = RenderUtility.getNormalizationScale(metaData); final Image image = ImageUtils.createTransparentImage((int) (imageWidth * scale), (int) (imageHeight * scale)); final Graphics2D g2 = (Graphics2D) image.getGraphics(); final Object attribute = box.getStyleProperty(ElementStyleKeys.ANTI_ALIASING); if (attribute != null) { if (Boolean.TRUE.equals(attribute)) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else if (Boolean.FALSE.equals(attribute)) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } } if (RenderUtility.isFontSmooth(box, metaData)) { g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } g2.scale(scale, scale); // the clipping bounds are a sub-area of the whole drawable // we only want to print a certain area ... final String fontName = (String) box.getStyleProperty(TextStyleKeys.FONT); final int fontSize = box.getIntStyleProperty(TextStyleKeys.FONTSIZE, 8); final boolean bold = box.getBooleanStyleProperty(TextStyleKeys.BOLD); final boolean italics = box.getBooleanStyleProperty(TextStyleKeys.ITALIC); if (bold && italics) { g2.setFont(new Font(fontName, Font.BOLD | Font.ITALIC, fontSize)); } else if (bold) { g2.setFont(new Font(fontName, Font.BOLD, fontSize)); } else if (italics) { g2.setFont(new Font(fontName, Font.ITALIC, fontSize)); } else { g2.setFont(new Font(fontName, Font.PLAIN, fontSize)); } g2.setStroke((Stroke) box.getStyleProperty(ElementStyleKeys.STROKE)); g2.setPaint((Paint) box.getStyleProperty(ElementStyleKeys.PAINT)); drawable.draw(g2, new Rectangle2D.Double(0, 0, imageWidth, imageHeight)); g2.dispose(); try { return new DefaultImageReference(image); } catch (final IOException e1) { logger.warn("Unable to fully load a given image. (It should not happen here.)", e1); return null; } }