Example usage for java.awt RenderingHints VALUE_ANTIALIAS_ON

List of usage examples for java.awt RenderingHints VALUE_ANTIALIAS_ON

Introduction

In this page you can find the example usage for java.awt RenderingHints VALUE_ANTIALIAS_ON.

Prototype

Object VALUE_ANTIALIAS_ON

To view the source code for java.awt RenderingHints VALUE_ANTIALIAS_ON.

Click Source Link

Document

Antialiasing hint value -- rendering is done with antialiasing.

Usage

From source file:eu.udig.style.advanced.utils.Utilities.java

/**
 * Creates an {@link Image} for the given rule.
 * // ww  w. j  av a 2 s  .  c  om
 * @param rule the rule for which to create the image.
 * @param width the image width.
 * @param height the image height.
 * @return the generated image.
 */
public static BufferedImage lineRuleToImage(final Rule rule, int width, int height) {
    DuplicatingStyleVisitor copyStyle = new DuplicatingStyleVisitor();
    rule.accept(copyStyle);
    Rule newRule = (Rule) copyStyle.getCopy();

    Stroke stroke = null;
    Symbolizer[] symbolizers = newRule.getSymbolizers();
    if (symbolizers.length > 0) {
        Symbolizer symbolizer = newRule.getSymbolizers()[0];
        if (symbolizer instanceof LineSymbolizer) {
            LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer;
            stroke = SLDs.stroke(lineSymbolizer);
        }
    }

    int strokeSize = 0;
    if (stroke != null) {
        strokeSize = SLDs.width(stroke);
        if (strokeSize < 0) {
            strokeSize = 0;
            stroke.setWidth(ff.literal(strokeSize));
        }
    }

    // pointSize = width;
    BufferedImage finalImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    // Polygon polygon = d.polygon(new int[]{40,30, 60,70, 30,130, 130,130, 130,30});

    int[] xy = new int[] { (int) (height * 0.15), (int) (width * 0.85), (int) (height * 0.35),
            (int) (width * 0.15), (int) (height * 0.75), (int) (width * 0.85), (int) (height * 0.85),
            (int) (width * 0.15) };
    LineString line = d.line(xy);
    d.drawDirect(finalImage, d.feature(line), newRule);
    Graphics2D g2d = finalImage.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.drawImage(finalImage, 0, 0, null);
    g2d.dispose();

    return finalImage;
}

From source file:savant.view.tracks.BAMTrackRenderer.java

