List of usage examples for java.awt RenderingHints RenderingHints
public RenderingHints(Key key, Object value)
From source file:gui.DendrogramChart.java
ChartPanel getChartPanel(Dendrogram d, boolean log) { JFreeChart chart = ChartFactory.createXYLineChart(null, "Similarity", "No. of Groups", null, PlotOrientation.VERTICAL, true, true, false); setChartData(chart, log);//from www . j av a2s. co 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)); if (log == false) { NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); rangeAxis.setNumberFormatOverride(new DecimalFormat("0")); rangeAxis.setLabelFont(Prefs.labelFont); } else { // LogarithmicAxis logXAxis = new LogarithmicAxis("Similarity"); // logXAxis.setAllowNegativesFlag(true); LogarithmicAxis logYAxis = new LogarithmicAxis("No. Of Groups"); logYAxis.setAllowNegativesFlag(false); // plot.setDomainAxis(logXAxis); plot.setRangeAxis(logYAxis); } ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setPopupMenu(null); return chartPanel; }
From source file:no.met.jtimeseries.chart.XYCloudSymbolRenderer.java
/** * Creates a new renderer.// www .j a v a 2 s .c o m * @param numTimeSteps The number of total timesteps in the domain range. Used in the calculation of symbol width * @param numTimeStepsPerCloud The number of timesteps a cloudsymbol covers. Used in calculation of symbol width */ public XYCloudSymbolRenderer(int numTimeSteps) { super(); renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); this.numTimeSteps = numTimeSteps; }
From source file:be.fedict.eid.idp.sp.PhotoServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); response.setContentType("image/jpg"); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1"); // http 1.1 response.setHeader("Pragma", "no-cache, no-store"); // http 1.0 response.setDateHeader("Expires", -1); ServletOutputStream out = response.getOutputStream(); HttpSession session = request.getSession(); byte[] photoData = (byte[]) session.getAttribute(PHOTO_SESSION_ATTRIBUTE); if (null != photoData) { BufferedImage photo = ImageIO.read(new ByteArrayInputStream(photoData)); if (null == photo) { /*/*from w ww. j a v a 2s . co m*/ * In this case we render a photo containing some error message. */ photo = new BufferedImage(140, 200, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) photo.getGraphics(); RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHints(renderingHints); graphics.setColor(Color.WHITE); graphics.fillRect(1, 1, 140 - 1 - 1, 200 - 1 - 1); graphics.setColor(Color.RED); graphics.setFont(new Font("Dialog", Font.BOLD, 20)); graphics.drawString("Photo Error", 0, 200 / 2); graphics.dispose(); ImageIO.write(photo, "jpg", out); } else { out.write(photoData); } } out.close(); }
From source file:be.fedict.eid.applet.service.PhotoServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); response.setContentType("image/jpg"); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1"); // http 1.1 response.setHeader("Pragma", "no-cache, no-store"); // http 1.0 response.setDateHeader("Expires", -1); ServletOutputStream out = response.getOutputStream(); HttpSession session = request.getSession(); byte[] photoData = (byte[]) session.getAttribute(IdentityDataMessageHandler.PHOTO_SESSION_ATTRIBUTE); if (null != photoData) { BufferedImage photo = ImageIO.read(new ByteArrayInputStream(photoData)); if (null == photo) { /*/* ww w. j a v a 2 s.c o m*/ * In this case we render a photo containing some error message. */ photo = new BufferedImage(140, 200, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) photo.getGraphics(); RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHints(renderingHints); graphics.setColor(Color.WHITE); graphics.fillRect(1, 1, 140 - 1 - 1, 200 - 1 - 1); graphics.setColor(Color.RED); graphics.setFont(new Font("Dialog", Font.BOLD, 20)); graphics.drawString("Photo Error", 0, 200 / 2); graphics.dispose(); ImageIO.write(photo, "jpg", out); } else { out.write(photoData); } } out.close(); }
From source file:no.met.jtimeseries.chart.XYWindArrowRenderer.java
/** * Creates a new renderer./* w w w . j a va 2 s .c o m*/ */ public XYWindArrowRenderer() { super(); renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); }
From source file:Sampler.java
private void createTransformations() { AffineTransform at;//from w ww . j av a2s . com at = AffineTransform.getRotateInstance(Math.PI / 6, 0, 285); mOps.put("Rotate nearest neighbor", new AffineTransformOp(at, null)); RenderingHints rh = new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); mOps.put("Rotate bilinear", new AffineTransformOp(at, rh)); at = AffineTransform.getScaleInstance(.5, .5); mOps.put("Scale .5, .5", new AffineTransformOp(at, null)); at = AffineTransform.getRotateInstance(Math.PI / 6); mOps.put("Rotate bilinear (origin)", new AffineTransformOp(at, rh)); }
From source file:org.geoserver.wps.gs.raster.algebra.JiffleScriptProcessTest.java
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); GeoTiffFormat format = new GeoTiffFormat(); hints = new RenderingHints(JAI.KEY_TILE_CACHE, new SunTileCache(1024 * 1024 * 1024)); // Image preparation if (testCoverage1 == null) { GeoTiffReader reader = null;/*from w ww . j a va 2 s .com*/ try { final File input = new File(getClass().getResource(IMAGE_NAME_1).getPath()); reader = format.getReader(input); testCoverage1 = reader.read(null); } catch (Exception e) { LOGGER.log(Level.FINER, e.getMessage(), e); } finally { if (reader != null) { reader.dispose(); } } } if (testCoverage2 == null) { GeoTiffReader reader = null; try { final File input = new File(getClass().getResource(IMAGE_NAME_2).getPath()); reader = format.getReader(input); testCoverage2 = reader.read(null); } catch (Exception e) { LOGGER.log(Level.FINER, e.getMessage(), e); } finally { if (reader != null) { reader.dispose(); } } } if (testCoverage3 == null) { GeoTiffReader reader = null; try { final File input = new File(getClass().getResource(IMAGE_NAME_3).getPath()); reader = format.getReader(input); testCoverage3 = reader.read(null); } catch (Exception e) { LOGGER.log(Level.FINER, e.getMessage(), e); } finally { if (reader != null) { reader.dispose(); } } } }
From source file:util.ImgJaiTool.java
/** * A helper method that adds the tile cache hint with JAI.KEY_IMAGE_LAYOUT * to improve scale performance. This reduces the tile cache used to scale * the image./*from w ww . j a v a 2 s . c om*/ * * warning... seems to slow things down in some cases. * * http://archives.java.sun.com/cgi-bin/wa?A2=ind0202&L=jai-interest&P=3228 * * @param hints * existing list of RenderingHints * @param image * image to scale * @param factX * scaling factor x * @param factY * scaling factor y */ protected static RenderingHints addScaleTileCacheHint(RenderingHints hints, RenderedOp image, float factX, float factY) { int tW = (int) (image.getTileWidth() * factX); int tH = (int) (image.getTileHeight() * factY); if (tW <= 0) { tW = 1; } if (tH <= 0) { tH = 1; } ImageLayout il = null; if (hints == null) { il = new ImageLayout().setTileWidth(tW).setTileHeight(tH); hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il); } else { il = (ImageLayout) hints.get(JAI.KEY_IMAGE_LAYOUT); if (il == null) { il = new ImageLayout(); } il.setTileWidth(tW).setTileHeight(tH); hints.put(JAI.KEY_IMAGE_LAYOUT, il); } return hints; }
From source file:org.esa.s2tbx.dataio.s2.S2TileOpImage.java
public static PlanarImage create(File imageFile, File cacheDir, Point imagePos, TileLayout tileLayout, S2Config config, MultiLevelModel imageModel, S2SpatialResolution productResolution, int level) { Assert.notNull(cacheDir, "cacheDir"); Assert.notNull(tileLayout, "imageLayout"); Assert.notNull(imageModel, "imageModel"); if (imageFile != null) { SystemUtils.LOG.fine("Image layout: " + tileLayout); return new S2TileOpImage(imageFile, cacheDir, imagePos, tileLayout, imageModel, level); } else {/* w ww. j ava 2s .c om*/ SystemUtils.LOG.fine("Using empty image !"); TileLayout tileLaoutForProductResolution = config.getTileLayout(productResolution); int targetWidth = getSizeAtResolutionLevel(tileLaoutForProductResolution.width, level); int targetHeight = getSizeAtResolutionLevel(tileLaoutForProductResolution.height, level); Dimension targetTileDim = getTileDimAtResolutionLevel(tileLaoutForProductResolution.tileWidth, tileLaoutForProductResolution.tileHeight, level); SampleModel sampleModel = ImageUtils.createSingleBandedSampleModel(S2Config.SAMPLE_DATA_BUFFER_TYPE, targetWidth, targetHeight); ImageLayout imageLayout = new ImageLayout(0, 0, targetWidth, targetHeight, 0, 0, targetTileDim.width, targetTileDim.height, sampleModel, null); return ConstantDescriptor.create((float) imageLayout.getWidth(null), (float) imageLayout.getHeight(null), new Short[] { S2Config.FILL_CODE_NO_FILE }, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout)); } }
From source file:org.kuali.mobility.people.service.PeopleServiceImpl.java
@Override public BufferedImage generateObfuscatedImage(String text) { int width = 250; int height = 25; BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = bufferedImage.createGraphics(); Font font = new Font("Arial", Font.PLAIN, 14); g2d.setFont(font);//w w w . j a v a 2s .c o m RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh); Paint bg = new Color(255, 255, 255); g2d.setPaint(bg); g2d.fillRect(0, 0, width, height); int x = 0; int y = height - 7; Paint textPaint = new Color(0, 0, 0); g2d.setPaint(textPaint); g2d.drawString(text, x, y); g2d.dispose(); return bufferedImage; }