List of usage examples for java.awt Graphics2D drawImage
public abstract void drawImage(BufferedImage img, BufferedImageOp op, int x, int y);
From source file:de._13ducks.cor.graphics.GraphicsComponent.java
private void runRenderRoundFix(Graphics2D g2) { //System.out.println("This is runRenderRound, searching for <" + searchprop + "> mapsize(x,y) view [x,y]: (" + sizeX + "," + sizeY + ") [" + viewX + "," + viewY + "]"); for (int x = 0; x < sizeX && x < viewX; x = x + 2) { for (int y = 0; y < sizeY && y < viewY; y = y + 2) { // X und Y durchlaufen, wenn ein Bild da ist, dann einbauen // System.out.println("Searching for " + x + "," + y); String tex = null;//from ww w . ja va 2s. co m try { tex = visMap[x + positionX][y + positionY].getFix_tex(); } catch (java.lang.ArrayIndexOutOfBoundsException ex) { // Kann beim Scrollein vorkommen - Einfach nichts zeichnen, denn da ist die Map zu Ende... } // Was da? if (tex != null) { // Bild suchen und einfgen CoRImage tempImage; if (colMode) { // SW-Modus BufferedImage newTemp = grayImgMap.get(tex).getImage(); tempImage = new CoRImage(newTemp); } else { // Normalfall tempImage = imgMap.get(tex); } if (tempImage != null) { g2.drawImage(tempImage.getImage(), x * 10, (int) (y * 7.5), null); } else { System.out.println("[RME][ERROR]: Image \"" + tex + "\" not found!"); } } // System.out.println(x + " " + y); } } for (int x = 0 + 1; x < sizeX && x < viewX; x = x + 2) { for (int y = 0 + 1; y < sizeY && y < viewY; y = y + 2) { // X und Y durchlaufen, wenn ein Bild da ist, dann einbauen // System.out.println("Searching for " + x + "," + y); String tex = null; try { tex = visMap[x + positionX][y + positionY].getFix_tex(); } catch (java.lang.ArrayIndexOutOfBoundsException ex) { // Siehe oben, egal weil hier die Map zu Ende ist... } // Was da? if (tex != null) { // Bild suchen und einfgen CoRImage tempImage; if (colMode) { // SW-Modus BufferedImage newTemp = grayImgMap.get(tex).getImage(); tempImage = new CoRImage(newTemp); } else { // Normalfall tempImage = imgMap.get(tex); } if (tempImage != null) { g2.drawImage(tempImage.getImage(), x * 10, (int) (y * 7.5), null); } else { System.out.println("[RME][ERROR]: Image \"" + tex + "\" not found!"); } } } } }
From source file:de._13ducks.cor.graphics.GraphicsComponent.java
private void runRenderRoundGround(Graphics2D g2) { //System.out.println("This is runRenderRound, searching for <" + searchprop + "> mapsize(x,y) view [x,y]: (" + sizeX + "," + sizeY + ") [" + viewX + "," + viewY + "]"); for (int x = 0; x < sizeX && x < viewX; x = x + 2) { for (int y = 0; y < sizeY && y < viewY; y = y + 2) { // X und Y durchlaufen, wenn ein Bild da ist, dann einbauen // System.out.println("Searching for " + x + "," + y); String tex = null;//www . jav a2s . co m try { tex = visMap[x + positionX][y + positionY].getGround_tex(); } catch (java.lang.ArrayIndexOutOfBoundsException ex) { // Kann beim Scrollein vorkommen - Einfach nichts zeichnen, denn da ist die Map zu Ende... } // Was da? if (tex != null) { // Bild suchen und einfgen CoRImage tempImage; if (colMode) { // SW-Modus BufferedImage newTemp = grayImgMap.get(tex).getImage(); tempImage = new CoRImage(newTemp); } else { // Normalfall tempImage = imgMap.get(tex); } if (tempImage != null) { g2.drawImage(tempImage.getImage(), x * 10, (int) (y * 7.5), null); } else { System.out.println("[RME][ERROR]: Image \"" + tex + "\" not found!"); } } // System.out.println(x + " " + y); } } for (int x = 0 + 1; x < sizeX && x < viewX; x = x + 2) { for (int y = 0 + 1; y < sizeY && y < viewY; y = y + 2) { // X und Y durchlaufen, wenn ein Bild da ist, dann einbauen // System.out.println("Searching for " + x + "," + y); String tex = null; try { tex = visMap[x + positionX][y + positionY].getGround_tex(); } catch (java.lang.ArrayIndexOutOfBoundsException ex) { // Siehe oben, egal weil hier die Map zu Ende ist... } // Was da? if (tex != null) { // Bild suchen und einfgen CoRImage tempImage; if (colMode) { // SW-Modus BufferedImage newTemp = grayImgMap.get(tex).getImage(); tempImage = new CoRImage(newTemp); } else { // Normalfall tempImage = imgMap.get(tex); } if (tempImage != null) { g2.drawImage(tempImage.getImage(), x * 10, (int) (y * 7.5), null); } else { System.out.println("[RME][ERROR]: Image \"" + tex + "\" not found!"); } } } } }
From source file:net.sf.mzmine.modules.visualization.twod.PointTwoDXYPlot.java
public boolean render(final Graphics2D g2, final Rectangle2D dataArea, int index, PlotRenderingInfo info, CrosshairState crosshairState) { // if this is not TwoDDataSet if (index != 0) return super.render(g2, dataArea, index, info, crosshairState); // prepare some necessary constants final int x = (int) dataArea.getX(); final int y = (int) dataArea.getY(); final int width = (int) dataArea.getWidth(); final int height = (int) dataArea.getHeight(); final double imageRTMin = (double) getDomainAxis().getRange().getLowerBound(); final double imageRTMax = (double) getDomainAxis().getRange().getUpperBound(); final double imageRTStep = (imageRTMax - imageRTMin) / width; final double imageMZMin = (double) getRangeAxis().getRange().getLowerBound(); final double imageMZMax = (double) getRangeAxis().getRange().getUpperBound(); final double imageMZStep = (imageMZMax - imageMZMin) / height; // This if statement below keeps the min max values at the original values when the user // zooms in. We need some variables that scall as the box size so that the points we show // have better resolution the more someone zooms in. double dynamicImageRTMin = imageRTMin; double dynamicImageRTMax = imageRTMax; double dynamicImageMZMin = imageMZMin; double dynamicImageMZMax = imageMZMax; double dynamicImageRTStep = imageRTStep; double dynamicImageMZStep = imageMZStep; if ((zoomOutBitmap != null) && (imageRTMin == totalRTRange.lowerEndpoint()) && (imageRTMax == totalRTRange.upperEndpoint()) && (imageMZMin == totalMZRange.lowerEndpoint()) && (imageMZMax == totalMZRange.upperEndpoint()) && (zoomOutBitmap.getWidth() == width) && (zoomOutBitmap.getHeight() == height)) { g2.drawImage(zoomOutBitmap, x, y, null); return true; }/* w ww. java2 s .c o m*/ // Save current time Date renderStartTime = new Date(); // prepare a bitmap of required size //BufferedImage image = new BufferedImage(width, height, //BufferedImage.TYPE_INT_ARGB); //ArrayList<DataPoint> listOfDataPoints = new ArrayList<DataPoint>(); //ArrayList<DataPoint> listOfRTValues = new ArrayList<DataPoint>(); ArrayList<DataPoint> listOfDataPoints; ArrayList<Double> listOfRTValues; // These two function must be run in this order Range<Double> rtRangeIn = Range.closed(getDomainAxis().getRange().getLowerBound(), getDomainAxis().getRange().getUpperBound()); Range<Double> mzRangeIn = Range.closed(getRangeAxis().getRange().getLowerBound(), getRangeAxis().getRange().getUpperBound()); listOfDataPoints = dataset.getCentroidedDataPointsInRTMZRange(rtRangeIn, mzRangeIn); listOfRTValues = dataset.getrtValuesInUserRange(); // points to be plotted List plotPoints = new ArrayList(); int count = 0; // Store the current mz,rt,int values so that they can be outputed to a file if we want //currentlyPlottedMZ = new ArrayList(); //for (Iterator dpIt = listOfDataPoints.iterator(); dpIt.hasNext();) { // make a list to keep track of the intesities of each for (DataPoint curDataPoint : listOfDataPoints) { //DataPoint curDataPoint = dpIt.next(); double currentRT = listOfRTValues.get(count).doubleValue(); double currentMZ = curDataPoint.getMZ(); plotPoints.add(new Point2D.Double(currentRT, currentMZ)); count += 1; //currentlyPlottedMZ.add() } // draw image points //for (int i = 0; i < width; i++) // for (int j = 0; j < height; j++) { // Color pointColor = paletteType.getColor(values[i][j]); // //image.setRGB(i, height - j - 1, pointColor.getRGB()); // points.add(new Point2D.Float(i,j)); // } count = 0; for (Iterator i = plotPoints.iterator(); i.hasNext();) { Point2D.Double pt = (Point2D.Double) i.next(); // using the ''dynamic'' min and max will make the resolution imporve as someone zooms // in //float xPlace = (pt.x-(float)dynamicImageRTMin)/((float)dynamicImageRTStep) + x; //float yPlace = (pt.y-(float)dynamicImageMZMin)/((float)dynamicImageMZStep) + y; double xPlace = (pt.x - dynamicImageRTMin) / (dynamicImageRTStep) + (double) x; double yPlace = (double) height - (pt.y - dynamicImageMZMin) / (dynamicImageMZStep) + (double) y; //get the current intensity // use the R, G B for the intensity double curIntensity = listOfDataPoints.get(count).getIntensity(); curIntensity = curIntensity / dataset.curMaxIntensity; //g2.setColor(Color.BLACK); Color pointColor = paletteType.getColor(curIntensity); g2.setColor(pointColor); Ellipse2D dot = new Ellipse2D.Double(xPlace - 1, yPlace - 1, 2, 2); g2.fill(dot); count += 1; } //float xPlace = ((float)42.0-(float)dynamicImageRTMin)/((float)dynamicImageRTStep)+x; //float yPlace = (float)height - ((float)201.02-(float)dynamicImageMZMin)/((float)dynamicImageMZStep)+y; //Ellipse2D dot = new Ellipse2D.Float(xPlace - 1, yPlace - 1, 2, 2); //g2.fill(dot); //g2.dispose(); // if we are zoomed out, save the values if ((imageRTMin == totalRTRange.lowerEndpoint()) && (imageRTMax == totalRTRange.upperEndpoint()) && (imageMZMin == totalMZRange.lowerEndpoint()) && (imageMZMax == totalMZRange.upperEndpoint())) { //zoomOutBitmap = image; } // Paint image //g2.drawImage(image, x, y, null); //g.setColor(Color.BLACK) Date renderFinishTime = new Date(); logger.finest("Finished rendering 2D visualizer, " + (renderFinishTime.getTime() - renderStartTime.getTime()) + " ms"); return true; }
From source file:org.tsho.dmc2.core.chart.AbsorbingAreaRenderer.java
public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) { state = STATE_RUNNING;/*from www. ja v a2s .com*/ gridWidth = (int) dataArea.getWidth(); gridHeight = (int) dataArea.getHeight(); //imageX,imageY correspond to point(0,0) int imageX = (int) dataArea.getX() + 1; int imageY = (int) dataArea.getY() + 1; DataBufferInt dataBuffer; image = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); grid = ((DataBufferInt) raster.getDataBuffer()).getData(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); xEpsilon = Math.abs((domainAxis.getUpperBound() - domainAxis.getLowerBound()) / (double) gridWidth); yEpsilon = Math.abs((rangeAxis.getUpperBound() - rangeAxis.getLowerBound()) / (double) gridHeight); int numPoints = gridHeight * gridWidth; int index = 0; int rate = numPoints / 100; if (justClearedSet) { if (criticalSetFound) { this.clearDisplay(); g2.drawImage(image, null, imageX, imageY); } justClearedSet = false; return; } if (!notYetRendered) { plotCopiedDisplay(); g2.drawImage(image, null, imageX, imageY); } notYetRendered = false; if (criticalSetFound && !findCriticalSetAgain) { if (this.chooseSegmentsSet) chooseSegments(g2, image, imageX, imageY); if (this.plotAttractorSet) plotAttractor(g2, image, imageX, imageY); if (this.iterateChosenSegmentsSet) iterateChosenSegments(g2, image, imageX, imageY); if (this.hideAttractorSet) hideAttractor(g2, image, imageX, imageY); } else { this.disableAllActionsExceptStop(); det = new AbsorbingAreaRenderer.ImplicitDeterminant(gridWidth, gridHeight, epsilon, g2, image, imageX, imageY); gridBackup = new int[grid.length]; copyDisplay(); criticalSetFound = true; findCriticalSetAgain = false; g2.drawImage(image, null, imageX, imageY); this.enableAllActionsExceptStop(); } }
From source file:ImageOps.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); int w = getSize().width; int h = getSize().height; g2.setColor(Color.black);/*from w ww.jav a 2s . c o m*/ float[][] data = { { 0.1f, 0.1f, 0.1f, // low-pass filter 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.1f }, SHARPEN3x3_3 }; String theDesc[] = { "Convolve LowPass", "Convolve Sharpen", "LookupOp", "RescaleOp" }; for (int i = 0; i < bi.length; i++) { int iw = bi[i].getWidth(this); int ih = bi[i].getHeight(this); int x = 0, y = 0; AffineTransform at = new AffineTransform(); at.scale((w - 14) / 2.0 / iw, (h - 34) / 2.0 / ih); BufferedImageOp biop = null; BufferedImage bimg = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); switch (i) { case 0: case 1: x = i == 0 ? 5 : w / 2 + 3; y = 15; Kernel kernel = new Kernel(3, 3, data[i]); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); break; case 2: x = 5; y = h / 2 + 15; byte chlut[] = new byte[256]; for (int j = 0; j < 200; j++) chlut[j] = (byte) (256 - j); ByteLookupTable blut = new ByteLookupTable(0, chlut); LookupOp lop = new LookupOp(blut, null); lop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); break; case 3: x = w / 2 + 3; y = h / 2 + 15; RescaleOp rop = new RescaleOp(1.1f, 20.0f, null); rop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); } g2.drawImage(bimg, biop, x, y); TextLayout tl = new TextLayout(theDesc[i], g2.getFont(), g2.getFontRenderContext()); tl.draw(g2, (float) x, (float) y - 4); } }
From source file:MyJava3D.java
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException { if (pi >= 1) { return Printable.NO_SUCH_PAGE; }//from w w w. ja v a2s . c om Graphics2D g2d = (Graphics2D) g; g2d.translate(pf.getImageableX(), pf.getImageableY()); g2d.translate(pf.getImageableWidth() / 2, pf.getImageableHeight() / 2); Dimension d = getSize(); double scale = Math.min(pf.getImageableWidth() / d.width, pf.getImageableHeight() / d.height); if (scale < 1.0) { g2d.scale(scale, scale); } g2d.translate(-d.width / 2.0, -d.height / 2.0); if (bimg == null) { Graphics2D g2 = createGraphics2D(d.width, d.height, null, g2d); render(d.width, d.height, g2); g2.dispose(); } else { g2d.drawImage(bimg, 0, 0, this); } return Printable.PAGE_EXISTS; }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public Image getImage() { BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); // gc2.setBackground(Color.white); g2.setPaint(Color.white);/*w w w .j a va 2 s. c o m*/ g2.fill(new Rectangle2D.Double(0, 0, getWidth(), getHeight())); if (getChart() != null) { Image chartImage = getChart().createBufferedImage((int) getWidth(), (int) getHeight()); g2.drawImage(chartImage, 0, 0, this); ChartMaskingUtilities.drawMasks(g2, getScreenDataArea(), maskList, null, getChart()); } g2.dispose(); return image; }
From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java
public boolean renderArea(Graphics2D g2, Rectangle2D dataArea) { CoreStatusEvent statusEv = new CoreStatusEvent(this); g2.setPaint(paint);//from w ww .j a v a 2s .co m final double parHStep, parVStep; double parHLower = domainAxis.getRange().getLowerBound(); double parHUpper = domainAxis.getRange().getUpperBound(); double parVLower = rangeAxis.getRange().getLowerBound(); double parVUpper = rangeAxis.getRange().getUpperBound(); parHStep = Math.abs(parHUpper - parHLower) / dataArea.getWidth(); parVStep = Math.abs(parVUpper - parVLower) / dataArea.getHeight(); final BufferedImage image = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(), BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer(); int[] data = dataBuffer.getData(); final double parHStart = parHLower + parHStep / 2; final double parVStart = parVUpper - parVStep / 2; for (int i = 0; i < (int) dataArea.getWidth(); i++) { for (int j = 0; j < (int) dataArea.getHeight(); j++) { parameters.put(firstParLabel, parHStart + i * parHStep); parameters.put(secondParLabel, parVStart - j * parVStep); double[] result; int color; try { result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations); } catch (ModelException e) { String mess = "Exception while:\n" + dumpVariableDoubles(parameters) + dumpVariableDoubles(initialPoint); throw new ModelException(mess, e); } if (result == null) { System.out.println("i: " + i + " j: " + j); System.out.println("par1: " + parHStart + i * parHStep); System.out.println("par2: " + parVStart + j * parVStep); g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); statusEv.setStatusString("exception"); statusEv.setType(CoreStatusEvent.STRING); notifyCoreStatusListeners(statusEv); return false; } // both zero if (Math.abs(result[0]) < epsilon && Math.abs(result[1]) < epsilon) { color = Color.black.getRGB(); } // one zero one positive else if (Math.abs(result[0]) < epsilon && result[1] > 0 || Math.abs(result[1]) < epsilon && result[0] > 0) { color = Color.red.getRGB(); } // one zero one negative else if (Math.abs(result[0]) < epsilon && result[1] < 0 || Math.abs(result[1]) < epsilon && result[0] < 0) { color = Color.blue.getRGB(); } // one positive one negative else if (result[0] < 0 && result[1] > 0 || result[1] < 0 && result[0] > 0) { color = Color.green.getRGB(); } // both positive else if (result[0] > 0 && result[1] > 0) { color = Color.orange.getRGB(); } // both negative else if (result[0] < 0 && result[1] < 0) { color = Color.pink.getRGB(); } else { // impossible color = Color.yellow.getRGB(); } data[i + j * (int) dataArea.getWidth()] = color; if (stopped == true) { return false; } if (j == (int) dataArea.getHeight() - 1) { g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); statusEv.setPercent(0); statusEv.setType(CoreStatusEvent.COUNT | CoreStatusEvent.PERCENT); notifyCoreStatusListeners(statusEv); } } } return true; }
From source file:ucar.unidata.idv.control.chart.TimeSeriesChart.java
/** * draw the time line/*from w w w . ja v a 2 s .c om*/ * * @param g2 param * @param plot param * @param dataArea param * @param domainAxis param * @param rangeAxis param * @param rendererIndex param * @param info param */ private void drawTime(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { try { Animation animation = control.getSomeAnimation(); if (animation == null) { return; } Real dttm = animation.getAniValue(); if (dttm == null) { return; } g2.setStroke(new BasicStroke()); g2.setColor(Color.black); double timeValue = dttm.getValue(CommonUnit.secondsSinceTheEpoch); int x = (int) domainAxis.valueToJava2D(timeValue * 1000, dataArea, RectangleEdge.BOTTOM); if ((x < dataArea.getX()) || (x > dataArea.getX() + dataArea.getWidth())) { return; } int bottom = (int) (dataArea.getY() + dataArea.getHeight()); int top = (int) (dataArea.getY()); int offset = 0; if (false && (clockImage == null)) { clockImage = GuiUtils.getImage("/auxdata/ui/icons/clock.gif"); clockImage.getHeight(this); offset = clockImage.getHeight(null); } // g2.drawLine(x, (int) dataArea.getY(), x, bottom - offset); int w = 8; int w2 = w / 2; int[] xs = { x - w2, x, x + w2, x }; int[] ys = { top, top + w, top, top }; // g2.drawLine(x, top, x, top+10); g2.fillPolygon(xs, ys, xs.length); if (clockImage != null) { g2.drawImage(clockImage, x - clockImage.getWidth(null) / 2, bottom - clockImage.getHeight(null), null); } } catch (VisADException exc) { } catch (RemoteException exc) { } }
From source file:net.geoprism.dashboard.DashboardMap.java
private BufferedImage getLegendTitleImage(DashboardLayer layer) { FontMetrics fm;/*from w w w .ja v a 2 s . c o m*/ int textWidth; int textHeight; int textBoxHorizontalPadding = 4; int textBoxVerticalPadding = 4; int borderWidth = 2; int paddedTitleHeight; int paddedTitleWidth; int titleLeftPadding = textBoxHorizontalPadding; BufferedImage newLegendTitleBase; Graphics2D newLegendTitleBaseGraphic = null; try { // Build the Font object Font titleFont = new Font(layer.getName(), Font.BOLD, 14); // Build variables for base legend graphic construction try { newLegendTitleBase = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); newLegendTitleBaseGraphic = newLegendTitleBase.createGraphics(); newLegendTitleBaseGraphic.setFont(titleFont); fm = newLegendTitleBaseGraphic.getFontMetrics(); textHeight = fm.getHeight(); textWidth = fm.stringWidth(layer.getName()); paddedTitleWidth = textWidth + (textBoxHorizontalPadding * 2) + (borderWidth * 2); paddedTitleHeight = textHeight + (textBoxVerticalPadding * 2) + (borderWidth * 2); } finally { // dispose of temporary graphics context if (newLegendTitleBaseGraphic != null) { newLegendTitleBaseGraphic.dispose(); } } titleLeftPadding = ((paddedTitleWidth / 2) - ((textWidth + (textBoxHorizontalPadding * 2) + (borderWidth * 2)) / 2)) + textBoxHorizontalPadding; newLegendTitleBase = new BufferedImage(paddedTitleWidth, paddedTitleHeight, BufferedImage.TYPE_INT_ARGB); newLegendTitleBaseGraphic = newLegendTitleBase.createGraphics(); newLegendTitleBaseGraphic.drawImage(newLegendTitleBase, 0, 0, null); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); newLegendTitleBaseGraphic.setFont(titleFont); // draw title text fm = newLegendTitleBaseGraphic.getFontMetrics(); newLegendTitleBaseGraphic.setColor(Color.WHITE); newLegendTitleBaseGraphic.drawString(layer.getName(), titleLeftPadding, fm.getAscent() + textBoxVerticalPadding); newLegendTitleBaseGraphic.drawImage(newLegendTitleBase, 0, 0, null); } finally { if (newLegendTitleBaseGraphic != null) { newLegendTitleBaseGraphic.dispose(); } } return newLegendTitleBase; }