private void renderArcPairedMode(Graphics2D g2, GraphPaneAdapter gp) {

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    LOG.debug("YMAX for ARC mode: " + ((AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE)).getYMax());
    AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE);
    ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME);
    int discordantMin = (Integer) instructions.get(DrawingInstruction.DISCORDANT_MIN);
    int discordantMax = (Integer) instructions.get(DrawingInstruction.DISCORDANT_MAX);
    //LOG.info("discordantMin=" + discordantMin + " discordantMax=" + discordantMax);

    // set up colors
    Color normalArcColor = makeTransparent(cs.getColor(ColourKey.CONCORDANT_LENGTH));
    Color invertedReadColor = makeTransparent(cs.getColor(ColourKey.ONE_READ_INVERTED));
    Color evertedPairColor = makeTransparent(cs.getColor(ColourKey.EVERTED_PAIR));
    Color discordantLengthColor = makeTransparent(cs.getColor(ColourKey.DISCORDANT_LENGTH));
    Color unmappedMateColor = makeTransparent(cs.getColor(ColourKey.UNMAPPED_MATE));

    // set graph pane's range parameters
    gp.setXRange(axisRange.getXRange());
    gp.setYRange(axisRange.getYRange());

    // iterate through the data and draw
    LOG.debug("BAMTrackRenderer.renderArcMatePairMode: " + data.size() + " records.");
    for (Record record : data) {
        BAMIntervalRecord bamRecord = (BAMIntervalRecord) record;
        SAMRecord samRecord = bamRecord.getSAMRecord();
        SAMReadUtils.PairedSequencingProtocol prot = (SAMReadUtils.PairedSequencingProtocol) instructions
                .get(DrawingInstruction.PAIRED_PROTOCOL);
        SAMReadUtils.PairMappingType type = SAMReadUtils.getPairType(samRecord, prot);

        if (samRecord.getReadPairedFlag() && type != null) {
            if (samRecord.getMateUnmappedFlag()) {
                // Read with unmapped mate.
                int alignmentStart = samRecord.getAlignmentStart();
                double x = gp.transformXPos(alignmentStart);
                double radius = 4.0;
                double top = gp.transformYPos(axisRange.getYRange().getTo() * 0.25) + radius;
                g2.setColor(unmappedMateColor);
                g2.setStroke(ONE_STROKE);
                Path2D flower = new Path2D.Double();
                flower.moveTo(x, gp.transformYPos(0.0));
                flower.lineTo(x, top);//from  w  w w  . j a v a2  s.  co  m
                flower.moveTo(x - radius, top - radius);
                flower.lineTo(x + radius, top + radius);
                flower.moveTo(x - radius, top + radius);
                flower.lineTo(x + radius, top - radius);
                //flower.append(new Ellipse2D.Double(x - radius, top - radius, radius * 2.0, radius * 2.0), false);
                g2.draw(flower);
                recordToShapeMap.put(record, flower);

                // mates map to different chrs
            } else if (!samRecord.getMateReferenceName().equals(samRecord.getReferenceName())) {

                int alignmentStart = samRecord.getAlignmentStart();
                double x = gp.transformXPos(alignmentStart);
                double arrowWidth = 10;
                double arrowHeight = 15;
                double top = gp.transformYPos(axisRange.getYRange().getTo() * 0.9);
                g2.setColor(invertedReadColor);
                g2.setStroke(TWO_STROKE);

                Path2D stem = new Path2D.Double();
                stem.moveTo(x, gp.transformYPos(0.0));
                stem.lineTo(x, top + arrowHeight);

                g2.draw(stem);

                Path2D pointer = new Path2D.Double();
                pointer.moveTo(x, top);
                pointer.lineTo(x - arrowWidth / 2, top + arrowHeight);
                pointer.lineTo(x + arrowWidth / 2, top + arrowHeight);
                pointer.lineTo(x, top);
                g2.fill(pointer);

                pointer.append(stem, false);

                //flower.append(new Ellipse2D.Double(x - radius, top - radius, radius * 2.0, radius * 2.0), false);
                //g2.draw(pointer);

                recordToShapeMap.put(record, pointer);

                // mates map to the same chr
            } else {
                // Paired read with normal mate.

                int arcLength = Math.abs(samRecord.getInferredInsertSize());

                // skip reads with a zero insert length--probably mapping errors
                if (arcLength == 0) {
                    continue;
                }

                int alignmentStart;
                int mateAlignmentStart = samRecord.getMateAlignmentStart();
                if (samRecord.getAlignmentStart() > mateAlignmentStart) {
                    if (!(mateAlignmentStart < LocationController.getInstance().getRangeStart())) {
                        // this is the second in the pair, and it doesn't span the beginning of the range, so don't draw anything
                        continue;
                    } else {
                        // switch the mate start/end for the read start/end to deal with reversed position
                        alignmentStart = mateAlignmentStart;
                    }
                } else {
                    alignmentStart = samRecord.getAlignmentStart();
                }
                // at this point alignmentStart/End refers the the start end of the first occurrence in the pair

                int intervalStart;
                switch (type) {
                case INVERTED_READ:
                case INVERTED_MATE:
                    intervalStart = alignmentStart;
                    g2.setColor(invertedReadColor);
                    g2.setStroke(TWO_STROKE);
                    break;
                case EVERTED:
                    intervalStart = alignmentStart;
                    g2.setColor(evertedPairColor);
                    g2.setStroke(TWO_STROKE);
                    break;
                default:
                    // make sure arclength is over our threshold
                    /*if (threshold != 0.0d && threshold < 1.0d && arcLength < axisRange.getXRange().getLength()*threshold) {
                     continue;
                     }
                     else if (threshold > 1.0d && arcLength < threshold) {
                     continue;
                     }*/

                    intervalStart = alignmentStart;

                    if (arcLength > discordantMax || arcLength < discordantMin) {
                        g2.setColor(discordantLengthColor);
                        g2.setStroke(TWO_STROKE);
                    } else {
                        g2.setColor(normalArcColor);
                        g2.setStroke(ONE_STROKE);
                    }
                    break;
                }
                int arcHeight = arcLength;

                double rectWidth = arcLength * gp.getUnitWidth();
                double rectHeight = arcHeight * 2 * gp.getUnitHeight();

                double xOrigin = gp.transformXPos(intervalStart);
                double yOrigin = gp.transformYPos(arcHeight);

                Arc2D arc = new Arc2D.Double(xOrigin, yOrigin, rectWidth, rectHeight, -180, -180, Arc2D.OPEN);
                g2.draw(arc);
                recordToShapeMap.put(record, arc);
            }
        }
    }
}

