Example usage for java.awt.image BufferedImage getGraphics

List of usage examples for java.awt.image BufferedImage getGraphics

Introduction

In this page you can find the example usage for java.awt.image BufferedImage getGraphics.

Prototype

public java.awt.Graphics getGraphics() 

Source Link

Document

This method returns a Graphics2D , but is here for backwards compatibility.

Usage

From source file:org.deegree.portal.standard.wms.control.DynLegendListener.java

/**
 * Draws the given symbol to the given image
 * /*from   www .  j  a  v  a2s .com*/
 * @param map
 *            Hashmap holding the properties of the legend
 * @param bi
 *            image of the legend
 * @param color
 *            color to fill the graphic
 * @return The drawn BufferedImage
 */
private BufferedImage drawSymbolsToBI(HashMap<String, Object> map, BufferedImage bi, Color color) {

    Graphics g = bi.getGraphics();
    g.setColor(color);
    g.fillRect(0, 0, bi.getWidth(), bi.getHeight());

    String[] layers = (String[]) map.get("NAMES");
    String[] titles = (String[]) map.get("TITLES");
    BufferedImage[] legs = (BufferedImage[]) map.get("IMAGES");
    int h = topMargin;
    for (int i = layers.length - 1; i >= 0; i--) {
        g.drawImage(legs[i], leftMargin, h, null);
        g.setColor(Color.BLACK);
        // just draw title if the flag has been set in listener configuration,
        // the legend image is less than a defined value and a legend image
        // (not missing) has been accessed
        if (useLayerTitle && legs[i].getHeight() < maxNNLegendSize && !missing.contains(layers[i])) {
            g.drawString(titles[i], leftMargin + legs[i].getWidth() + 10,
                    h + (int) (legs[i].getHeight() / 1.2));
        }
        h += legs[i].getHeight() + 5;
        if (separator != null && i > 0) {
            g.drawImage(separator, leftMargin, h, null);
            h += separator.getHeight() + 5;
        }
    }
    g.dispose();
    return bi;
}

From source file:me.solhub.simple.engine.DebugLocationsStructure.java

