Example usage for java.awt.geom Rectangle2D.Float setFrameFromDiagonal

List of usage examples for java.awt.geom Rectangle2D.Float setFrameFromDiagonal

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D.Float setFrameFromDiagonal.

Prototype

public void setFrameFromDiagonal(double x1, double y1, double x2, double y2) 

Source Link

Document

Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates.

Usage

From source file:org.gvsig.framework.web.service.impl.OGCInfoServiceImpl.java

/**
 * {@inheritDoc}}// ww w  .j  a va2s  .c  o  m
 */
@Override
public String getFeatureInfoFromWMS(String urlServer, String crs, Vector<String> layers, Vector<String> styles,
        int x, int y, int height, int width, List<String> bounds) {
    String featureInfo = null;

    Float xmin = new Float(Float.parseFloat(bounds.get(0)));
    Float ymin = new Float(Float.parseFloat(bounds.get(1)));
    Float xmax = new Float(Float.parseFloat(bounds.get(2)));
    Float ymax = new Float(Float.parseFloat(bounds.get(3)));

    Rectangle2D.Float extent = new Rectangle2D.Float();
    extent.setFrameFromDiagonal(xmin, ymin, xmax, ymax);

    WMSStatus status = new WMSStatus();
    status.setSrs(crs);
    status.setStyles(styles);
    status.setLayerNames(layers);
    status.setOnlineResource(urlServer);
    status.setExtent(extent);
    status.setHeight(height);
    status.setWidth(width);
    status.setInfoFormat("text/html");
    status.setExceptionFormat("text/plain");

    try {
        WMSClient wms = new WMSClient(urlServer);
        wms.connect(null);

        featureInfo = wms.getFeatureInfo(status, x, y, 0, null);

    } catch (Exception exc) {
        // Show exception in log
        logger.error("Exception on getFeatureInfoFromWMS", exc);
        throw new ServerGeoException();
    }
    return featureInfo;
}