use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.
the class MapLayoutWidget method setMapCenter.
/**
* Set center of the Map on Italy
*/
public void setMapCenter() {
IGPAccountDetail accountDetail = Registry.get(UserSessionEnum.ACCOUNT_DETAIL_IN_SESSION.name());
GPClientViewport viewport = accountDetail.getViewport();
if (viewport != null) {
ViewportUtility.gotoViewportLocation(map, viewport);
} else {
LonLat center = new LonLat(13.375, 42.329);
if (map.getProjection().equals(GPCoordinateReferenceSystem.GOOGLE_MERCATOR.getCode())) {
center.transform(WGS_84.getCode(), GPCoordinateReferenceSystem.EPSG_GOOGLE.getCode());
}
float zoomLevel = 5;
this.map.setCenter(center, (int) zoomLevel);
}
this.mapControl.clearNavigationHistory();
}
use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.
the class SaveViewportAction method isStoreModelCorrect.
private boolean isStoreModelCorrect() {
boolean check = true;
BBoxClientInfo bbox;
for (GPClientViewport viewport : store.getModels()) {
bbox = viewport.getBbox();
System.out.println("BBOXXX: " + bbox.getLowerLeftX());
if (bbox == null || bbox.getLowerLeftX() == 0.0d || bbox.getLowerLeftY() == 0.0d || bbox.getUpperRightX() == 0.0d || bbox.getUpperRightY() == 0.0d || viewport.getName() == null || viewport.getName().isEmpty() || viewport.getZoomLevel() < 0) {
check = false;
break;
}
}
return check;
}
use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.
the class ViewportGridFieldSet method addComponents.
@Override
public void addComponents() {
store.addStoreListener(new StoreListener<GPClientViewport>() {
@Override
public void storeUpdate(StoreEvent<GPClientViewport> se) {
super.storeUpdate(se);
ViewportGridFieldSet.this.saveButton.enable();
}
});
this.add(createViewportFilter());
this.add(this.generateGrid(), new FormData("100%"));
ButtonBar buttonBar = new ButtonBar();
Button addEntryButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonAddViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
ViewportGridFieldSet.this.store.add(ViewportUtility.generateViewportFromMap(map));
viewportGrid.startEditing(store.getCount() - 1, 1);
ViewportGridFieldSet.this.saveButton.enable();
}
});
buttonBar.add(addEntryButton);
this.deleteViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonDeleteViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.delete()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
if (viewportList != null) {
GeoPlatformMessage.confirmMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportBodyText(), new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
if (Dialog.YES.equals(be.getButtonClicked().getItemId())) {
for (GPClientViewport viewport : viewportList) {
store.remove(viewport);
ViewportGridFieldSet.this.saveButton.enable();
}
}
}
});
}
}
});
deleteViewportButton.setEnabled(Boolean.FALSE);
buttonBar.add(deleteViewportButton);
this.gotoViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonGoToViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.gotoXY()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
if (viewportList != null && viewportList.size() == 1) {
ViewportUtility.gotoViewportLocation(map, viewportList.get(0));
} else {
GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
}
}
});
gotoViewportButton.setEnabled(Boolean.FALSE);
buttonBar.add(gotoViewportButton);
this.setDefaultViewportButton = new Button(ButtonsConstants.INSTANCE.setDefautlText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.select()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
if (viewportList != null && viewportList.size() == 1) {
GPClientViewport selectedViewport = viewportList.get(0);
for (GPClientViewport viewport : ViewportGridFieldSet.this.store.getModels()) {
if (viewport.isDefault()) {
viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.FALSE);
store.update(viewport);
} else if (selectedViewport.equals(viewport)) {
viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.TRUE);
store.update(viewport);
}
}
} else {
GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_setDefaultViewportAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
}
}
});
setDefaultViewportButton.setEnabled(Boolean.FALSE);
buttonBar.add(setDefaultViewportButton);
SaveViewportAction saveViewportAction = new SaveViewportAction(GPTrustedLevel.LOW, this.store);
this.saveButton = new GPSecureButton(ButtonsConstants.INSTANCE.saveText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.save()), saveViewportAction);
buttonBar.add(this.saveButton);
this.add(buttonBar, new FormData("100%"));
}
use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.
the class ViewportWidget method onCreateViewport.
@Override
public void onCreateViewport(List<GPLayerBean> layerList, String viewportName) {
Bounds bounds = ViewportUtility.calculateMaxBound(layerList, map);
Projection currentProjection = new Projection(GPCoordinateReferenceSystem.WGS_84.getCode());
Projection destinationProjection = new Projection(map.getProjection());
bounds.transform(currentProjection, destinationProjection);
double zoom = map.getZoomForExtent(bounds, Boolean.FALSE);
bounds.transform(destinationProjection, currentProjection);
BBoxClientInfo bbox = ViewportUtility.generateBBOXFromBounds(bounds);
this.viewportToAdd = new GPClientViewport(viewportName, MapModuleConstants.INSTANCE.ViewportUtility_newViewportDescriptionText(), bbox, zoom, Boolean.FALSE);
this.show();
}
use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.
the class MapService method convertServerViewportToDTO.
private List<GPClientViewport> convertServerViewportToDTO(Collection<GPViewport> viewportCollection) {
List<GPClientViewport> clientViewportList = Lists.<GPClientViewport>newArrayList();
GPClientViewport clientViewport;
GPBBox serverBBOX;
BBoxClientInfo clientBBOX;
if (viewportCollection != null) {
for (GPViewport viewport : viewportCollection) {
serverBBOX = viewport.getBbox();
clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
clientViewportList.add(clientViewport);
}
}
return clientViewportList;
}
Aggregations