@@ -0,0 +1,2134 @@
+/*%0A * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.%0A *%0A * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.%0A *%0A * The program is available in open source according to the GNU Affero%0A * General Public License. All contributions in this program are covered%0A * by the Geomajas Contributors License Agreement. For full licensing%0A * details, see LICENSE.txt in the project root.%0A */%0Apackage org.geomajas.plugin.editing.jsapi.example.server.command;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.geomajas.command.Command;%0Aimport org.geomajas.geometry.Coordinate;%0Aimport org.geomajas.geometry.Geometry;%0Aimport org.geomajas.global.ExceptionCode;%0Aimport org.geomajas.global.GeomajasException;%0Aimport org.geomajas.plugin.editing.jsapi.example.dto.GetCentroidRequest;%0Aimport org.geomajas.plugin.editing.jsapi.example.dto.GetCentroidResponse;%0Aimport org.geomajas.service.DtoConverterService;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport com.vividsolutions.jts.geom.Point;%0A%0A/**%0A * %3Cp%3E%0A * This command calculates the centroid of the given geometries.%0A * %3C/p%3E%0A * %0A * @author Pieter De Graef%0A */%0A@Component%0Apublic class GetCentroidCommand implements Command%3CGetCentroidRequest, GetCentroidResponse%3E %7B%0A%0A%09@Autowired%0A%09private DtoConverterService converter;%0A%0A%09public GetCentroidResponse getEmptyCommandResponse() %7B%0A%09%09return new GetCentroidResponse();%0A%09%7D%0A%0A%09public void execute(GetCentroidRequest request, GetCentroidResponse response) throws Exception %7B%0A%09%09if (request.getGeometries() == null %7C%7C request.getGeometries().size() == 0) %7B%0A%09%09%09throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, %22request%22);%0A%09%09%7D%0A%0A%09%09Map%3CGeometry, Coordinate%3E centroids = new HashMap%3CGeometry, Coordinate%3E(request.getGeometries().size());%0A%09%09for (Geometry geometry : request.getGeometries()) %7B%0A%09%09%09com.vividsolutions.jts.geom.Geometry jtsGeom = converter.toInternal(geometry);%0A%09%09%09Point centroid = jtsGeom.getCentroid();%0A%09%09%09centroids.put(geometry, new Coordinate(centroid.getX(), centroid.getY()));%0A%09%09%7D%0A%0A%09%09response.setCentroids(centroids);%0A%09%7D%0A%7D

Create a showcase application that demonstrates the JavaScript API of the editing plugin.