From source file:com.pronoiahealth.olhie.server.services.BookCoverImageService.java

/**
 * Resize an image//from   ww  w.jav  a  2 s  .  co m
 * 
 * @param originalImage
 * @param width
 * @param height
 * @param type
 * @return
 */
private BufferedImage resize(BufferedImage originalImage, int width, int height, int type) {
    BufferedImage resizedImage = new BufferedImage(width, height, type);
    Graphics2D g = resizedImage.createGraphics();
    try {
        g.setComposite(AlphaComposite.Src);
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.drawImage(originalImage, 0, 0, width, height, null);
    } finally {
        if (g != null) {
            g.dispose();
        }
    }

    return resizedImage;
}

From source file:au.org.ala.layers.web.UserDataService.java

@RequestMapping(value = WS_USERDATA_WMS, method = RequestMethod.GET)
public void getPointsMap(
        @RequestParam(value = "CQL_FILTER", required = false, defaultValue = "") String cql_filter,
        @RequestParam(value = "ENV", required = false, defaultValue = "") String env,
        @RequestParam(value = "BBOX", required = false, defaultValue = "") String bboxString,
        @RequestParam(value = "WIDTH", required = false, defaultValue = "") String widthString,
        @RequestParam(value = "HEIGHT", required = false, defaultValue = "") String heightString,
        HttpServletRequest request, HttpServletResponse response) {
    RecordsLookup.setUserDataDao(userDataDao);

    response.setHeader("Cache-Control", "max-age=86400"); //age == 1 day
    response.setContentType("image/png"); //only png images generated

    int width = 256, height = 256;
    try {//ww  w .j  a  va2s.  c  o  m
        width = Integer.parseInt(widthString);
        height = Integer.parseInt(heightString);
    } catch (Exception e) {
        logger.error("error parsing to int: " + widthString + " or " + heightString, e);
    }

    try {
        env = URLDecoder.decode(env, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        logger.error("error decoding env from UTF-8: " + env, e);
    }
    int red = 0, green = 0, blue = 0, alpha = 0;
    String name = "circle";
    int size = 4;
    boolean uncertainty = false;
    String highlight = null;
    String colourMode = null;
    for (String s : env.split(";")) {
        String[] pair = s.split(":");
        if (pair[0].equals("color")) {
            while (pair[1].length() < 6) {
                pair[1] = "0" + pair[1];
            }
            red = Integer.parseInt(pair[1].substring(0, 2), 16);
            green = Integer.parseInt(pair[1].substring(2, 4), 16);
            blue = Integer.parseInt(pair[1].substring(4), 16);
        } else if (pair[0].equals("name")) {
            name = pair[1];
        } else if (pair[0].equals("size")) {
            size = Integer.parseInt(pair[1]);
        } else if (pair[0].equals("opacity")) {
            alpha = (int) (255 * Double.parseDouble(pair[1]));
            //            } else if (pair[0].equals("uncertainty")) {
            //                uncertainty = true;
        } else if (pair[0].equals("sel")) {
            try {
                highlight = URLDecoder.decode(s.substring(4), "UTF-8").replace("%3B", ";");
            } catch (Exception e) {
            }
        } else if (pair[0].equals("colormode")) {
            colourMode = pair[1];
        }
    }

    double[] bbox = new double[4];
    int i;
    i = 0;
    for (String s : bboxString.split(",")) {
        try {
            bbox[i] = Double.parseDouble(s);
            i++;
        } catch (Exception e) {
            logger.error("error converting bounding box value to double: " + s, e);
        }
    }
    try {

        //adjust bbox extents with half pixel width/height
        double pixelWidth = (bbox[2] - bbox[0]) / width;
        double pixelHeight = (bbox[3] - bbox[1]) / height;
        bbox[0] += pixelWidth / 2;
        bbox[2] -= pixelWidth / 2;
        bbox[1] += pixelHeight / 2;
        bbox[3] -= pixelHeight / 2;

        //offset for points bounding box by size
        double xoffset = (bbox[2] - bbox[0]) / (double) width
                * (size + (highlight != null ? HIGHLIGHT_RADIUS * 2 + size * 0.2 : 0) + 5);
        double yoffset = (bbox[3] - bbox[1]) / (double) height
                * (size + (highlight != null ? HIGHLIGHT_RADIUS * 2 + size * 0.2 : 0) + 5);

        //check offset for points bb by maximum uncertainty (?? 30k ??)
        if (uncertainty) {
            double xuoffset = 30000;
            double yuoffset = 30000;
            if (xoffset < xuoffset) {
                xoffset = xuoffset;
            }
            if (yoffset < yuoffset) {
                yoffset = yuoffset;
            }
        }

        //adjust offset for pixel height/width
        xoffset += pixelWidth;
        yoffset += pixelHeight;

        double[][] bb = {
                { SpatialUtils.convertMetersToLng(bbox[0] - xoffset),
                        SpatialUtils.convertMetersToLat(bbox[1] - yoffset) },
                { SpatialUtils.convertMetersToLng(bbox[2] + xoffset),
                        SpatialUtils.convertMetersToLat(bbox[3] + yoffset) } };

        double[] pbbox = new double[4]; //pixel bounding box
        pbbox[0] = SpatialUtils.convertLngToPixel(SpatialUtils.convertMetersToLng(bbox[0]));
        pbbox[1] = SpatialUtils.convertLatToPixel(SpatialUtils.convertMetersToLat(bbox[1]));
        pbbox[2] = SpatialUtils.convertLngToPixel(SpatialUtils.convertMetersToLng(bbox[2]));
        pbbox[3] = SpatialUtils.convertLatToPixel(SpatialUtils.convertMetersToLat(bbox[3]));

        String lsid = null;
        int p1 = 0;
        int p2 = cql_filter.indexOf('&', p1 + 1);
        if (p2 < 0) {
            p2 = cql_filter.indexOf(';', p1 + 1);
        }
        if (p2 < 0) {
            p2 = cql_filter.length();
        }
        if (p1 >= 0) {
            lsid = cql_filter.substring(0, p2);
        }

        double[] points = null;
        ArrayList<QueryField> listHighlight = null;
        QueryField colours = null;
        double[] pointsBB = null;
        Facet facet = null;
        String[] facetFields = null;
        if (highlight != null && !(colourMode != null && colourMode.equals("grid"))) {
            facet = Facet.parseFacet(highlight);
            facetFields = facet.getFields();
            listHighlight = new ArrayList<QueryField>();
        }

        int[] idx = null;
        if (lsid != null) {
            Object[] data = (Object[]) RecordsLookup.getData(lsid);
            points = (double[]) data[1];
            pointsBB = (double[]) data[4];
            idx = (int[]) data[5];

            if (points == null || points.length == 0 || pointsBB[0] > bb[1][0] || pointsBB[2] < bb[0][0]
                    || pointsBB[1] > bb[1][1] || pointsBB[3] < bb[0][1]) {
                setImageBlank(response);
                return;
            }

            ArrayList<QueryField> fields = (ArrayList<QueryField>) data[2];

            for (int j = 0; j < fields.size(); j++) {
                if (facet != null) {
                    for (int k = 0; k < facetFields.length; k++) {
                        if (facetFields[k].equals(fields.get(j).getName())) {
                            listHighlight.add(fields.get(j));
                        }
                    }
                }
                if (colourMode != null) {
                    if (fields.get(j).getName().equals(colourMode)) {
                        synchronized (fields.get(j)) {
                            //need to resize 'colours' facet to the correct length and store as new QueryField
                            for (int k = 0; k < fields.size(); k++) {
                                if (fields.get(k).getName().equals(colourMode + " resized")) {
                                    colours = fields.get(k);
                                }
                            }

                            if (colours == null) {
                                colours = fields.get(j);

                                //does it need to be rebuilt to the correct length?
                                int count = colours.getIntData() != null ? colours.getIntData().length
                                        : colours.getLongData() != null ? colours.getLongData().length
                                                : colours.getFloatData() != null ? colours.getFloatData().length
                                                        : colours.getDoubleData() != null
                                                                ? colours.getDoubleData().length
                                                                : 0;
                                if (count != points.length / 2) {
                                    QueryField qf = new QueryField();
                                    qf.setDisplayName(colours.getDisplayName());
                                    qf.setName(colours.getName() + " resized");
                                    for (int k = 0; k < idx.length; k++) {
                                        qf.add(colours.getAsString(idx[k]));
                                    }
                                    qf.store();

                                    fields.add(qf);

                                    colours = qf;
                                }
                            }
                        }
                    }
                }
            }
        }

        /* TODO: make this a copy instead of create */
        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = (Graphics2D) img.getGraphics();
        g.setColor(new Color(0, 0, 0, 0));
        g.fillRect(0, 0, width, height);

        g.setColor(new Color(red, green, blue, alpha));
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        int x, y;
        int pointWidth = size * 2 + 1;
        double width_mult = (width / (pbbox[2] - pbbox[0]));
        double height_mult = (height / (pbbox[1] - pbbox[3]));

        if (colourMode != null && colourMode.equals("grid")) {
            int divs = 16;
            double grid_width_mult = (width / (pbbox[2] - pbbox[0])) / (256 / divs);
            double grid_height_mult = (height / (pbbox[1] - pbbox[3])) / (256 / divs);
            int[][] gridCounts = new int[divs][divs];
            for (i = 0; i < points.length; i += 2) {
                x = (int) ((SpatialUtils.convertLngToPixel(points[i]) - pbbox[0]) * grid_width_mult);
                y = (int) ((SpatialUtils.convertLatToPixel(points[i + 1]) - pbbox[3]) * grid_height_mult);
                if (x >= 0 && x < divs && y >= 0 && y < divs) {
                    gridCounts[x][y]++;
                }
            }
            int xstep = 256 / divs;
            int ystep = 256 / divs;
            for (x = 0; x < divs; x++) {
                for (y = 0; y < divs; y++) {
                    int v = gridCounts[x][y];
                    if (v > 0) {
                        if (v > 500) {
                            v = 500;
                        }
                        int colour = Legend.getLinearColour(v, 0, 500, 0xFFFFFF00, 0xFFFF0000);
                        g.setColor(new Color(colour));
                        g.fillRect(x * xstep, y * ystep, xstep, ystep);
                    }
                }
            }
        } else {
            //circle type
            if (name.equals("circle")) {
                if (colours == null) {
                    for (i = 0; i < points.length; i += 2) {
                        if (points[i] >= bb[0][0] && points[i] <= bb[1][0] && points[i + 1] >= bb[0][1]
                                && points[i + 1] <= bb[1][1]) {
                            x = (int) ((SpatialUtils.convertLngToPixel(points[i]) - pbbox[0]) * width_mult);
                            y = (int) ((SpatialUtils.convertLatToPixel(points[i + 1]) - pbbox[3])
                                    * height_mult);
                            g.fillOval(x - size, y - size, pointWidth, pointWidth);
                        }
                    }
                } else {
                    int prevColour = -1; //!= colours[0]
                    g.setColor(new Color(prevColour));
                    for (i = 0; i < points.length; i += 2) {
                        if (points[i] >= bb[0][0] && points[i] <= bb[1][0] && points[i + 1] >= bb[0][1]
                                && points[i + 1] <= bb[1][1]) {
                            //colours is made the correct length, see above
                            int thisColour = colours.getColour(i / 2);
                            if (thisColour != prevColour) {
                                g.setColor(new Color(thisColour));
                                prevColour = thisColour;
                            }
                            x = (int) ((SpatialUtils.convertLngToPixel(points[i]) - pbbox[0]) * width_mult);
                            y = (int) ((SpatialUtils.convertLatToPixel(points[i + 1]) - pbbox[3])
                                    * height_mult);
                            g.fillOval(x - size, y - size, pointWidth, pointWidth);
                        }
                    }
                }
            }

            if (highlight != null && facet != null) {
                g.setStroke(new BasicStroke(2));
                g.setColor(new Color(255, 0, 0, 255));
                int sz = size + HIGHLIGHT_RADIUS;
                int w = sz * 2 + 1;

                for (i = 0; i < points.length; i += 2) {
                    if (points[i] >= bb[0][0] && points[i] <= bb[1][0] && points[i + 1] >= bb[0][1]
                            && points[i + 1] <= bb[1][1]) {

                        if (facet.isValid(listHighlight, idx[i / 2])) {
                            x = (int) ((SpatialUtils.convertLngToPixel(points[i]) - pbbox[0]) * width_mult);
                            y = (int) ((SpatialUtils.convertLatToPixel(points[i + 1]) - pbbox[3])
                                    * height_mult);
                            g.drawOval(x - sz, y - sz, w, w);
                        }
                    }
                }
            }
        }

        g.dispose();

        try {
            OutputStream os = response.getOutputStream();
            ImageIO.write(img, "png", os);
            os.flush();
            os.close();
        } catch (IOException e) {
            logger.error("error in outputting wms/reflect image as png", e);
        }
    } catch (Exception e) {
        logger.error("error generating wms/reflect tile", e);
    }

    //logger.debug("[wms tile: " + (System.currentTimeMillis() - start) + "ms]");
}

From source file:org.kalypso.ogc.gml.map.MapPanel.java

/**
 * Paints contents of the map in the following order:
 * <ul>//w  w  w . j a  va2s.co  m
 * <li>the buffered image containing the layers</li>
 * <li>the status, if not OK</li>
 * <li>all 'paint-listeners'</li>
 * <li>the current widget</li>
 * </ul>
 * 
 * @see java.awt.Component#paint(java.awt.Graphics)
 */
@Override
public void paint(final Graphics g) {
    final int width = getWidth();
    final int height = getHeight();
    if (height == 0 || width == 0)
        return;

    // only recreate buffered image if size has changed
    if (m_imageBuffer == null || m_imageBuffer.getWidth() != width || m_imageBuffer.getHeight() != height)
        m_imageBuffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    else
        // this seems to be enough for clearing the image here
        m_imageBuffer.flush();

    Graphics2D bufferGraphics = null;
    try {
        bufferGraphics = m_imageBuffer.createGraphics();
        bufferGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        bufferGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        final BufferPaintJob bufferPaintJob = m_bufferPaintJob; // get copy (for more thread safety)
        if (bufferPaintJob != null) {
            paintBufferedMap(bufferGraphics, bufferPaintJob);
        }

        // TODO: at the moment, we paint the status just on top of the map, if we change this component to SWT, we should
        // show the statusComposite in a title bar, if the status is non-OK (with details button for a stack trace)
        paintStatus(bufferGraphics);

        final IMapPanelPaintListener[] pls = m_paintListeners.toArray(new IMapPanelPaintListener[] {});
        for (final IMapPanelPaintListener pl : pls)
            pl.paint(bufferGraphics);

        paintWidget(bufferGraphics);
    } finally {
        if (bufferGraphics != null)
            bufferGraphics.dispose();
    }

    if (m_isMultitouchEnabled) {
        final IMapPanelMTPaintListener[] postls = m_postPaintListeners
                .toArray(new IMapPanelMTPaintListener[] {});
        for (final IMapPanelMTPaintListener pl : postls)
            pl.paint(m_imageBuffer);
    } else {
        g.drawImage(m_imageBuffer, 0, 0, null);
    }
}

From source file:MyJava3D.java

public void setAntiAlias(boolean aa) {
    AntiAlias = aa ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF;
}

From source file:com.zacwolf.commons.email.Email.java

public static BufferedImage makeRoundedBanner(BufferedImage image, int cornerRadius) {
    int w = image.getWidth();
    int h = image.getHeight() + 10;
    BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = output.createGraphics();
    g2.setComposite(AlphaComposite.Src);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);//from   ww  w  .j  a v  a  2s . co  m
    g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius));
    g2.setComposite(AlphaComposite.SrcAtop);
    g2.drawImage(image, 0, 0, null);
    g2.setComposite(AlphaComposite.SrcOver);
    //               g2.setColor(new Color(153,153,153));//slight grey border
    //               g2.drawRoundRect(0, 0, w-1, h, cornerRadius, cornerRadius);
    g2.dispose();
    return output.getSubimage(0, 0, image.getWidth(), image.getHeight());
}

