private CopyCoordinatesPanel createCopyCoordinatesPanel( MapTool<?> mapTool, MapModel mapModel, Container container) { CopyCoordinatesPanel copyCoordinatesPanel = new CopyCoordinatesPanel(mapTool, container); int width = mapModel.getTargetDevice().getPixelWidth(); int height = mapModel.getTargetDevice().getPixelHeight(); copyCoordinatesPanel.setBounds(0, 0, width, height); copyCoordinatesPanel.setBackground(new Color(255, 255, 255, 0)); copyCoordinatesPanel.setVisible(true); return copyCoordinatesPanel; }
/* * (non-Javadoc) * * @see org.deegree.igeo.modules.remotecontrol.RequestHandler#perform(java.util.Map, * org.deegree.igeo.ApplicationContainer) */ public String perform(Map<String, String> paramater, ApplicationContainer<?> appContainer) throws ModuleException { String tmp = paramater.get("OBJECTIDS"); if (tmp == null || tmp.length() == 0) { throw new ModuleException(Messages.get("$DG10091")); } List<String> objIds = StringTools.toList(tmp, ",;", true); tmp = paramater.get("LAYER"); if (tmp == null) { throw new ModuleException(Messages.get("$DG10092")); } MapModel mapModel = appContainer.getMapModel(null); LocalMapModelVisitor mv = new LocalMapModelVisitor(tmp); try { mapModel.walkLayerTree(mv); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } Layer layer = mv.getResult(); if (layer == null) { throw new ModuleException(Messages.get("$DG10093", tmp)); } layer.setVisible(true); // first select features in layer List<Identifier> ids = new ArrayList<Identifier>(); for (String id : objIds) { ids.add(new Identifier(id)); } SelectFeatureCommand cmd = new SelectFeatureCommand(layer, ids, false); try { appContainer.getCommandProcessor().executeSychronously(cmd, true); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } // get selected features as FeatureCollection and so their common bounding box FeatureCollection fc = layer.getSelectedFeatures(); if (fc.size() == 0) { throw new ModuleException(Messages.get("$DG10094", paramater.get("OBJECTIDS"))); } Envelope env = null; try { env = fc.getBoundedBy(); if (env.getWidth() < 0.0001) { // feature collection just contains one point; set fix bbox width/height // 25 map units env = env.getBuffer(25); } } catch (GeometryException e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } // zoom to common bounding box of selected features ZoomCommand zcmd = new ZoomCommand(mapModel); zcmd.setZoomBox( env, mapModel.getTargetDevice().getPixelWidth(), mapModel.getTargetDevice().getPixelHeight()); if ("TRUE".equalsIgnoreCase(paramater.get("sync"))) { try { appContainer.getCommandProcessor().executeSychronously(zcmd, true); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } } else { appContainer.getCommandProcessor().executeASychronously(zcmd); } return "feature selected"; }