diff --git a/.settings/com.google.appengine.eclipse.core.prefs b/.settings/com.google.appengine.eclipse.core.prefs new file mode 100644 index 0000000..82c36af --- /dev/null +++ b/.settings/com.google.appengine.eclipse.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +filesCopiedToWebInfLib= diff --git a/src/net/molez/mandlm/fotostream/FotoStream.gwt.xml b/src/net/molez/mandlm/fotostream/FotoStream.gwt.xml index 2fa540a..b61e79e 100644 --- a/src/net/molez/mandlm/fotostream/FotoStream.gwt.xml +++ b/src/net/molez/mandlm/fotostream/FotoStream.gwt.xml @@ -12,7 +12,7 @@ - + diff --git a/src/net/molez/mandlm/fotostream/client/FotoStream.java b/src/net/molez/mandlm/fotostream/client/FotoStream.java index 6aa59cd..45cd3a5 100644 --- a/src/net/molez/mandlm/fotostream/client/FotoStream.java +++ b/src/net/molez/mandlm/fotostream/client/FotoStream.java @@ -7,9 +7,7 @@ import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.Image; -import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; public class FotoStream implements EntryPoint @@ -18,10 +16,6 @@ public class FotoStream implements EntryPoint public void onModuleLoad() { - final Label label = new Label(); - RootPanel.get("textContainer").add(label); - - final Image image = new Image(); image.setVisible(false); image.addLoadHandler(new LoadHandler() @@ -29,27 +23,24 @@ public class FotoStream implements EntryPoint @Override public void onLoad(LoadEvent event) { - int clientHeight = Window.getClientHeight(); int clientWidth = Window.getClientWidth(); - - int imageHeight = image.getHeight(); - int imageWidth = image.getWidth(); - - double heightScale = (double)clientHeight / (double)imageHeight; - double widthScale = (double)clientWidth / (double)imageWidth; - - double scale = Math.min(heightScale, widthScale); + int clientHeight = Window.getClientHeight(); - int targetWidth = (int) (scale * (double)imageWidth); - int targetHeight = (int) (scale * (double)imageHeight); + double clientAspect = (double)clientWidth / (double)clientHeight; - label.setText( - "Client: " + clientWidth + "x" + clientHeight + " " + - "Image: " + imageWidth + "x" + imageHeight + " " + - "Target: " + targetWidth + "x" + targetHeight); + int imageWidth = image.getOffsetWidth(); + int imageHeight = image.getOffsetHeight(); + double imageAspect = (double)imageWidth / (double)imageHeight; + + int widthScalePercent = 100; + if (imageAspect > 0 && clientAspect > 0 && imageAspect < clientAspect) + { + widthScalePercent = (int)(((double)imageAspect / (double)clientAspect) * 100.0); + } + image.setVisible(true); - image.setWidth("50%"); + image.setWidth(widthScalePercent + "%"); } }); @@ -63,11 +54,7 @@ public class FotoStream implements EntryPoint @Override public void onFailure(Throwable caught) { - DialogBox errorMsg = new DialogBox(); - - errorMsg.setTitle("Error loading image"); - errorMsg.setHTML(caught.getMessage()); - errorMsg.show(); + image.setUrl("img/no_image.png"); } @Override diff --git a/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java b/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java index eb06a90..db85f5a 100644 --- a/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java +++ b/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java @@ -50,6 +50,11 @@ public class CurrentImageURLServiceImpl extends RemoteServiceServlet implements readImageFiles(); + if (imageFiles.isEmpty()) + { + return "img/no_image.png"; + } + File latestFile = imageFiles.get(imageFiles.size() - 1); Date latestFileDate = new Date(latestFile.lastModified()); diff --git a/war/FotoStream.css b/war/FotoStream.css index 092d347..0e85f4a 100644 --- a/war/FotoStream.css +++ b/war/FotoStream.css @@ -1,7 +1,16 @@ +body +{ + margin: 0; + padding: 0; + background-color: black; + overflow: hidden; +} + div { - padding: 20px; + margin: 0; + padding: 10px; background-color: black; color: green; } \ No newline at end of file diff --git a/war/FotoStream.html b/war/FotoStream.html index f063b66..49c6e2c 100644 --- a/war/FotoStream.html +++ b/war/FotoStream.html @@ -23,7 +23,7 @@ - + @@ -40,7 +40,6 @@ -
-
+
diff --git a/war/img/no_image.png b/war/img/no_image.png new file mode 100644 index 0000000..c812cc8 Binary files /dev/null and b/war/img/no_image.png differ