From source file:com.zacwolf.commons.email.Email.java

public static BufferedImage makeRoundedFooter(int width, int cornerRadius, Color bgcolor, Color border)
        throws Exception {
    int height = (cornerRadius * 2) + 10;
    BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = output.createGraphics();
    g2.setComposite(AlphaComposite.Src);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(bgcolor);//w ww . ja  va  2  s.c o m
    g2.fillRoundRect(0, 0, width, height - 1, cornerRadius, cornerRadius);
    g2.setComposite(AlphaComposite.SrcOver);
    if (border != null) {
        g2.setColor(border);
        g2.drawRoundRect(0, 0, width - 1, height - 2, cornerRadius, cornerRadius);
    }
    g2.dispose();
    Rectangle clip = createClip(output, new Dimension(width, cornerRadius), 0, height - cornerRadius - 1);
    return output.getSubimage(clip.x, clip.y, clip.width, clip.height);
}

From source file:de.fhg.igd.mapviewer.AbstractTileOverlayPainter.java

/**
 * Configure the given graphics/* w  w w. j ava 2s  .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:org.pentaho.di.core.gui.SwingDirectGC.java

public void setAntialias(boolean antiAlias) {
    if (antiAlias) {

        RenderingHints hints = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
        hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        // hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
        // RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY));
        gc.setRenderingHints(hints);//from www .j a  v a2  s .c  o m
    }
}