Fixed strange rotated image behaviour
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@130991 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b25cac6a72
commit
4019447587
|
@ -21,7 +21,7 @@ public class ImagePreviewer implements EntryPoint {
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
|
|
||||||
// decomment for testing purpose
|
// decomment for testing purpose
|
||||||
//test();
|
// test();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class ImagePreviewer implements EntryPoint {
|
||||||
});
|
});
|
||||||
b.setText("Show preview");
|
b.setText("Show preview");
|
||||||
|
|
||||||
c.show();
|
b.click();
|
||||||
|
|
||||||
RootPanel.get("image-previewer-div").add(b);
|
RootPanel.get("image-previewer-div").add(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.google.gwt.event.dom.client.LoadHandler;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
@ -225,10 +226,11 @@ public class Carousel extends Composite{
|
||||||
|
|
||||||
// evaluate prev index
|
// evaluate prev index
|
||||||
currentPreviewPosition =
|
currentPreviewPosition =
|
||||||
currentPreviewPosition == 0 ? listOfAttachmentsToShow.size() - 1 : currentPreviewPosition - 1;
|
currentPreviewPosition == 0 ?
|
||||||
|
listOfAttachmentsToShow.size() - 1 : currentPreviewPosition - 1;
|
||||||
|
|
||||||
// show the image
|
// show the image
|
||||||
showImage(currentPreviewPosition);
|
showImage(currentPreviewPosition);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +245,7 @@ public class Carousel extends Composite{
|
||||||
currentPreviewPosition =
|
currentPreviewPosition =
|
||||||
currentPreviewPosition == listOfAttachmentsToShow.size() -1 ?
|
currentPreviewPosition == listOfAttachmentsToShow.size() -1 ?
|
||||||
0 : currentPreviewPosition + 1;
|
0 : currentPreviewPosition + 1;
|
||||||
|
|
||||||
// show the image
|
// show the image
|
||||||
showImage(currentPreviewPosition);
|
showImage(currentPreviewPosition);
|
||||||
|
|
||||||
|
@ -299,7 +301,6 @@ public class Carousel extends Composite{
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -328,9 +329,7 @@ public class Carousel extends Composite{
|
||||||
*/
|
*/
|
||||||
private void showImage(int index){
|
private void showImage(int index){
|
||||||
|
|
||||||
// show loading image and hide the shown one
|
showLoader();
|
||||||
loadingImage.setVisible(true);
|
|
||||||
shownImage.setVisible(false);
|
|
||||||
|
|
||||||
final EnhancedImage imageToShow = listOfAttachmentsToShow.get(index);
|
final EnhancedImage imageToShow = listOfAttachmentsToShow.get(index);
|
||||||
final String url = imageToShow.getImageUrl();
|
final String url = imageToShow.getImageUrl();
|
||||||
|
@ -347,21 +346,20 @@ public class Carousel extends Composite{
|
||||||
imageServices.getImageOrientation(url, new AsyncCallback<Orientation>() {
|
imageServices.getImageOrientation(url, new AsyncCallback<Orientation>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Orientation result) {
|
public void onSuccess(Orientation result) {
|
||||||
|
imageToShow.setOrientation(result);
|
||||||
setOrientation(imageToShow, result);
|
setOrientation(imageToShow, result);
|
||||||
removeLoader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
imageToShow.setOrientation(Orientation.DO_NOT_ROTATE);
|
||||||
setOrientation(imageToShow, Orientation.DO_NOT_ROTATE);
|
setOrientation(imageToShow, Orientation.DO_NOT_ROTATE);
|
||||||
removeLoader();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
setOrientation(imageToShow, imageToShow.getOrientation());
|
setOrientation(imageToShow, imageToShow.getOrientation());
|
||||||
removeLoader();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -373,8 +371,8 @@ public class Carousel extends Composite{
|
||||||
shownImage.setTitle(imageToShow.getToolTipToShow());
|
shownImage.setTitle(imageToShow.getToolTipToShow());
|
||||||
|
|
||||||
// change the title to the modal
|
// change the title to the modal
|
||||||
String shownTitle = imageToShow.getTitleToShow().length() > 50 ?
|
String shownTitle = imageToShow.getTitleToShow().length() > 80 ?
|
||||||
imageToShow.getTitleToShow().substring(0, 50) + "..." :
|
imageToShow.getTitleToShow().substring(0, 80) + "..." :
|
||||||
imageToShow.getTitleToShow();
|
imageToShow.getTitleToShow();
|
||||||
mainModalPanel.setTitle(shownTitle);
|
mainModalPanel.setTitle(shownTitle);
|
||||||
|
|
||||||
|
@ -386,6 +384,14 @@ public class Carousel extends Composite{
|
||||||
((Element)mainModalPanel.getElement().getChildNodes().getItem(0)).addClassName("modal-header-custom");
|
((Element)mainModalPanel.getElement().getChildNodes().getItem(0)).addClassName("modal-header-custom");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show image loader
|
||||||
|
*/
|
||||||
|
protected void showLoader() {
|
||||||
|
loadingImage.setVisible(true);
|
||||||
|
shownImage.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove image loader
|
* Remove image loader
|
||||||
|
@ -402,11 +408,6 @@ public class Carousel extends Composite{
|
||||||
*/
|
*/
|
||||||
private void setOrientation(EnhancedImage img, Orientation o){
|
private void setOrientation(EnhancedImage img, Orientation o){
|
||||||
|
|
||||||
GWT.log("Rotation is " + o);
|
|
||||||
|
|
||||||
// set to the img
|
|
||||||
img.setOrientation(o);
|
|
||||||
|
|
||||||
// remove all the possible secondary styles..
|
// remove all the possible secondary styles..
|
||||||
shownImage.removeStyleName("rotate-0");
|
shownImage.removeStyleName("rotate-0");
|
||||||
shownImage.removeStyleName("rotate-90");
|
shownImage.removeStyleName("rotate-90");
|
||||||
|
@ -426,7 +427,17 @@ public class Carousel extends Composite{
|
||||||
|
|
||||||
default: shownImage.addStyleName("rotate-0");
|
default: shownImage.addStyleName("rotate-0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// few ms are needed to remove/add the style, after that we remove the loading image
|
||||||
|
Timer t = new Timer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
removeLoader();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
t.schedule(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ImageOrientationServicesImpl extends RemoteServiceServlet implement
|
||||||
logger.debug("Orientation is " + orientation);
|
logger.debug("Orientation is " + orientation);
|
||||||
return mapIntToOrientation(orientation);
|
return mapIntToOrientation(orientation);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Could not get orientation", e);
|
logger.warn("Could not get orientation");
|
||||||
}
|
}
|
||||||
|
|
||||||
// as default
|
// as default
|
||||||
|
|
Loading…
Reference in New Issue