Skip to content

Commit

Permalink
2004-02-09 Pierre-Luc Paour <gallery@paour.com> (1.3-b28)
Browse files Browse the repository at this point in the history
	* Fixed yet another concurrency problem in slideshow, when using
	  both manual and automatic slide changes.
	* Fixed caption not being outlined. Saldy, this means the caption
	  is not HTML capable and single-line only.
  • Loading branch information
Pierre-Luc Paour committed Feb 9, 2004
1 parent efb2005 commit 2385937
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 40 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2004-02-09 Pierre-Luc Paour <gallery@paour.com> (1.3-b28)

* Fixed yet another concurrency problem in slideshow, when using
both manual and automatic slide changes.
* Fixed caption not being outlined. Saldy, this means the caption
is not HTML capable and single-line only.

2004-02-04 Pierre-Luc Paour <gallery@paour.com> (1.3-b27)

* GR now requires Java 1.4 or later, too many things are unsupported
Expand Down
156 changes: 120 additions & 36 deletions com/gallery/GalleryRemote/SlideshowFrame.java
Expand Up @@ -7,11 +7,9 @@

import javax.swing.*;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.event.*;
import java.util.List;
import java.util.ArrayList;
Expand All @@ -28,6 +26,7 @@ public class SlideshowFrame extends PreviewFrame implements Runnable, Preference
public static final String MODULE = "SlideFrame";
List pictures = null;
List wantDownloaded = Collections.synchronizedList(new ArrayList());
Picture userPicture = null;
int sleepTime = 3000;
boolean running = false;
boolean shutdown = false;
Expand Down Expand Up @@ -61,7 +60,7 @@ public void show() {

DialogUtil.maxSize(this);
//setBounds(600, 100, 500, 500);
show();
super.show();
} catch (Throwable e) {
Log.log(Log.LEVEL_TRACE, MODULE, "No full-screen mode: using maximized window");
DialogUtil.maxSize(this);
Expand Down Expand Up @@ -178,6 +177,10 @@ public void keyPressed(KeyEvent e) {
}

private void addComponent(PreviewFrame.ImageContentPane cp, JLabel c, int mod, int value) {
if (value == 0) {
return;
}

int col;
int cons;
switch (value % 10) {
Expand All @@ -204,33 +207,9 @@ private void addComponent(PreviewFrame.ImageContentPane cp, JLabel c, int mod, i
c.setHorizontalAlignment(value % 10);
}

public static class OutlineLabelUI extends BasicLabelUI {
protected static OutlineLabelUI labelUI = new OutlineLabelUI();

public static ComponentUI createUI(JComponent c) {
return labelUI;
}

protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) {
g.setColor(Color.darkGray);
g.drawString(s,textX + 1, textY + 1);
g.drawString(s,textX - 1, textY + 1);
g.drawString(s,textX + 1, textY - 1);
g.drawString(s,textX - 1, textY - 1);
g.setColor(l.getForeground());
g.drawString(s, textX, textY);
}

/*public Dimension getPreferredSize(JComponent c) {
Dimension d = super.getPreferredSize(c);
return new Dimension((int) d.getWidth() + 2, (int) d.getHeight() + 2);
}*/
}

public void start(ArrayList pictures) {
if (GalleryRemote._().properties.getBooleanProperty(SLIDESHOW_RANDOM)) {
this.pictures = (List) pictures.clone();
this.pictures = new ArrayList(pictures);
Collections.shuffle(this.pictures);
} else {
this.pictures = pictures;
Expand All @@ -244,7 +223,7 @@ public void run() {
while (running) {
long time = System.currentTimeMillis();

if (!next()) {
if (!next(false)) {
// the slideshow is over
hide();
break;
Expand All @@ -265,26 +244,26 @@ public void run() {
private void previousAsync() {
new Thread() {
public void run() {
previous();
previous(true);
}
}.start();
}

private void nextAsync() {
new Thread() {
public void run() {
next();
next(true);
}
}.start();
}

public boolean next() {
public boolean next(boolean user) {
int index = -1;

if (loadPicture != null) {
index = pictures.indexOf(loadPicture);

if (wantDownloaded.contains(loadPicture)) {
if (wantDownloaded.contains(loadPicture) && (loadPicture != userPicture || user)) {
// we no longer want the current picture
wantDownloaded.remove(loadPicture);
}
Expand All @@ -300,6 +279,13 @@ public boolean next() {

// display next picture
Picture picture = (Picture) pictures.get(index);
if (user) {
userPicture = picture;
} else if (userPicture != null && userPicture != picture) {
// automatic move tying to move away from user-chosen picture
return true;
}

wantDownloaded.add(picture);
updateProgress(picture);
displayPicture(picture, false);
Expand All @@ -313,12 +299,12 @@ public boolean next() {
return true;
}

public boolean previous() {
public boolean previous(boolean user) {
int index = -1;

if (loadPicture == null) {
return false;
} else if (wantDownloaded.contains(loadPicture)) {
} else if (wantDownloaded.contains(loadPicture) && (loadPicture != userPicture || user)) {
// we no longer want the current picture
wantDownloaded.remove(loadPicture);
}
Expand All @@ -335,6 +321,13 @@ public boolean previous() {

// display previous picture
Picture picture = (Picture) pictures.get(index);
if (user) {
userPicture = picture;
} else if (userPicture != null && userPicture != picture) {
// automatic move tying to move away from user-chosen picture
return true;
}

wantDownloaded.add(picture);
updateProgress(picture);
displayPicture(picture, false);
Expand All @@ -351,13 +344,19 @@ public boolean previous() {
public void imageLoaded(ImageIcon image, Picture picture) {
Log.log(Log.LEVEL_TRACE, MODULE, "Picture " + picture + " finished loading");

if (picture == userPicture) {
userPicture = null;
}

if (picture != loadPicture) {
Log.log(Log.LEVEL_TRACE, MODULE, "We wanted " + loadPicture + ": ignoring");
return;
}

if (picture != null) {
jCaption.setText("<HTML>" + picture.getCaption() + "</HTML>");
// todo: captions are not printed outline because they are HTML and that's a fucking mess
//jCaption.setText("<HTML>" + picture.getCaption() + "</HTML>");
jCaption.setText(picture.getCaption());
updateProgress(picture);
String extraFields = picture.getExtraFieldsString();
if (extraFields != null) {
Expand Down Expand Up @@ -400,4 +399,89 @@ public boolean dataTransferred(int transferred, int overall, double kbPerSecond,

return true;
}

public static class OutlineLabelUI extends BasicLabelUI {
protected static OutlineLabelUI labelUI = new OutlineLabelUI();
private static Rectangle paintIconR = new Rectangle();
private static Rectangle paintTextR = new Rectangle();
private static Rectangle paintViewR = new Rectangle();
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);

public static ComponentUI createUI(JComponent c) {
return labelUI;
}

protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) {
g.setColor(Color.darkGray);
g.drawString(s,textX + 1, textY + 1);
g.drawString(s,textX - 1, textY + 1);
g.drawString(s,textX + 1, textY - 1);
g.drawString(s,textX - 1, textY - 1);
g.setColor(l.getForeground());
g.drawString(s, textX, textY);
}

// todo: captions are not printed outline because they are HTML and that's a fucking mess
/*public void paint(Graphics g, JComponent c) {
JLabel label = (JLabel)c;
String text = label.getText();
Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
if ((icon == null) && (text == null)) {
return;
}
FontMetrics fm = g.getFontMetrics();
Insets insets = c.getInsets(paintViewInsets);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = c.getWidth() - (insets.left + insets.right);
paintViewR.height = c.getHeight() - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
String clippedText =
layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);
if (icon != null) {
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
}
if (text != null) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
Color color = label.getForeground();
label.setForeground(Color.darkGray);
label.setText(label.getText() + " ");
paintTextR.x -= 1;
v.paint(g, paintTextR);
paintTextR.y -= 1;
v.paint(g, paintTextR);
paintTextR.x += 2;
v.paint(g, paintTextR);
paintTextR.y += 2;
v.paint(g, paintTextR);
label.setForeground(Color.white);
label.setText(label.getText() + " ");
paintTextR.x -= 1;
paintTextR.y -= 1;
v.paint(g, paintTextR);
} else {
int textX = paintTextR.x;
int textY = paintTextR.y + fm.getAscent();
if (label.isEnabled()) {
paintEnabledText(label, g, clippedText, textX, textY);
}
else {
paintDisabledText(label, g, clippedText, textX, textY);
}
}
}
}*/
}
}
8 changes: 6 additions & 2 deletions com/gallery/GalleryRemote/model/Picture.java
Expand Up @@ -106,6 +106,10 @@ public Object clone() {

clone.fileSize = fileSize;
clone.escapedCaption = escapedCaption;
clone.indexCache = indexCache;

clone.albumOnServer = albumOnServer;
clone.indexOnServer = indexOnServer;

return clone;
}
Expand Down Expand Up @@ -472,7 +476,7 @@ public String getName() {

public Album getAlbumOnServer() {
if (!online) {
throw new RuntimeException("Can't get dimension for a local file!");
throw new RuntimeException("Can't get Album on server for a local file!");
}

return albumOnServer;
Expand All @@ -484,7 +488,7 @@ public void setAlbumOnServer(Album albumOnServer) {

public int getIndexOnServer() {
if (!online) {
throw new RuntimeException("Can't get dimension for a local file!");
throw new RuntimeException("Can't get Index on server for a local file!");
}

return indexOnServer;
Expand Down
4 changes: 2 additions & 2 deletions defaults.properties
Expand Up @@ -171,6 +171,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p
#
# --- Do not edit below this line ---
#
version=1.3-b27
releaseDate=2004/02/04
version=1.3-b28
releaseDate=2004/02/08
aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by:\n \nPierre-Luc Paour\nAmedeo Paglione\nChris Schwerdt\n \n \nInitial version by Chris Smith\n \n \nContributors:\n \nTim Miller\nDolan Halbrook\nMarkus Cozowicz\nScott Gartner\n \n \nArtwork by Ross A. Reyman\n \n \nBundled software:\n \nImageMagick\nJSX\nJava look and feel Graphics Repository icons\njpegtran, Guido Vollbeding's version\nMetadataExtractor

0 comments on commit 2385937

Please sign in to comment.