Modified:
trunk/src/wosaic/Controller.java
trunk/src/wosaic/FlickrService.java
trunk/src/wosaic/JAIProcessor.java
trunk/src/wosaic/Sources.java
trunk/src/wosaic/WosaicApplication.java
trunk/src/wosaic/WosaicUI.java
trunk/src/wosaic/ui/MosaicPane.java
trunk/src/wosaic/utilities/Facebook.java
trunk/src/wosaic/utilities/FacebookQuery.java
trunk/src/wosaic/utilities/FileQuery.java
trunk/src/wosaic/utilities/FilesystemPlugin.java
trunk/src/wosaic/utilities/FlickrQuery.java
trunk/src/wosaic/utilities/ImageBuffer.java
trunk/src/wosaic/utilities/ImagePreview.java
trunk/src/wosaic/utilities/Mosaic.java
trunk/src/wosaic/utilities/MosaicEvent.java
trunk/src/wosaic/utilities/Parameters.java
trunk/src/wosaic/utilities/Pixel.java
trunk/src/wosaic/utilities/SaveThread.java
trunk/src/wosaic/utilities/SourcePlugin.java
trunk/src/wosaic/utilities/Status.java
trunk/src/wosaic/utilities/WosaicFilter.java
Log:
Purpose: Cleanup
Mostly add missing Javadoc comments and cleanup some code. Remove a few
unused fields in the JAIProcessor
Modified: trunk/src/wosaic/Controller.java
==============================================================================
--- trunk/src/wosaic/Controller.java (original)
+++ trunk/src/wosaic/Controller.java Wed Sep 3 20:07:16 2008
@@ -32,7 +32,7 @@
protected int imagesReceived;
private final Mosaic mosaic;
-
+
protected static final int THREAD_WAIT_SECS = 3600;
protected Thread mosaicThread;
@@ -62,26 +62,15 @@
* Perhaps we should incorporate these parameters into the Parameters
* utility object.
*
- * @param target
- * total number of flickr images to analyze
- * @param numThrds
- * the number of images per flickrThread to query
- * @param numRows
- * the desired number of rows in the resulting mosaic
- * @param numCols
- * the desired number of cols in the resulting mosaic
- * @param xDim
- * the width of the final mosaic image
- * @param yDim
- * the height of the final mosaic image
- * @param search
- * the Flickr search string
- * @param mImage
- * the filename of the master image
- * @param mos
- * a reference to the mosaic object which will be operated on
- * @param fb
- * a flag that indicates whether or not to use facebook. This
+ * @param p The parameters associated with the mosaic
+ * @param sourcePixel Source image as a Pixel object
+ * @param numCols the desired number of cols in the resulting mosaic
+ * @param xDim the width of the final mosaic image
+ * @param yDim the height of the final mosaic image
+ * @param search the Flickr search string
+ * @param mImage the filename of the master image
+ * @param mos a reference to the mosaic object which will be operated on
+ * @param fb a flag that indicates whether or not to use facebook. This
* should be replaced by a vector indicating which Plugins to
* use, as we incorporate more Plugins.
*/
@@ -116,8 +105,7 @@
* Add a listener that will receive an event when the Mosaic is finished
* processing
*
- * @param l
- * the listener
+ * @param l the listener
*/
public synchronized void addActionListener(final ActionListener l) {
_listeners.add(l);
@@ -135,8 +123,7 @@
/**
* Remove a listener from the action listeners list
*
- * @param l
- * the listener
+ * @param l the listener
*/
public synchronized void removeActionListener(final ActionListener l) {
_listeners.remove(l);
@@ -159,7 +146,7 @@
mosaicThread = new Thread(mProc, "JAIProcessor Worker Thread");
mosaicThread.setPriority(1);
mosaicThread.start();
-
+
// Wait for everything to shutdown
PluginPool.shutdown();
try {
@@ -169,14 +156,14 @@
// Signal to the JAIProcessor that we've finished
mosaicThread.interrupt();
mosaicThread.join();
-
+
} catch (final InterruptedException ex) {
// This means the user hit cancel-- tell everything to shutdown,
// and then wait some more.
ThreadPool.shutdownNow();
mosaicThread.interrupt();
try {
- mosaicThread.join();
+ mosaicThread.join();
} catch (InterruptedException ex2) {
// We should never get here.
System.out.println("Controller was interrupted twice!");
Modified: trunk/src/wosaic/FlickrService.java
==============================================================================
--- trunk/src/wosaic/FlickrService.java (original)
+++ trunk/src/wosaic/FlickrService.java Wed Sep 3 20:07:16 2008
@@ -36,7 +36,6 @@
* through the flickrj API
*
* @author scott
- *
*/
public class FlickrService extends SourcePlugin {
@@ -45,6 +44,10 @@
*/
protected final static int DEFAULT_NUM_PICS = 500;
+ /**
+ * @author swegner Handle the case when the user presses "Cancel" on the
+ * options UI
+ */
class CancelAction extends AbstractAction {
/**
@@ -63,6 +66,9 @@
}
+ /**
+ * @author swegner Handle event when user presses "Ok" on options UI
+ */
class OkAction extends AbstractAction {
/**
@@ -184,16 +190,16 @@
} catch (final ParserConfigurationException ex) {
latestEx = ex;
}
- if (!FlickrService.Connected)
- throw latestEx;
+ if (!FlickrService.Connected) throw latestEx;
}
// Configuration UI Code
- JTextField NumSearchField = null;
- JDialog OptionsDialog = null;
+ private JTextField NumSearchField = null;
+
+ private JDialog OptionsDialog = null;
- JPanel OptionsPane = null;
+ private JPanel OptionsPane = null;
private SearchParameters Params = null;
@@ -202,20 +208,17 @@
/**
* Create a new FlickrService that will make the under-lying connections
to
* the Flickr API. Note that a new FlickrService should be initialized for
- * each new search query.
- *
- * This no-argument constructor essentially replaces our previous
- * constructor, as it's required for the Sources API.
+ * each new search query. This no-argument constructor essentially
replaces
+ * our previous constructor, as it's required for the Sources API.
*
- * @throws FlickrServiceException
+ * @throws FlickrServiceException If the Flickr API encounters an error
*/
public FlickrService() throws FlickrServiceException {
- if (!FlickrService.Connected)
- try {
- FlickrService.Connect();
- } catch (final ParserConfigurationException ex) {
- throw new FlickrServiceException("Cannot connect to Flickr", ex);
- }
+ if (!FlickrService.Connected) try {
+ FlickrService.Connect();
+ } catch (final ParserConfigurationException ex) {
+ throw new FlickrServiceException("Cannot connect to Flickr", ex);
+ }
// Set our parameters
Params = new SearchParameters();
@@ -358,8 +361,7 @@
/**
* Publicly-accessible method to set the string to search for
*
- * @param str
- * string that should be searched.
+ * @param str string that should be searched.
*/
@Override
public void setSearchString(final String str) {
@@ -369,8 +371,7 @@
/**
* Publicly accesible function to set how many images to retrieve.
*
- * @param target
- * The number of images to retrieve.
+ * @param target The number of images to retrieve.
*/
public void setTargetImages(final int target) {
TargetImages = target;
Modified: trunk/src/wosaic/JAIProcessor.java
==============================================================================
--- trunk/src/wosaic/JAIProcessor.java (original)
+++ trunk/src/wosaic/JAIProcessor.java Wed Sep 3 20:07:16 2008
@@ -1,14 +1,11 @@
package wosaic;
/**
- * JAIProcessor.java
- *
- * This file contains the outline for processing images
- * for use in a mosaic.
+ * JAIProcessor.java This file contains the outline for processing images
for
+ * use in a mosaic.
*/
import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
import wosaic.utilities.ImageBuffer;
import wosaic.utilities.Mosaic;
@@ -22,15 +19,7 @@
*/
public class JAIProcessor implements Runnable {
- public static int INFINITY = 255 * 3;
-
- public static int MINUS_INFINITY = -1 - 255 * 3;
-
- public static int SLEEP_TIME = 500;
-
- public static int TOLERANCE = 30;
-
- int[][][] colorMap;
+ private int[][][] colorMap;
/**
* This is the Pixel object for the master image.
@@ -63,16 +52,12 @@
/**
* This constructor should be used by the threaded application.
*
- * @param mPixel
- * the master image
- * @param param
- * mosaic parameters
- * @param buf
- * reference to a shared buffer that contains images to be
+ * @param mPixel the master image
+ * @param param mosaic parameters
+ * @param buf reference to a shared buffer that contains images to be
* processed
- * @param mos
- * @param stat
- * a reference to a shared status object
+ * @param mos The Mosaic object we will be filling
+ * @param stat a reference to a shared status object
*/
public JAIProcessor(final Pixel mPixel, final Parameters param,
final ImageBuffer buf, final Mosaic mos, final Status stat) {
@@ -86,14 +71,11 @@
/**
* Split an image up into segments, and calculate its average color.
*
- * @param numRows
- * @param numCols
- * @param width
- * the width of a segment
- * @param height
- * the height of a segment
- * @param mPixel
- * the source image
+ * @param numRows Number of rows in the mosaic
+ * @param numCols Number of columns in the mosaic
+ * @param width the width of a segment
+ * @param height the height of a segment
+ * @param mPixel the source image
* @return the average colors of each segment
*/
public int[][][] analyzeSegments(final int numRows, final int numCols,
@@ -125,7 +107,7 @@
/ params.resCols, master.height / params.resRows, master);
BufferedImage newImg = null;
- while (sourcesBuffer.size() != 0 || !Thread.interrupted() ) {
+ while (sourcesBuffer.size() != 0 || !Thread.interrupted()) {
try {
newImg = sourcesBuffer.removeFromImageBuffer();
Modified: trunk/src/wosaic/Sources.java
==============================================================================
--- trunk/src/wosaic/Sources.java (original)
+++ trunk/src/wosaic/Sources.java Wed Sep 3 20:07:16 2008
@@ -10,7 +10,6 @@
/**
* @author carl-erik svensson
- *
*/
public class Sources {
@@ -52,8 +51,7 @@
/**
* Initializes the sources list.
*
- * @param statusObject
- * the status object which notifies the user of progress
+ * @param statusObject the status object which notifies the user of
progress
*/
public Sources(final Status statusObject) {
@@ -70,38 +68,35 @@
/**
* Add a source to the pool of enabled sources.
*
- * @param src
- * the SourcePlugin to be added.
+ * @param src the SourcePlugin to be added.
* @return true if successful, false otherwise
*/
public boolean addSource(final Plugin src) {
- if (PluginObjects[src.ordinal()] != null)
- return false;
+ if (PluginObjects[src.ordinal()] != null) return false;
SourcePlugin thePlugin = null;
switch (src) {
- case Facebook:
- thePlugin = new Facebook();
- break;
-
- case Flickr:
- try {
- thePlugin = new FlickrService();
- } catch (final FlickrServiceException e) {
- // TODO: Handle this error gracefully, or at least print
- // something!
- }
- break;
-
- case Filesystem:
- thePlugin = new FilesystemPlugin();
- break;
+ case Facebook:
+ thePlugin = new Facebook();
+ break;
+
+ case Flickr:
+ try {
+ thePlugin = new FlickrService();
+ } catch (final FlickrServiceException e) {
+ // TODO: Handle this error gracefully, or at least print
+ // something!
+ }
+ break;
+
+ case Filesystem:
+ thePlugin = new FilesystemPlugin();
+ break;
}
- if (thePlugin != null)
- thePlugin.setStatusObject(status);
+ if (thePlugin != null) thePlugin.setStatusObject(status);
PluginObjects[src.ordinal()] = thePlugin;
return thePlugin != null;
}
@@ -109,8 +104,7 @@
/**
* Add an enabled source, based on that source's string type.
*
- * @param src
- * the string describing the source
+ * @param src the string describing the source
* @return true when successful, false otherwise
*/
public boolean addSource(final String src) {
@@ -121,8 +115,7 @@
/**
* Returns the corresponding, enabled SourcePlugin of the given name.
*
- * @param s -
- * string of the name of the SourcePlugin
+ * @param s - string of the name of the SourcePlugin
* @return the SourcePlugin of the desired type
*/
public SourcePlugin findType(final String s) {
@@ -158,14 +151,12 @@
public ArrayList<SourcePlugin> getEnabledSources() {
final ArrayList<SourcePlugin> retList = new ArrayList<SourcePlugin>();
for (final SourcePlugin element : PluginObjects)
- if (element != null)
- retList.add(element);
+ if (element != null) retList.add(element);
return retList;
}
/**
- *
* @return a string array containing the names of each enabled source.
*/
public String[] getEnabledSourcesList() {
@@ -179,7 +170,6 @@
}
/**
- *
* @return a string array containing the names of each source.
*/
public String[] getSourcesList() {
@@ -195,8 +185,7 @@
/**
* Checks if a source is in the enabled list.
*
- * @param src
- * the string representation of the source.
+ * @param src the string representation of the source.
* @return true if the source is enabled, false otherwise.
*/
public boolean isEnabled(final String src) {
@@ -207,13 +196,11 @@
/**
* Remove a source from the pool of enabled sources.
*
- * @param src
- * the SourcePlugin to be removed.
+ * @param src the SourcePlugin to be removed.
* @return if the removal was a success.
*/
public boolean removeSource(final Plugin src) {
- if (PluginObjects[src.ordinal()] == null)
- return false;
+ if (PluginObjects[src.ordinal()] == null) return false;
PluginObjects[src.ordinal()] = null;
return true;
@@ -222,8 +209,7 @@
/**
* Remove an enabled source, based on that source's string type.
*
- * @param src
- * the string describing the source
+ * @param src the string describing the source
* @return true when successful, false otherwise
*/
public boolean removeSource(final String src) {
@@ -238,8 +224,7 @@
*/
public boolean usingSearchString() {
for (final Plugin element : Sources.SearchablePlugins)
- if (PluginObjects[element.ordinal()] != null)
- return true;
+ if (PluginObjects[element.ordinal()] != null) return true;
return false;
}
@@ -253,8 +238,7 @@
String err = null;
for (final SourcePlugin element : PluginObjects)
- if (element != null)
- err = element.validateParams();
+ if (element != null) err = element.validateParams();
return err;
}
Modified: trunk/src/wosaic/WosaicApplication.java
==============================================================================
--- trunk/src/wosaic/WosaicApplication.java (original)
+++ trunk/src/wosaic/WosaicApplication.java Wed Sep 3 20:07:16 2008
@@ -19,8 +19,7 @@
* Main entry point for the Wosaic application. Currently, the args
* parameter is ignored.
*
- * @param args
- * Unused.
+ * @param args Unused.
*/
public static void main(final String[] args) {
new WosaicApplication();
Modified: trunk/src/wosaic/WosaicUI.java
==============================================================================
--- trunk/src/wosaic/WosaicUI.java (original)
+++ trunk/src/wosaic/WosaicUI.java Wed Sep 3 20:07:16 2008
@@ -354,8 +354,7 @@
else if (eventSource == ConfigureSourceButton)
ConfigureSelectedSource();
- else if (eventSource == MosaicController)
- GenerationCleanup();
+ else if (eventSource == MosaicController) GenerationCleanup();
}
@@ -383,11 +382,9 @@
/**
* Validates the dimensions. Returns their computed value.
*
- * @param width
- * the ORIGINAL width of the source image
- * @param height
- * the ORIGINAL height of the source image
- * @return
+ * @param width the ORIGINAL width of the source image
+ * @param height the ORIGINAL height of the source image
+ * @return the computed dimension value
*/
public Dimension checkDimensions(final int width, final int height) {
int xDim, yDim;
@@ -453,16 +450,13 @@
// Get selected source
final String selection = (String) EnabledSourcesList.getSelectedValue();
- if (selection == null)
- return;
+ if (selection == null) return;
final SourcePlugin src = PluginSources.findType(selection);
- if (src == null)
- return;
+ if (src == null) return;
final JDialog frame = src.getOptionsDialog();
- if (frame == null)
- return;
+ if (frame == null) return;
frame.setLocationRelativeTo(this);
frame.setVisible(true);
@@ -475,8 +469,7 @@
*/
protected void DisableSelectedSource() {
final String src = (String) EnabledSourcesList.getSelectedValue();
- if (src == null)
- return;
+ if (src == null) return;
if (PluginSources.removeSource(src)) {
final DefaultListModel enabledModel = (DefaultListModel)
EnabledSourcesList
.getModel();
@@ -493,8 +486,7 @@
* radio button that the user has selected. Make the fields for the
selected
* button active, and the others inactive.
*
- * @param selectedButton
- * The user-selected radio button
+ * @param selectedButton The user-selected radio button
*/
private void EnableSelectedDimField(final JRadioButton selectedButton) {
OriginalDimsButton.setSelected(selectedButton == OriginalDimsButton);
@@ -514,8 +506,7 @@
*/
protected void EnableSelectedSource() {
final String src = (String) DisabledSourcesList.getSelectedValue();
- if (src == null)
- return;
+ if (src == null) return;
if (PluginSources.addSource(src)) {
final DefaultListModel enabledModel = (DefaultListModel)
EnabledSourcesList
.getModel();
@@ -535,7 +526,7 @@
ControllerThread = null;
MosaicController = null;
StatusUI.setIndeterminate(false);
- StatusUI.setProgress(0);
+ StatusUI.setProgress(0);
TabbedPane.setEnabledAt(
TabbedPane.indexOfComponent(AdvancedOptionsTab), true);
InputImageText.setEnabled(true);
@@ -553,8 +544,7 @@
* Calculates the parameters (numRows and numCols) for this mosaic. This
is
* based on the resolution field and the original size of the image.
*
- * @param bi
- * the buffered image of the master image
+ * @param bi the buffered image of the master image
* @return an initialized parameters object
*/
protected Parameters GenParams(final BufferedImage bi) {
@@ -895,8 +885,7 @@
GeneratedMosaic.getParams().originalWidth, GeneratedMosaic
.getParams().originalHeight);
- if (d == null)
- return;
+ if (d == null) return;
GeneratedMosaic.setOutputSize(d.width, d.height);
@@ -920,7 +909,7 @@
// Get rid of any references we have from previous generations
CleanSlate();
-
+
// Set the status object
StatusUI.setStatus("Validating Inputs...");
@@ -929,7 +918,7 @@
PluginSources.getEnabledSources());
for (final SourcePlugin source : sources)
source.setSearchString(SearchQueryText.getText());
-
+
// Validate parameters
final String validateResponse = ValidateGenParams();
if (validateResponse != null) {
@@ -980,16 +969,14 @@
*/
protected String ValidateGenParams() {
final File sourceFile = new File(InputImageText.getText());
- if (!sourceFile.canRead())
- return "Please enter a valid source file";
+ if (!sourceFile.canRead()) return "Please enter a valid source file";
try {
SourceImage = ImageIO.read(sourceFile);
} catch (final Exception e) {
SourceImage = null;
}
- if (SourceImage == null)
- return "Please enter a valid source image";
+ if (SourceImage == null) return "Please enter a valid source image";
if (PluginSources.usingSearchString())
if (SearchQueryText.getText().equals(""))
@@ -1001,22 +988,21 @@
} catch (final Exception e) {
return "Please enter a valid resolution";
}
- if (res <= 0)
- return "Please enter a positive resolution";
-
+ if (res <= 0) return "Please enter a positive resolution";
+
String error;
-
- for(int i = 0; i < EnabledSourcesList.getModel().getSize(); i++) {
- final String selection = (String)
EnabledSourcesList.getModel().getElementAt(i);
-
+
+ for (int i = 0; i < EnabledSourcesList.getModel().getSize(); i++) {
+ final String selection = (String) EnabledSourcesList.getModel()
+ .getElementAt(i);
+
if (selection == null)
return "Fatal Error: Enabled Sources List is out of sync!";
final SourcePlugin src = PluginSources.findType(selection);
error = src.validateParams();
-
- if (error != null)
- return error;
+
+ if (error != null) return error;
}
return null;
Modified: trunk/src/wosaic/ui/MosaicPane.java
==============================================================================
--- trunk/src/wosaic/ui/MosaicPane.java (original)
+++ trunk/src/wosaic/ui/MosaicPane.java Wed Sep 3 20:07:16 2008
@@ -69,8 +69,7 @@
/**
* Change the Image that represents this tile
*
- * @param pixel
- * The new Pixel
+ * @param pixel The new Pixel
*/
public void UpdateTilePixel(final Pixel pixel) {
thePixel = pixel;
@@ -105,10 +104,8 @@
/**
* Default constructor.
*
- * @param rows
- * The Mosaic resolution height
- * @param cols
- * The Mosaic resolution width
+ * @param rows The Mosaic resolution height
+ * @param cols The Mosaic resolution width
*/
public MosaicPane(final int rows, final int cols) {
super();
@@ -144,10 +141,8 @@
/**
* Create new tiles for each pixel in the panel
*
- * @param rows
- * number of pixels in each column
- * @param cols
- * number of pixels in each row
+ * @param rows number of pixels in each column
+ * @param cols number of pixels in each row
*/
public void setGrid(final int rows, final int cols) {
if (TileGrid != null) {
@@ -171,12 +166,9 @@
/**
* Update the Image on a specific tile
*
- * @param x
- * The row of the tile to update
- * @param y
- * The column of the tile to update
- * @param pix
- * The new pixel
+ * @param x The row of the tile to update
+ * @param y The column of the tile to update
+ * @param pix The new pixel
*/
public void UpdateTile(final int x, final int y, final Pixel pix) {
TileGrid[x][y].UpdateTilePixel(pix);
Modified: trunk/src/wosaic/utilities/Facebook.java
==============================================================================
--- trunk/src/wosaic/utilities/Facebook.java (original)
+++ trunk/src/wosaic/utilities/Facebook.java Wed Sep 3 20:07:16 2008
@@ -25,7 +25,6 @@
* Utility for interfacing with Facebook
*
* @author carl-erik svensson
- *
*/
public class Facebook extends SourcePlugin {
@@ -66,8 +65,14 @@
private boolean isAuthenticated;
// Config UI Code
+ /**
+ * Options UI for setting preferences
+ */
JDialog OptionsDialog = null;
+ /**
+ * The actual JPanel that will include UI elements
+ */
JPanel OptionsPane = null;
private final JPanel optionsPanel = null;
@@ -91,7 +96,7 @@
* Called from either the Advanced Options or when not authenticated and
* generating a mosaic.
*
- * @throws Exception
+ * @throws Exception If the BrowserLauncher encounters an error
*/
public void authenticate() throws Exception {
// Create an authentication token
@@ -131,7 +136,7 @@
/**
* Downloads the required images from Facebook.
*
- * @throws Exception
+ * @throws Exception If the Facebook client encounters an internal error
*/
/*
* FIXME: We need this because the Facebook client uses an "Integer" type
@@ -148,7 +153,7 @@
final NodeList nl = d.getElementsByTagName("photo");
numResults = nl.getLength();
sourcesBuffer.signalProgressCount(numResults);
-
+
// System.out.println(nl);
int i = 0;
Node photo;
@@ -182,7 +187,6 @@
}
/**
- *
* @return a flag indicating whether or not the user has authenticated
with
* facebook
*/
@@ -235,7 +239,7 @@
/**
* This should be called after the user has logged in.
*
- * @throws Exception
+ * @throws Exception If the Facebook client encounters an internal error
*/
public void verifyAuthentication() throws Exception {
client.auth_getSession(auth);
Modified: trunk/src/wosaic/utilities/FacebookQuery.java
==============================================================================
--- trunk/src/wosaic/utilities/FacebookQuery.java (original)
+++ trunk/src/wosaic/utilities/FacebookQuery.java Wed Sep 3 20:07:16 2008
@@ -23,10 +23,8 @@
/**
* Constructor taking sources buffer and dom node as parameters.
*
- * @param buf
- * the shared buffer instantiated by the controller
- * @param n
- * the DOM node whose value is the desired source URL
+ * @param buf the shared buffer instantiated by the controller
+ * @param n the DOM node whose value is the desired source URL
*/
public FacebookQuery(final ImageBuffer buf, final Node n) {
source = n;
Modified: trunk/src/wosaic/utilities/FileQuery.java
==============================================================================
--- trunk/src/wosaic/utilities/FileQuery.java (original)
+++ trunk/src/wosaic/utilities/FileQuery.java Wed Sep 3 20:07:16 2008
@@ -27,8 +27,7 @@
/**
* Constructor taking sources buffer and dom node as parameters.
*
- * @param F
- * the image file that should read in
+ * @param F the image file that should read in
*/
public FileQuery(final File F) {
file = F;
@@ -40,8 +39,8 @@
* instantiated by the Controller.
*
* @return A scaled representation of the image we were queried on
- * @throws IOException
- * If the File we are called on isn't a support image format
+ * @throws IOException If the File we are called on isn't a support image
+ * format
*/
public BufferedImage call() throws IOException {
Modified: trunk/src/wosaic/utilities/FilesystemPlugin.java
==============================================================================
--- trunk/src/wosaic/utilities/FilesystemPlugin.java (original)
+++ trunk/src/wosaic/utilities/FilesystemPlugin.java Wed Sep 3 20:07:16
2008
@@ -29,7 +29,6 @@
* Utility for interfacing with Facebook
*
* @author carl-erik svensson
- *
*/
public class FilesystemPlugin extends SourcePlugin {
@@ -124,7 +123,6 @@
}
}
-
/**
* The text box where the user can insert the directory to search
*/
@@ -173,8 +171,7 @@
* Spawn the individual FileQueries, and then ping them for results to
* return
*
- * @param F
- * The top directory that we should search
+ * @param F The top directory that we should search
*/
public void getImages(final File F) {
// Create our file filter
@@ -314,12 +311,9 @@
* Spawn a FileQuery for each image file in the directory. This function
* recursively calls itself for each subdirectory it finds
*
- * @param F
- * The directory to look for pictures in
- * @param filter
- * The file filter to weed out non-pictures
- * @param queryResults
- * The ArrayList to add our results to
+ * @param F The directory to look for pictures in
+ * @param filter The file filter to weed out non-pictures
+ * @param queryResults The ArrayList to add our results to
*/
public void spawnQueries(final File F, final FileFilter filter,
final ArrayList<Future<BufferedImage>> queryResults) {
Modified: trunk/src/wosaic/utilities/FlickrQuery.java
==============================================================================
--- trunk/src/wosaic/utilities/FlickrQuery.java (original)
+++ trunk/src/wosaic/utilities/FlickrQuery.java Wed Sep 3 20:07:16 2008
@@ -9,7 +9,6 @@
* sourcesBuffer
*
* @author scott
- *
*/
public class FlickrQuery implements Runnable {
@@ -26,10 +25,8 @@
/**
* Default constructor, create our query
*
- * @param url
- * the URL to look for a picture at
- * @param buffer
- * the buffer to send our results to
+ * @param url the URL to look for a picture at
+ * @param buffer the buffer to send our results to
*/
public FlickrQuery(final String url, final ImageBuffer buffer) {
urlString = url;
Modified: trunk/src/wosaic/utilities/ImageBuffer.java
==============================================================================
--- trunk/src/wosaic/utilities/ImageBuffer.java (original)
+++ trunk/src/wosaic/utilities/ImageBuffer.java Wed Sep 3 20:07:16 2008
@@ -8,7 +8,6 @@
/**
* @author carl-erik svensson
- *
*/
public class ImageBuffer {
@@ -30,12 +29,9 @@
/**
* Default constructor.
*
- * @param sz
- * the maximum number of elements we want to allow in the
buffer
- * @param num
- * the number of sources that feed the buffer
- * @param stat
- * the shared status object used for reporting progress
+ * @param sz the maximum number of elements we want to allow in the buffer
+ * @param num the number of sources that feed the buffer
+ * @param stat the shared status object used for reporting progress
*/
public ImageBuffer(final int sz, final int num, final Status stat) {
sourcesBuffer = new ArrayList<BufferedImage>();
@@ -45,14 +41,13 @@
numSources = num;
statusObject = stat;
statusObject.setIndeterminate(true);
- //statusObject.setProgressLimits(0, maxSize);
+ // statusObject.setProgressLimits(0, maxSize);
}
/**
* Atomically adds an array of image to the shared image buffer
*
- * @param img
- * the ArrayList of images to be added
+ * @param img the ArrayList of images to be added
* @return returns a status indicator
*/
synchronized public boolean addToImageBuffer(
@@ -61,16 +56,15 @@
sourcesBuffer.addAll(img);
currentSize += img.size();
- /*if (currentSize >= maxSize) {
- isComplete = true;
- statusObject.setProgress(maxSize);
- // System.out.println("DBG: Setting progress to max!");
- } else*/
-
- //statusObject.setProgress(currentSize);
+ /*
+ * if (currentSize >= maxSize) { isComplete = true;
+ * statusObject.setProgress(maxSize); //
+ * System.out.println("DBG: Setting progress to max!"); } else
+ */
+
+ // statusObject.setProgress(currentSize);
// System.out.println("DBG: Setting progress bar to have " +
// currentSize + " size");
-
notifyAll();
return true;
}
@@ -83,8 +77,7 @@
/**
* Atomically adds an image to the shared image buffer
*
- * @param img
- * the BufferedImage to be added
+ * @param img the BufferedImage to be added
* @return returns a status indicator
*/
synchronized public boolean addToImageBuffer(final BufferedImage img) {
@@ -92,16 +85,15 @@
sourcesBuffer.add(img);
currentSize++;
- /*if (currentSize >= maxSize) {
- isComplete = true;
- statusObject.setProgress(maxSize);
- // System.out.println("DBG: Setting progress to max!");
- } else*/
-
- //statusObject.setProgress(currentSize);
+ /*
+ * if (currentSize >= maxSize) { isComplete = true;
+ * statusObject.setProgress(maxSize); //
+ * System.out.println("DBG: Setting progress to max!"); } else
+ */
+
+ // statusObject.setProgress(currentSize);
// System.out.println("DBG: Setting progress bar to have " +
// currentSize + " size");
-
notifyAll();
return true;
}
@@ -114,9 +106,8 @@
* Safely remove an element from the shared image buffer.
*
* @return the head element of the buffer
- * @throws InterruptedException
- * if we receive an interrupt while waiting for an image to
- * enter the buffer
+ * @throws InterruptedException if we receive an interrupt while waiting
for
+ * an image to enter the buffer
*/
synchronized public BufferedImage removeFromImageBuffer()
throws InterruptedException {
@@ -139,13 +130,13 @@
// System.out.println("DBG: Setting progress to max!");
}
}
-
+
public synchronized void signalProgressCount(int num) {
progressState++;
maxSize += num;
-
+
if (progressState == numSources) {
- //statusObject.setIndeterminate(false);
+ // statusObject.setIndeterminate(false);
statusObject.setProgressLimits(0, maxSize);
statusObject.setProgress(maxSize);
// System.out.println("DBG: Setting progress to max!");
Modified: trunk/src/wosaic/utilities/ImagePreview.java
==============================================================================
--- trunk/src/wosaic/utilities/ImagePreview.java (original)
+++ trunk/src/wosaic/utilities/ImagePreview.java Wed Sep 3 20:07:16 2008
@@ -1,9 +1,9 @@
//
-// ImagePreview.java
+// ImagePreview.java
//
//
-// Borrowed from Sun tutorial:
-//
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
+// Borrowed from Sun tutorial:
+//
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
package wosaic.utilities;
@@ -20,23 +20,20 @@
/**
* An accessory that can be added to a JFileChooser to display a small
preview
- * of the selected image.
- *
- * Based on ImagePreview.java by FileChooserDemo2.java.
+ * of the selected image. Based on ImagePreview.java by
FileChooserDemo2.java.
*/
public class ImagePreview extends JComponent implements
PropertyChangeListener {
/**
* Generated by Eclipse
*/
private static final long serialVersionUID = -1118759912160048880L;
- File file = null;
- ImageIcon thumbnail = null;
+ private File file = null;
+ private ImageIcon thumbnail = null;
/**
* Default constructor
*
- * @param fc
- * the filechooser we will associate with
+ * @param fc the filechooser we will associate with
*/
public ImagePreview(final JFileChooser fc) {
setPreferredSize(new Dimension(100, 50));
@@ -70,17 +67,14 @@
*/
@Override
protected void paintComponent(final Graphics g) {
- if (thumbnail == null)
- loadImage();
+ if (thumbnail == null) loadImage();
if (thumbnail != null) {
int x = getWidth() / 2 - thumbnail.getIconWidth() / 2;
int y = getHeight() / 2 - thumbnail.getIconHeight() / 2;
- if (y < 0)
- y = 0;
+ if (y < 0) y = 0;
- if (x < 5)
- x = 5;
+ if (x < 5) x = 5;
thumbnail.paintIcon(this, g, x, y);
}
}
Modified: trunk/src/wosaic/utilities/Mosaic.java
==============================================================================
--- trunk/src/wosaic/utilities/Mosaic.java (original)
+++ trunk/src/wosaic/utilities/Mosaic.java Wed Sep 3 20:07:16 2008
@@ -5,7 +5,6 @@
import java.awt.Point;
import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -36,10 +35,8 @@
/**
* Constructor for a mosaic object called by the Controller.
*
- * @param param
- * the set of parameters associated with this mosaic.
- * @param mPixel
- * the master image in Pixel form
+ * @param param the set of parameters associated with this mosaic.
+ * @param mPixel the master image in Pixel form
*/
public Mosaic(final Parameters param, final Pixel mPixel) {
@@ -77,7 +74,8 @@
WritableRaster wr;
try {
- wr = master.getImageRaster().createCompatibleWritableRaster(width,
height);
+ wr = master.getImageRaster().createCompatibleWritableRaster(width,
+ height);
} catch (final Exception e) {
System.out.println(e);
// System.out.println("We're running out of memory!");
@@ -93,7 +91,8 @@
for (int c = 0; c < params.resCols; c++)
try {
// Copy the pixels
- wr.setRect(c * sWidth, r * sHeight,
sources[r][c].getScaledImgRaster(sWidth, sHeight));
+ wr.setRect(c * sWidth, r * sHeight, sources[r][c]
+ .getScaledImgRaster(sWidth, sHeight));
} catch (final Exception e) {
System.out.println(e);
@@ -140,7 +139,7 @@
public synchronized Pixel getPixelAt(final int x, final int y) {
return imageGrid[x][y];
}
-
+
public synchronized int getScoreAt(final int x, final int y) {
return scoreGrid[x][y];
}
@@ -149,10 +148,8 @@
* Initializes a mosaic object. A Mosaic object must be initialized before
* it can be used in computation.
*
- * @param param
- * the set of parameters associated with this mosaic
- * @param mPixel
- * mPixel the master image in Pixel form
+ * @param param the set of parameters associated with this mosaic
+ * @param mPixel mPixel the master image in Pixel form
*/
public void init(final Parameters param, final Pixel mPixel) {
params = param;
@@ -179,8 +176,7 @@
* Remove an object from our list of registered listeners. This assumes
that
* the listener being removed was actually added first.
*
- * @param l
- * the listener to remove
+ * @param l the listener to remove
*/
public synchronized void removeMosaicEventListener(final MosaicListener
l) {
_listeners.remove(l);
@@ -189,13 +185,10 @@
/**
* Writes an image to the specified file.
*
- * @param img
- * the image to be written to disk
- * @param file
- * the filename for the image
- * @param type
- * the encoding for the image
- * @throws IOException
+ * @param img the image to be written to disk
+ * @param file the filename for the image
+ * @param type the encoding for the image
+ * @throws IOException If the file doesn't exist or is not readable
*/
public void save(final BufferedImage img, final String file,
@@ -210,8 +203,8 @@
* Take a total width and height for the new output dimension of the
mosaic,
* and set the parameters object accordingly.
*
- * @param width
- * @param height
+ * @param width The new output width
+ * @param height The new output height
*/
public void setOutputSize(final int width, final int height) {
@@ -221,11 +214,9 @@
/**
* Finds the best spot(s) to put the parameter Pixel object.
*
- * @param srcPixel
- * the pixel to place in the mosaic
- * @param colorMap
- * the 3D array containing color information about the master
- * image
+ * @param srcPixel the pixel to place in the mosaic
+ * @param colorMap the 3D array containing color information about the
+ * master image
*/
public synchronized void updateMosaic(final Pixel srcPixel,
final int[][][] colorMap) {
@@ -264,13 +255,13 @@
updatedCoords.add(new Point(r, c));
}
}
- if (updatedCoords.size() != 0)
- _fire(updatedCoords, srcPixel);
+ if (updatedCoords.size() != 0) _fire(updatedCoords, srcPixel);
notifyAll();
}
-
- public synchronized void UpdatePixel(int row, int col, final Pixel
newPixel, int score) {
+
+ public synchronized void UpdatePixel(int row, int col,
+ final Pixel newPixel, int score) {
imageGrid[row][col] = newPixel;
scoreGrid[row][col] = score;
}
Modified: trunk/src/wosaic/utilities/MosaicEvent.java
==============================================================================
--- trunk/src/wosaic/utilities/MosaicEvent.java (original)
+++ trunk/src/wosaic/utilities/MosaicEvent.java Wed Sep 3 20:07:16 2008
@@ -9,7 +9,6 @@
/**
* @author carl-eriksvensson
- *
*/
public class MosaicEvent extends EventObject {
@@ -31,10 +30,8 @@
/**
* Creates an event that specifies what part of the mosaic was just
updated.
*
- * @param src
- * the object that generated this event
- * @param coords
- * A list of coordinates that were updated
+ * @param src the object that generated this event
+ * @param coords A list of coordinates that were updated
*/
public MosaicEvent(final Object src, final ArrayList<Point> coords,
final Pixel pixel) {
Modified: trunk/src/wosaic/utilities/Parameters.java
==============================================================================
--- trunk/src/wosaic/utilities/Parameters.java (original)
+++ trunk/src/wosaic/utilities/Parameters.java Wed Sep 3 20:07:16 2008
@@ -4,9 +4,7 @@
package wosaic.utilities;
/**
- * @author carl-erik svensson
- *
- * This class is immutable
+ * @author carl-erik svensson This class is immutable
*/
public final class Parameters {
@@ -43,14 +41,10 @@
/**
* Creates a fully initialized parameter set.
*
- * @param rows
- * number of rows of segments in mosaic
- * @param cols
- * number of columns of segments in mosaic
- * @param mW
- * width of the master image
- * @param mH
- * height of the master image
+ * @param rows number of rows of segments in mosaic
+ * @param cols number of columns of segments in mosaic
+ * @param mW width of the master image
+ * @param mH height of the master image
*/
public Parameters(final int rows, final int cols, final int mW, final int
mH) {
resRows = rows;
@@ -84,10 +78,8 @@
* Sets the section width and height based on a target master width and
* height.
*
- * @param mW
- * master width
- * @param mH
- * master height
+ * @param mW master width
+ * @param mH master height
*/
public void setSectionSize(final int mW, final int mH) {
@@ -95,14 +87,12 @@
// Adjust for having a fraction of a pixel in width
sWidth = mW / resCols;
int remainder = mW % resCols;
- if (remainder > 0)
- sWidth++;
+ if (remainder > 0) sWidth++;
// Adjust for having a fraction of a pixel in height
sHeight = mH / resRows;
remainder = mH % resRows;
- if (remainder > 0)
- sHeight++;
+ if (remainder > 0) sHeight++;
}
Modified: trunk/src/wosaic/utilities/Pixel.java
==============================================================================
--- trunk/src/wosaic/utilities/Pixel.java (original)
+++ trunk/src/wosaic/utilities/Pixel.java Wed Sep 3 20:07:16 2008
@@ -1,7 +1,5 @@
/**
- * Pixel.java
- *
- * This provides manipulations at the pixel level.
+ * Pixel.java This provides manipulations at the pixel level.
*/
package wosaic.utilities;
@@ -49,8 +47,7 @@
/**
* Creates a Pixel object from a BufferedImage
*
- * @param img
- * the source image
+ * @param img the source image
*/
public Pixel(final BufferedImage img) {
// source = AWTImageDescriptor.create(img, null);
@@ -78,18 +75,12 @@
/**
* Gets the average color of an area of this Pixel's image.
*
- * @param x
- * starting x position of the area
- * @param y
- * starting y position of the area
- * @param w
- * width of area
- * @param h
- * height of area
- * @param avgVal
- * Optionally pre-allocated array for results. Should have
exact
- * 3 cells.
- *
+ * @param x starting x position of the area
+ * @param y starting y position of the area
+ * @param w width of area
+ * @param h height of area
+ * @param avgVal Optionally pre-allocated array for results. Should have
+ * exact 3 cells.
* @return The average red, green, and blue components, respectively
*/
public int[] getAvgColor(final int x, final int y, final int w,
@@ -133,9 +124,7 @@
* Gets the average color of the entire image. This is an optimized
version
* of getAvgColor. Note that we use some caching for efficiency
*
- * @param arr
- * Optionally pre-allocated array for the results
- *
+ * @param arr Optionally pre-allocated array for the results
* @return A 3-cell int array with the average red, green, and blue
values,
* respectively
*/
@@ -194,8 +183,7 @@
* @return the Raster
*/
public Raster getImageRaster() {
- if (cachedRaster == null)
- cachedRaster = image.getData();
+ if (cachedRaster == null) cachedRaster = image.getData();
return cachedRaster;
}
@@ -204,10 +192,8 @@
* method uses some caching, so multiple calls for the same dimensions
will
* be efficient.
*
- * @param w
- * The width of the scaled instance
- * @param h
- * The height of the scaled instance
+ * @param w The width of the scaled instance
+ * @param h The height of the scaled instance
* @return a new BufferedImage of the requested dimensions
*/
public BufferedImage getScaledImage(final int w, final int h) {
@@ -239,10 +225,8 @@
* uses some caching, so multiple calls for the same dimensions will be
* efficient.
*
- * @param w
- * The width of the scaled instance's raster
- * @param h
- * The height of the scaled instance's raster
+ * @param w The width of the scaled instance's raster
+ * @param h The height of the scaled instance's raster
* @return a new Raster for a scaled image of the requested dimensions
*/
public Raster getScaledImgRaster(final int w, final int h) {
Modified: trunk/src/wosaic/utilities/SaveThread.java
==============================================================================
--- trunk/src/wosaic/utilities/SaveThread.java (original)
+++ trunk/src/wosaic/utilities/SaveThread.java Wed Sep 3 20:07:16 2008
@@ -18,12 +18,9 @@
/**
* Minimal constructor for a save thread.
*
- * @param m
- * the mosaic object to save
- * @param s
- * the status object for reporting errors
- * @param f
- * the file to save to
+ * @param m the mosaic object to save
+ * @param s the status object for reporting errors
+ * @param f the file to save to
*/
public SaveThread(final Mosaic m, final Status s, final File f) {
file = f;
Modified: trunk/src/wosaic/utilities/SourcePlugin.java
==============================================================================
--- trunk/src/wosaic/utilities/SourcePlugin.java (original)
+++ trunk/src/wosaic/utilities/SourcePlugin.java Wed Sep 3 20:07:16 2008
@@ -46,12 +46,10 @@
/**
* Provides an interface for printing status messages.
*
- * @param stat
- * the message to be printed.
+ * @param stat the message to be printed.
*/
public void reportStatus(final String stat) {
- if (statusObject != null)
- statusObject.setStatus(stat);
+ if (statusObject != null) statusObject.setStatus(stat);
}
/**
@@ -64,7 +62,7 @@
/**
* This is required for setting the shared buffer for all the sources.
*
- * @param buf
+ * @param buf The shared image buffer
*/
public void setBuffer(final ImageBuffer buf) {
sourcesBuffer = buf;
@@ -73,8 +71,7 @@
/**
* This is required for setting the shared buffer for all the sources.
*
- * @param tp -
- * a previously instantiated executor service containing
threads
+ * @param tp - a previously instantiated executor service containing
threads
* for use in this source.
*/
public void setPool(final ExecutorService tp) {
@@ -82,14 +79,13 @@
}
public void setSearchString(final String s) {
- // By default, do nothing
+ // By default, do nothing
}
/**
* Defines the how a source can post the status of its running.
*
- * @param obj
- * the shared reference to a Status object
+ * @param obj the shared reference to a Status object
*/
public void setStatusObject(final Status obj) {
statusObject = obj;
@@ -101,6 +97,5 @@
* @return an error message if the parameters aren't valid, or null
*/
abstract public String validateParams();
-
}
Modified: trunk/src/wosaic/utilities/Status.java
==============================================================================
--- trunk/src/wosaic/utilities/Status.java (original)
+++ trunk/src/wosaic/utilities/Status.java Wed Sep 3 20:07:16 2008
@@ -7,7 +7,6 @@
* Defines an object for reporting status information to the user.
*
* @author carl-eriksvensson
- *
*/
public class Status {
@@ -17,10 +16,8 @@
/**
* Initializes the status object with a progress bar and status label.
*
- * @param label
- * label to hold status messages
- * @param bar
- * a reference to the progress bar
+ * @param label label to hold status messages
+ * @param bar a reference to the progress bar
*/
public Status(final JLabel label, final JProgressBar bar) {
statusLabel = label;
@@ -31,8 +28,7 @@
/**
* Initializes the status object with a progress bar.
*
- * @param bar
- * a reference to the progress bar
+ * @param bar a reference to the progress bar
*/
public Status(final JProgressBar bar) {
progressBar = bar;
@@ -42,8 +38,7 @@
/**
* Sets the mode of the progress bar.
*
- * @param ind
- * whether or not the progress bar is in indeterminate mode.
+ * @param ind whether or not the progress bar is in indeterminate mode.
*/
public void setIndeterminate(final boolean ind) {
progressBar.setIndeterminate(ind);
@@ -52,8 +47,7 @@
/**
* Defines a reference to a label on the UI for reporting status messages.
*
- * @param label
- * label to hold status messages
+ * @param label label to hold status messages
*/
public void setLabel(final JLabel label) {
statusLabel = label;
@@ -62,8 +56,7 @@
/**
* Set the amount to display on the progress bar
*
- * @param n
- * amount to set progress to
+ * @param n amount to set progress to
*/
public void setProgress(final int n) {
progressBar.setValue(n);
@@ -72,10 +65,8 @@
/**
* Defines the limits for the progress bar
*
- * @param min
- * minimum value
- * @param max
- * maximum value
+ * @param min minimum value
+ * @param max maximum value
*/
public void setProgressLimits(final int min, final int max) {
progressBar.setMinimum(min);
@@ -85,8 +76,7 @@
/**
* Sets the status message
*
- * @param s
- * the status message
+ * @param s the status message
*/
public void setStatus(final String s) {
statusLabel.setText(s);
Modified: trunk/src/wosaic/utilities/WosaicFilter.java
==============================================================================
--- trunk/src/wosaic/utilities/WosaicFilter.java (original)
+++ trunk/src/wosaic/utilities/WosaicFilter.java Wed Sep 3 20:07:16 2008
@@ -12,7 +12,6 @@
* dialogues in the project.
*
* @author carl-eriksvensson
- *
*/
public class WosaicFilter extends FileFilter implements java.io.FileFilter
{
@@ -34,8 +33,7 @@
/**
* Default constructor allows all filters accepted by ImageIO natively.
*
- * @param dirs
- * Whether or not we should accept directories
+ * @param dirs Whether or not we should accept directories
*/
public WosaicFilter(final boolean dirs) {
filters = new ArrayList<String>();
@@ -50,15 +48,13 @@
*/
@Override
public boolean accept(final File file) {
- if (file.isDirectory())
- return acceptDirs;
+ if (file.isDirectory()) return acceptDirs;
// Find the extension
final String lcasePath = file.getAbsolutePath().toLowerCase();
for (int i = 0; i < filters.size(); i++)
- if (lcasePath.endsWith("." + filters.get(i)))
- return true;
+ if (lcasePath.endsWith("." + filters.get(i))) return true;
return false;
}
@@ -66,8 +62,7 @@
/**
* Add an extension to the list of filters.
*
- * @param filter
- * name of the extension to be added.
+ * @param filter name of the extension to be added.
*/
public void addFilter(final String filter) {
filters.add(filter);
@@ -84,8 +79,7 @@
/**
* Remove a specified type of extension from the file filter.
*
- * @param filter
- * string representation of the extension to be removed.
+ * @param filter string representation of the extension to be removed.
*/
public void removeFilter(final String filter) {
filters.remove(filter);