@Override
protected void draw() {
    Graphics2D g = (Graphics2D) getGraphics();
    Graphics2D bbg = (Graphics2D) _backBuffer.getGraphics();

    //anti-aliasing code
    //        bbg.setRenderingHint(
    //                RenderingHints.KEY_TEXT_ANTIALIASING,
    //                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    //        bbg.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );

    bbg.setColor(Color.WHITE);/*from  w w  w. j  a va  2s .  c om*/
    bbg.fillRect(0, 0, _windowWidth, _windowHeight);

    bbg.translate(_xOffset, _yOffset);

    // draw destinations
    bbg.setColor(_simState.startingDestination.getColor());
    bbg.drawOval(-(int) _simState.startingDestination.getRadius(),
            -(int) _simState.startingDestination.getRadius(),
            (int) _simState.startingDestination.getRadius() * 2,
            (int) _simState.startingDestination.getRadius() * 2);
    Iterator<Entry<Vector2D, Color>> blah = _destinationColors.entrySet().iterator();
    double destinationRadius = _simState.getDestinationRadius();
    while (blah.hasNext()) {
        Entry<Vector2D, Color> temp = blah.next();
        bbg.setColor(temp.getValue());
        //calculate center coordinate
        int x = (int) (temp.getKey().getX() - (destinationRadius));
        int y = (int) (temp.getKey().getY() - (destinationRadius));
        //drawOval draws a circle inside a rectangle
        bbg.drawOval(x, y, _simState.getDestinationRadius() * 2, _simState.getDestinationRadius() * 2);
    }

    // draw each of the agents
    Iterator<Agent> agentIter = _simState.getAgentIterator();
    while (agentIter.hasNext()) {
        Agent temp = agentIter.next();
        if (temp.isAlive()) {
            // decide whether to color for destination or group
            //                if( isDestinationColors )
            //                {
            //                    // if stopped then blink white and destination color
            //                    if( temp.hasReachedDestination() )
            //                    {
            //                        if( pulseWhite % 20 == 0 )
            //                        {
            //                            bbg.setColor( Color.WHITE );
            //                        }
            //                        else
            //                        {
            //                            bbg.setColor( temp.getDestinationColor() );
            //                        }
            //                    }
            //                    else
            //                    {
            //                        bbg.setColor( temp.getDestinationColor() );
            //                    }
            //                }
            //                else
            //                {
            //                    // if stopped then blink black and white
            //                    if( temp.hasReachedDestination() )
            //                    {
            //                        if( pulseWhite % 20 == 0 )
            //                        {
            //                            bbg.setColor( Color.WHITE );
            //                        }
            //                        else
            //                        {
            //                            bbg.setColor( temp.getGroup().getGroupColor() );
            //                        }
            //                    }
            //                    //set color to red if cancelled and global and not multiple initiators
            //                    else if(temp.getCurrentDecision().getDecision().getDecisionType().equals(
            //                            DecisionType.CANCELLATION ) 
            //                            && _simState.getCommunicationType().equals( "global" )
            //                            && !Agent.canMultipleInitiate()
            //                            )
            //                    {
            //                        bbg.setColor( Color.RED );
            //                    }
            //                    else
            //                    {
            //                        bbg.setColor( temp.getGroup().getGroupColor() );
            //                    }
            //                }

            double dx = temp.getCurrentDestination().getX() - temp.getCurrentLocation().getX();
            double dy = temp.getCurrentDestination().getY() - temp.getCurrentLocation().getY();
            double heading = Math.atan2(dy, dx);
            Utils.drawDirectionalTriangle(bbg, heading - Math.PI / 2, temp.getCurrentLocation().getX(),
                    temp.getCurrentLocation().getY(), 7, temp.getPreferredDestination().getColor(),
                    temp.getGroup().getGroupColor());

            //                bbg.fillOval( (int) temp.getCurrentLocation().getX() - _agentSize,
            //                        (int) temp.getCurrentLocation().getY() - _agentSize , _agentSize * 2, _agentSize * 2 );
        }
    }
    pulseWhite++;
    bbg.setColor(Color.BLACK);
    // the total number of groups
    bbg.setFont(_infoFont);

    bbg.drawString("Run: " + (_simState.getCurrentSimulationRun() + 1), _fontXOffset, _fontYOffset);
    bbg.drawString("Time: " + _simState.getSimulationTime(), _fontXOffset, _fontYOffset + _fontSize);
    bbg.drawString("Delay: " + LIVE_DELAY, _fontXOffset, _fontYOffset + _fontSize * 2);

    if (_simState.getCommunicationType().equals("global") && !Agent.canMultipleInitiate()) {
        String initiatorName = "None";
        if (_initiatingAgent != null) {
            initiatorName = _initiatingAgent.getId().toString();
        }
        bbg.drawString("Init: " + initiatorName, _fontXOffset, _fontYOffset + _fontSize * 3);
        bbg.drawString("Followers: " + _numberFollowing, _fontXOffset, _fontYOffset + _fontSize * 4);
    } else {
        bbg.drawString("Groups: " + _simState.getNumberGroups(), _fontXOffset, _fontYOffset + _fontSize * 3);
        bbg.drawString("Reached: " + _simState.numReachedDestination, _fontXOffset,
                _fontYOffset + _fontSize * 4);
        bbg.drawString("Inits: " + _simState.numInitiating, _fontXOffset, _fontYOffset + _fontSize * 5);
        bbg.drawString("Eaten: " + _simState.getPredator().getTotalAgentsEaten(), _fontXOffset,
                _fontYOffset + _fontSize * 6);
    }

    g.scale(_zoom, _zoom);
    g.drawImage(_backBuffer, 0, 0, this);
    if (SHOULD_VIDEO) {

        // setup to save to a png
        BufferedImage buff = new BufferedImage(_windowWidth, _windowHeight, BufferedImage.TYPE_INT_RGB);
        Graphics2D temp = (Graphics2D) buff.getGraphics();
        temp.scale(8, 4);
        temp.drawImage(_backBuffer, 0, 0, this);
        // sub-directory
        File dir = new File("video");
        dir.mkdir();
        // format string for filename
        String filename = String.format("video/run-%03d-time-%05d.png", _simState.getCurrentSimulationRun(),
                _simState.getSimulationTime());
        File outputfile = new File(filename);
        // save it
        try {
            ImageIO.write(buff, "png", outputfile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:net.frogmouth.ddf.nitfinputtransformer.NitfInputTransformer.java

protected byte[] getThumbnail(SlottedNitfParseStrategy slottedNitf) {

    if (slottedNitf.getGraphicSegmentHeaders().isEmpty()) {
        LOGGER.debug("Loaded file, but found no graphic segments.");
        return null;
    }//  www . ja va 2 s.com
    try {
        NitfGraphicSegmentHeader segment = slottedNitf.getGraphicSegmentHeaders().get(0);
        CgmParser parser = new CgmParser(slottedNitf.getGraphicSegmentData().get(0));
        parser.buildCommandList();

        if (segment.getBoundingBox2Column() > 0 && segment.getBoundingBox2Row() > 0) {
            BufferedImage targetImage = new BufferedImage(segment.getBoundingBox2Column(),
                    segment.getBoundingBox2Row(), BufferedImage.TYPE_INT_ARGB);
            CgmRenderer renderer = new CgmRenderer();
            renderer.setTargetImageGraphics((Graphics2D) targetImage.getGraphics(),
                    segment.getBoundingBox2Column(), segment.getBoundingBox2Row());
            renderer.render(parser.getCommandList());
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(targetImage, "jpg", baos);
            return baos.toByteArray();
        } else {
            LOGGER.debug("No image to generate");
        }
    } catch (IOException e) {
        LOGGER.debug("Failed to parse image from nitf", e);
    }
    return null;
}

From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java

public void writeImage(String fileName, int format) {
    //System.out.println("writing image: "+fileName);
    BufferedImage img = null;
    try {//  w  w  w .ja va 2s .  c  o m
        img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
        dontWrite = true;
        paintComponent(img.getGraphics());
        dontWrite = false;
        File file = new File(fileName);
        switch (format) {
        case FORMAT_PNG:
            ImageUtilities.writePng(img, file);
            break;
        case FORMAT_YUV:
            int[] content = null;
            content = img.getData().getPixels(0, 0, img.getWidth(), img.getHeight(), content);
            if (yuvSaver == null || yuvSaver.getHeight() != img.getHeight()
                    || yuvSaver.getWidth() != img.getWidth()) {
                yuvSaver = new YUVSaver(img.getWidth(), img.getHeight(), fileName);
            }
            yuvSaver.saveEncoded(img, controlsFrame.getMovieCreationPanel().getCurrentFrameNumber());
            break;
        default:
            ImageIO.write(img, ImageFormat.JPEG_FORMAT.getExtension(), file);
            break;
        }

    } catch (FileNotFoundException ex) {
        //         pl.edu.icm.visnow.egg.error.Displayer.display(2008052915280L, ex, toString(), "File not found: " + fileName);
    } catch (IOException ex) {
        //         pl.edu.icm.visnow.egg.error.Displayer.display(2008052915290L, ex, toString(), "IO Exception: " + fileName);
    }
}

From source file:org.deegree.portal.standard.wms.control.DynLegendListener.java

/**
 * In case the legend can not be obtained from the OGCLayer, this method is called to create a dummy legend image
 * plus the legend title//w  w w  .j a va  2 s  . com
 * 
 * @param layerName
 * @return BufferedImage holding the created dummy legend
 */
private BufferedImage createMissingLegend(String layerName) {
    LOG.logDebug("URL is null. Drawing the image from a missingImage variable in init params");
    BufferedImage missingLegend = new BufferedImage(80, 15, BufferedImage.TYPE_INT_RGB);
    Graphics g = missingLegend.getGraphics();
    Rectangle2D rect = g.getFontMetrics().getStringBounds(layerName, g);
    g.dispose();
    missingLegend = new BufferedImage(rect.getBounds().width + 80, missingImg.getHeight() + 15,
            BufferedImage.TYPE_INT_ARGB);
    g = missingLegend.getGraphics();
    g.drawImage(missingImg, 0, 0, null);
    g.setColor(Color.RED);
    if (useLayerTitle) {
        g.drawString(layerName, missingImg.getWidth() + 5,
                missingImg.getHeight() / 2 + g.getFont().getSize() / 2);
    }
    g.dispose();

    return missingLegend;
}

From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Find")) {
        BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
        Graphics g = back.getGraphics();
        g.setColor(new Color(120, 120, 120, 120));
        g.fillRect(0, 0, back.getWidth(), back.getHeight());
        g.setColor(new Color(120, 120, 120));
        g.drawLine(0, 0, 3, 3);/*from   w  w  w  .j a  v a 2s. c  o m*/
        g.dispose();
        TexturePaint paint = new TexturePaint(back,
                new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
        jxFilterPane.setBackgroundPainter(new MattePainter(paint));
        DefaultListModel model = new DefaultListModel();

        for (int i = 0; i < jConquersTable.getColumnCount(); i++) {
            TableColumnExt col = jConquersTable.getColumnExt(i);
            if (col.isVisible() && !col.getTitle().equals("Entfernung")
                    && !col.getTitle().equals("Dorfpunkte")) {
                model.addElement(col.getTitle());
            }
        }
        jXColumnList.setModel(model);
        jXColumnList.setSelectedIndex(0);
        jxFilterPane.setVisible(true);
    }
}

From source file:displayStructureAsPDFTable.java

public void drawStructure(IAtomContainer mol, int cnt) {

    // do aromaticity detection
    try {//from   w ww.  ja  va2s. c  o m
        CDKHueckelAromaticityDetector.detectAromaticity(mol);
    } catch (CDKException cdke) {
        cdke.printStackTrace();
    }
    mol = addHeteroHydrogens(mol);
    r2dm = new Renderer2DModel();
    renderer = new Renderer2D(r2dm);
    Dimension screenSize = new Dimension(this.width, this.height);
    setPreferredSize(screenSize);
    r2dm.setBackgroundDimension(screenSize); // make sure it is synched with the JPanel size
    setBackground(r2dm.getBackColor());

    try {
        StructureDiagramGenerator sdg = new StructureDiagramGenerator();
        sdg.setMolecule((IMolecule) mol);
        sdg.generateCoordinates();
        this.mol = sdg.getMolecule();

        r2dm.setDrawNumbers(false);
        r2dm.setUseAntiAliasing(true);
        r2dm.setColorAtomsByType(doColor);
        r2dm.setShowAromaticity(true);
        r2dm.setShowAromaticityInCDKStyle(false);
        r2dm.setShowReactionBoxes(false);
        r2dm.setKekuleStructure(false);
        r2dm.setShowExplicitHydrogens(withH);
        r2dm.setShowImplicitHydrogens(true);
        GeometryTools.translateAllPositive(this.mol);
        GeometryTools.scaleMolecule(this.mol, getPreferredSize(), this.scale);
        GeometryTools.center(this.mol, getPreferredSize());
    } catch (Exception exc) {
        exc.printStackTrace();
    }
    this.frame.getContentPane().add(this);
    this.frame.pack();

    String filename;
    if (cnt < 10)
        filename = this.odir + "/img00" + cnt + this.suffix;
    else if (cnt < 100)
        filename = this.odir + "/img0" + cnt + this.suffix;
    else
        filename = this.odir + "/img" + cnt + this.suffix;

    if (oformat.equalsIgnoreCase("png") || oformat.equalsIgnoreCase("jpeg")) {
        BufferedImage img;
        try {
            img = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_RGB);
            //                img = (BufferedImage) createImage(this.getSize().width, this.getSize().height);
            Graphics2D snapGraphics = (Graphics2D) img.getGraphics();
            this.paint(snapGraphics);
            File graphicsFile = new File(filename);
            ImageIO.write(img, oformat, graphicsFile);
        } catch (NullPointerException e) {
            System.out.println(e.toString());
        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }
    } else if (oformat.equalsIgnoreCase("pdf")) {
        File file = new File(filename);
        Rectangle pageSize = new Rectangle(this.getSize().width, this.getSize().height);
        Document document = new Document(pageSize);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
            document.open();
            PdfContentByte cb = writer.getDirectContent();

            Image awtImage = createImage(this.getSize().width, this.getSize().height);
            Graphics snapGraphics = awtImage.getGraphics();
            paint(snapGraphics);

            com.lowagie.text.Image pdfImage = com.lowagie.text.Image.getInstance(awtImage, null);
            pdfImage.setAbsolutePosition(0, 0);
            cb.addImage(pdfImage);

        } catch (DocumentException de) {
            System.err.println(de.getMessage());
        } catch (IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        document.close();
    } else if (oformat.equalsIgnoreCase("svg")) {
        /*
             try {
        SVGWriter cow = new SVGWriter(new FileWriter(filename));
        if (cow != null) {
            cow.writeAtomContainer(mol);
            cow.close();
        }
             } catch (IOException ioe) {
        ioe.printStackTrace();
             } catch (CDKException cdke) {
        cdke.printStackTrace();
             }
        */
    }
}

From source file:au.org.ala.biocache.web.MapController.java

@Deprecated
@RequestMapping(value = "/occurrences/wms", method = RequestMethod.GET)
public void pointsWmsImage(SpatialSearchRequestParams requestParams,
        @RequestParam(value = "colourby", required = false, defaultValue = "0") Integer colourby,
        @RequestParam(value = "width", required = false, defaultValue = "256") Integer widthObj,
        @RequestParam(value = "height", required = false, defaultValue = "256") Integer heightObj,
        @RequestParam(value = "zoom", required = false, defaultValue = "0") Integer zoomLevel,
        @RequestParam(value = "symsize", required = false, defaultValue = "4") Integer symsize,
        @RequestParam(value = "symbol", required = false, defaultValue = "circle") String symbol,
        @RequestParam(value = "bbox", required = false, defaultValue = "110,-45,157,-9") String bboxString,
        @RequestParam(value = "type", required = false, defaultValue = "normal") String type,
        @RequestParam(value = "outline", required = true, defaultValue = "false") boolean outlinePoints,
        @RequestParam(value = "outlineColour", required = true, defaultValue = "0x000000") String outlineColour,
        HttpServletResponse response) throws Exception {

    // size of the circles
    int size = symsize.intValue();
    int width = widthObj.intValue();
    int height = heightObj.intValue();

    requestParams.setStart(0);/*from w w  w.j av  a 2 s  . c  om*/
    requestParams.setPageSize(Integer.MAX_VALUE);
    String query = requestParams.getQ();
    String[] filterQuery = requestParams.getFq();

    if (StringUtils.isBlank(query) && StringUtils.isBlank(requestParams.getFormattedQuery())) {
        displayBlankImage(width, height, false, response);
        return;
    }

    // let's force it to PNG's for now 
    response.setContentType("image/png");

    // Convert array to list so we append more values onto it
    ArrayList<String> fqList = null;
    if (filterQuery != null) {
        fqList = new ArrayList<String>(Arrays.asList(filterQuery));
    } else {
        fqList = new ArrayList<String>();
    }

    // the bounding box
    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(e.getMessage(), e);
        }
    }

    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 * 2);
    double yoffset = (bbox[3] - bbox[1]) / (double) height * (size * 2);

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

    double[] bbox2 = new double[4];
    bbox2[0] = convertMetersToLng(bbox[0] - xoffset);
    bbox2[1] = convertMetersToLat(bbox[1] - yoffset);
    bbox2[2] = convertMetersToLng(bbox[2] + xoffset);
    bbox2[3] = convertMetersToLat(bbox[3] + yoffset);

    bbox[0] = convertMetersToLng(bbox[0]);
    bbox[1] = convertMetersToLat(bbox[1]);
    bbox[2] = convertMetersToLng(bbox[2]);
    bbox[3] = convertMetersToLat(bbox[3]);

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

    String bboxString2 = bbox2[0] + "," + bbox2[1] + "," + bbox2[2] + "," + bbox2[3];
    bboxToQuery(bboxString2, fqList);

    PointType pointType = getPointTypeForZoomLevel(zoomLevel);

    String[] newFilterQuery = (String[]) fqList.toArray(new String[fqList.size()]); // convert back to array

    requestParams.setFq(newFilterQuery);

    List<OccurrencePoint> points = searchDAO.getFacetPoints(requestParams, pointType);
    logger.debug("Points search for " + pointType.getLabel() + " - found: " + points.size());

    if (points.size() == 0) {
        displayBlankImage(width, height, false, response);
        return;
    }

    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = (Graphics2D) img.getGraphics();
    g.setColor(Color.RED);

    int x, y;
    int pointWidth = size * 2;
    double width_mult = (width / (pbbox[2] - pbbox[0]));
    double height_mult = (height / (pbbox[1] - pbbox[3]));

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

    Color oColour = Color.decode(outlineColour);

    for (i = 0; i < points.size(); i++) {
        OccurrencePoint pt = points.get(i);
        float lng = pt.getCoordinates().get(0).floatValue();
        float lat = pt.getCoordinates().get(1).floatValue();

        x = (int) ((convertLngToPixel(lng) - pbbox[0]) * width_mult);
        y = (int) ((convertLatToPixel(lat) - pbbox[3]) * height_mult);

        if (colourby != null) {
            int colour = 0xFF000000 | colourby.intValue();
            Color c = new Color(colour);
            g.setPaint(c);
        } else {
            g.setPaint(Color.blue);
        }

        // g.fillOval(x - (size / 2), y - (size / 2), pointWidth, pointWidth);
        Shape shp = getShape(symbol, x - (size / 2), y - (size / 2), pointWidth, pointWidth);
        g.draw(shp);
        g.fill(shp);
        if (outlinePoints) {
            g.setPaint(oColour);
            g.drawOval(x - (size / 2), y - (size / 2), pointWidth, pointWidth);
        }
    }

    g.dispose();

    try {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(img, "png", outputStream);
        ServletOutputStream outStream = response.getOutputStream();
        outStream.write(outputStream.toByteArray());
        outStream.flush();
        outStream.close();

    } catch (Exception e) {
        logger.error("Unable to write image", e);
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    TroopTableTab activeTab = getActiveTab();
    if (e.getActionCommand().equals("Delete")) {
        if (activeTab != null) {
            activeTab.deleteSelection();
        }/* ww  w. j av a 2  s .c  o  m*/
    } else if (e.getActionCommand().equals("BBCopy")) {
        if (activeTab != null) {
            activeTab.transferSelection(TroopTableTab.TRANSFER_TYPE.CLIPBOARD_BB);
        }
    } else if (e.getActionCommand().equals("Find")) {
        BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
        Graphics g = back.getGraphics();
        g.setColor(new Color(120, 120, 120, 120));
        g.fillRect(0, 0, back.getWidth(), back.getHeight());
        g.setColor(new Color(120, 120, 120));
        g.drawLine(0, 0, 3, 3);
        g.dispose();
        TexturePaint paint = new TexturePaint(back,
                new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
        jxSearchPane.setBackgroundPainter(new MattePainter(paint));
        updateTagList();
        jxSearchPane.setVisible(true);
    } else if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("SelectionDone")) {
            activeTab.updateSelectionInfo();
        }
    }
}

From source file:org.deegree.services.wps.provider.jrxml.contentprovider.map.MapContentProvider.java

private Object prepareMap(List<OrderedDatasource<?>> datasources, String type, int originalWidth,
        int originalHeight, int width, int height, Envelope bbox, int resolution) throws ProcessletException {
    if ("net.sf.jasperreports.engine.JRRenderable".equals(type)) {
        return new MapRenderable(datasources, bbox, resolution);
    } else {/*from  w  ww.  j  ava  2  s. c om*/
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.getGraphics();
        for (OrderedDatasource<?> datasource : datasources) {
            BufferedImage image = datasource.getImage(width, height, bbox);
            if (image != null) {
                g.drawImage(image, 0, 0, null);
            }
        }
        g.dispose();
        return convertImageToReportFormat(type, bi);
    }
}