Skip to content

Commit

Permalink
Enhanced progress bar, more enhancements to come.
Browse files Browse the repository at this point in the history
Added support for Acme.JPM for scaling of images. This will be rolled back because it doesn't offer any advantages.
  • Loading branch information
Pierre-Luc Paour committed Sep 1, 2002
1 parent bd571b6 commit dfa22a3
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions com/gallery/GalleryRemote/ThumbnailCache.java
Expand Up @@ -25,6 +25,9 @@
import java.awt.*;
import javax.swing.*;

import Acme.JPM.*;
import Acme.JPM.Filters.*;

import com.gallery.GalleryRemote.model.*;

/**
Expand Down Expand Up @@ -59,7 +62,7 @@ public ThumbnailCache( MainFrame mf ) {
*/
public void run() {
int loaded = 0;
mf.startProgress(0, toLoad.size(), "Loading thumbnails");
int pId = mf.startProgress(0, toLoad.size(), "Loading thumbnails");
//Log.log(Log.TRACE, MODULE, "Starting " + iFilename);
while ( !toLoad.isEmpty() ) {
String filename = (String) toLoad.pop();
Expand All @@ -68,13 +71,13 @@ public void run() {
loadThumbnail( filename );

loaded++;
mf.updateProgressValue(loaded, loaded + toLoad.size());
mf.updateProgressValue(pId, loaded, loaded + toLoad.size());
mf.thumbnailLoadedNotify();
}
}
stillRunning = false;

mf.stopProgress("Thumbnails loaded");
mf.stopProgress(pId, "Thumbnails loaded");

//Log.log(Log.TRACE, MODULE, "Ending");
}
Expand Down Expand Up @@ -161,19 +164,38 @@ void cancelLoad() {
*@return Resized icon
*/
public ImageIcon loadThumbnail( String filename ) {
ImageIcon r = new ImageIcon( filename );
Dimension d = PreviewFrame.getSizeKeepRatio( new Dimension( r.getIconWidth(), r.getIconHeight() ), GalleryRemote.getInstance().properties.getThumbnailSize() );

ImageIcon r = null;
long start = System.currentTimeMillis();
Image scaled = r.getImage().getScaledInstance( d.width, d.height, mf.highQualityThumbnails ? Image.SCALE_SMOOTH : Image.SCALE_FAST );

r = new ImageIcon( filename );

Image scaled = null;
if (true)
{
Dimension d = PreviewFrame.getSizeKeepRatio(
new Dimension( r.getIconWidth(), r.getIconHeight() ),
GalleryRemote.getInstance().properties.getThumbnailSize() );
scaled = r.getImage().getScaledInstance( d.width, d.height, mf.highQualityThumbnails ? Image.SCALE_SMOOTH : Image.SCALE_FAST );
} else {
float ratio = PreviewFrame.getRatio(
new Dimension( r.getIconWidth(), r.getIconHeight() ),
GalleryRemote.getInstance().properties.getThumbnailSize() );
scaled = JPMUtils.filterImage(mf, new ScaleCopy(r.getImage().getSource(), ratio));
}

r.getImage().flush();
r.setImage( scaled );

thumbnails.put( filename, r );
Log.log(Log.TRACE, MODULE, "Time: " + ( System.currentTimeMillis() - start ) );
long time = System.currentTimeMillis() - start;
totalTime += time;
totalIter++;
Log.log(Log.TRACE, MODULE, "Time: " + time + " - Avg: " + (totalTime/totalIter) );

return r;
}
long totalTime = 0;
int totalIter = 0;


/**
Expand Down

0 comments on commit dfa22a3

Please sign in to comment.