Skip to content

Commit

Permalink
Updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascraigschmidt committed May 13, 2015
1 parent e6b84c3 commit 0499fc1
Show file tree
Hide file tree
Showing 27 changed files with 2,050 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ImageStreamWeb/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 [1.8.0_20]">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/gson-2.3.1.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
36 changes: 36 additions & 0 deletions ImageStreamWeb/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ImageStreamWeb</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions ImageStreamWeb/WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
12 changes: 12 additions & 0 deletions ImageStreamWeb/WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ImageStreamWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
39 changes: 39 additions & 0 deletions ImageStreamWeb/src/example/BufferedImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package example;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
* @class BufferedImage
*
* @brief Encapsulates the Java BufferedImage class via a
* platform-independent interface.
*/
class BufferedImage implements Image {
/**
* A Java BufferedImage object.
*/
public java.awt.image.BufferedImage mBufferedImage;

/**
* Constructor that converts an @a imageData of raw bytes into a
* Java @a BufferedImage.
*/
public BufferedImage(byte[] imageData) {
try {
mBufferedImage = ImageIO.read(new ByteArrayInputStream(imageData));
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* Constructor that stores the @a bufferedInmage parameter into
* the data member.
*/
public BufferedImage (Object bufferedImage) {
mBufferedImage = (java.awt.image.BufferedImage) bufferedImage;
}
}
11 changes: 11 additions & 0 deletions ImageStreamWeb/src/example/Image.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package example;

/**
* @class Image
*
* @brief Defines a platform-independent Image interface, which can be
* implemented for different runtime environments, e.g.,
* Android or plain Java.
*/
interface Image {
}
147 changes: 147 additions & 0 deletions ImageStreamWeb/src/example/ImageEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package example;

import java.net.URL;

import filters.Filter;

/**
* @class ImageEntity
*
* @brief Stores meta-data about an Image and also provides methods
* for common image- and file-related tasks, such as decoding
* raw byte arrays into an Image and setting/getting filter and
* file names.
*/
public class ImageEntity {
/**
* The Image our ImageEntity stores.
*/
private Image mImage;

/**
* The source URL from which the result was downloaded.
*/
protected URL mSourceUrl;

/**
* The name of the filter that was applied to this result.
*/
protected String mFilterName;

/**
* Keeps track of whether operations on this ImageEntity succeed.
*/
protected boolean mSucceeded;

/**
* Construct an ImageEntity from a byte array of @a imageData
* downloaded from a URL @a source.
*/
public ImageEntity(URL sourceURL,
byte[] imageData) {
// Set the URL.
mSourceUrl = sourceURL;

// Initialize other data members.
mFilterName = null;
mSucceeded = true;

// Decode the imageData into a Bitmap.
setImage(imageData);
}

/**
* Construct a new ImageEntity from an @a Image.
*/
public ImageEntity(URL sourceURL,
Image image) {
// Set the URL.
mSourceUrl = sourceURL;

// Initialize other data members.
mFilterName = null;
mSucceeded = true;

// Store the image in the data member.
mImage = image;
}

/**
* Decodes a byte[] into an @a Image that can be used in the rest
* of the application.
*/
public void setImage(byte[] imageData) {
mImage = PlatformStrategy.instance().makeImage(imageData);
}

/**
* Returns the @a Image stored by this ImageEntity.
*/
public Image getImage() {
return mImage;
}

/**
* Modifies the source URL of this result. Necessary for when the
* result is constructed before it is associated with data.
*/
public void setSourceURL(URL url) {
mSourceUrl = url;
}

/**
* Returns the source URL this result was constructed from.
*/
public URL getSourceURL() {
return mSourceUrl;
}

/**
* Sets the name of the filter applied to this result.
*/
public void setFilterName(Filter filter) {
mFilterName = filter.getName();
}

/**
* Returns the name of the filter applied to this result.
*/
public String getFilterName() {
return mFilterName;
}

/**
* Sets whether operations on the ImageEntity succeeded or failed.
*/
public void setSucceeded(boolean succeeded) {
mSucceeded = succeeded;
}

/**
* Returns true if operations on the ImageEntity succeeded, else
* false.
*/
public boolean getSucceeded() {
return mSucceeded;
}

/**
* Returns the file name from the URL this ImageEntity was
* constructed from.
*/
public String getFileName() {
return mSourceUrl.getFile().substring
(mSourceUrl.getFile().lastIndexOf('/'));
}

/**
* Returns the format of the image from the URL in string form.
*/
public String getFormatName() {
String format =
mSourceUrl.getFile().substring
(mSourceUrl.getFile().lastIndexOf('.') + 1);
format = format.equalsIgnoreCase("jpeg") ? "jpg" : format;
return format;
}
}
Loading

0 comments on commit 0499fc1

Please sign in to comment.