minor fixes

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@134980 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-11-28 13:58:23 +00:00
parent aaa5ed3c25
commit c0f2daf232
2 changed files with 26 additions and 52 deletions

View File

@ -2,8 +2,6 @@ package org.gcube.portlets.widgets.imagepreviewerwidget.client;
import org.gcube.portlets.widgets.imagepreviewerwidget.shared.Orientation; import org.gcube.portlets.widgets.imagepreviewerwidget.shared.Orientation;
import com.github.gwtbootstrap.client.ui.Image;
/** /**
* This class allows to build the image to show within the carousel. It contains: * This class allows to build the image to show within the carousel. It contains:
* <ul> * <ul>
@ -35,11 +33,6 @@ public class EnhancedImage {
* The orientation * The orientation
*/ */
private Orientation orientation = Orientation.UNDEFINED; private Orientation orientation = Orientation.UNDEFINED;
/**
* The cached image (once downloaded)
*/
private Image cachedImage;
/** /**
* Build an enhanced image from a url. * Build an enhanced image from a url.
@ -136,14 +129,6 @@ public class EnhancedImage {
this.orientation = orientation; this.orientation = orientation;
} }
public Image getCachedImage() {
return cachedImage;
}
public void setCachedImage(Image cachedImage) {
this.cachedImage = cachedImage;
}
@Override @Override
public String toString() { public String toString() {
return "EnhancedImage [titleToShow=" + titleToShow + ", toolTipToShow=" return "EnhancedImage [titleToShow=" + titleToShow + ", toolTipToShow="

View File

@ -333,53 +333,42 @@ public class Carousel extends Composite{
final EnhancedImage imageToShow = listOfAttachmentsToShow.get(index); final EnhancedImage imageToShow = listOfAttachmentsToShow.get(index);
// check if it was already shown before and cached... final String url = imageToShow.getImageUrl();
if(imageToShow.getCachedImage() != null){
shownImage = imageToShow.getCachedImage(); // when image is downloaded ...
setOrientation(imageToShow, imageToShow.getOrientation()); shownImage.addLoadHandler(new LoadHandler() {
}else{ @Override
public void onLoad(LoadEvent event) {
final String url = imageToShow.getImageUrl(); // call only if undefined
if(imageToShow.getOrientation().equals(Orientation.UNDEFINED)){
// when image is downloaded ... imageServices.getImageOrientation(url, new AsyncCallback<Orientation>() {
shownImage.addLoadHandler(new LoadHandler() {
@Override @Override
public void onLoad(LoadEvent event) { public void onSuccess(Orientation result) {
imageToShow.setOrientation(result);
setOrientation(imageToShow, result);
}
// call only if undefined @Override
if(imageToShow.getOrientation().equals(Orientation.UNDEFINED)){ public void onFailure(Throwable caught) {
imageToShow.setOrientation(Orientation.DO_NOT_ROTATE);
setOrientation(imageToShow, Orientation.DO_NOT_ROTATE);
}
});
imageServices.getImageOrientation(url, new AsyncCallback<Orientation>() { }else{
setOrientation(imageToShow, imageToShow.getOrientation());
@Override
public void onSuccess(Orientation result) {
imageToShow.setOrientation(result);
setOrientation(imageToShow, result);
}
@Override
public void onFailure(Throwable caught) {
imageToShow.setOrientation(Orientation.DO_NOT_ROTATE);
setOrientation(imageToShow, Orientation.DO_NOT_ROTATE);
}
});
}else{
setOrientation(imageToShow, imageToShow.getOrientation());
}
// cache it
imageToShow.setCachedImage(shownImage);
} }
}); }
});
// fetch the image from the url
shownImage.setUrl(url);
// fetch the image from the url
shownImage.setUrl(url);
}
// change image tooltip // change image tooltip
shownImage.setTitle(imageToShow.getToolTipToShow()); shownImage.setTitle(imageToShow.getToolTipToShow());