Skip to content

Commit

Permalink
2007-06-01 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b32)
Browse files Browse the repository at this point in the history
	* Fixed detection of ImageMagick and jpegtran when running
	  from a stripped Jar.
	* Removed enabling beta support for OpenGL when starting GR,
	  it was causing some video drivers to crash.
	* Fixed URL to Codex when IM or jpegtran is missing.
	* Added signature for some of the Jars so they can be started
	  by WebStart and still have full permissions.
	* Added ability to pre-set Gallery to a specific URL by passing
	  the command-line parameters -url <url> and -username <username>.
	* Added support for golden section (in addition to rule of thirds)
	  for cropping.
	* Fixed slideshow issue when transitions are disabled (the wrong
	  image would be shown).
  • Loading branch information
Pierre-Luc Paour committed Jun 1, 2007
1 parent c8a95af commit 83df704
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 79 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
@@ -1,3 +1,19 @@
2007-06-01 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b32)

* Fixed detection of ImageMagick and jpegtran when running
from a stripped Jar.
* Removed enabling beta support for OpenGL when starting GR,
it was causing some video drivers to crash.
* Fixed URL to Codex when IM or jpegtran is missing.
* Added signature for some of the Jars so they can be started
by WebStart and still have full permissions.
* Added ability to pre-set Gallery to a specific URL by passing
the command-line parameters -url <url> and -username <username>.
* Added support for golden section (in addition to rule of thirds)
for cropping.
* Fixed slideshow issue when transitions are disabled (the wrong
image would be shown).

2007-02-14 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b31)

* Fixed missing string for slideshow preferences.
Expand Down
4 changes: 4 additions & 0 deletions build.xml
Expand Up @@ -73,6 +73,8 @@
<attribute name="Class-Path" value="lib/metadata-extractor-2.1.jar img/" />
</manifest>
</jar>

<signjar jar="GalleryRemote.jar" alias="gallery" storepass="gallery" />
</target>

<!--target name="applet_jar" depends="clean,compile,mac_img_jar" description="create a jar for the applet version of GR"-->
Expand Down Expand Up @@ -178,10 +180,12 @@

<jar destfile="img.jar">
<fileset dir="${img}"/>
<fileset dir="." includes="rar_about_gr1.png"/>
</jar>

<!--delete file="${img}/im.properties"/>
<delete file="${img}/jpegtran.properties"/-->
<signjar jar="img.jar" alias="gallery" storepass="gallery" />
</target>

<target name="applet_img_jar"
Expand Down
63 changes: 60 additions & 3 deletions com/gallery/GalleryRemote/GalleryRemote.java
Expand Up @@ -23,20 +23,23 @@
import com.gallery.GalleryRemote.prefs.GalleryProperties;
import com.gallery.GalleryRemote.prefs.PropertiesFile;
import com.gallery.GalleryRemote.prefs.PreferenceNames;
import com.gallery.GalleryRemote.model.Gallery;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.applet.Applet;
import java.util.Enumeration;
import java.util.Arrays;
import java.util.Iterator;

/**
* Main class and entry point of Gallery Remote
*
* @author paour
*/
public abstract class GalleryRemote {
public abstract class GalleryRemote implements PreferenceNames {
public static final String MODULE = "GalRem";

private static GalleryRemote singleton = null;
Expand Down Expand Up @@ -185,6 +188,59 @@ public static void main(String[] args) {
createInstance("com.gallery.GalleryRemote.GalleryRemoteMainFrame", null);

_().initializeGR();

// Analyze command-line
String url = null;
String username = null;

Iterator i = Arrays.asList(args).iterator();
while (i.hasNext()) {
String sw = (String) i.next();

if (sw.equals("-url") && i.hasNext()) {
url = (String) i.next();
Log.log(Log.LEVEL_TRACE, MODULE, "Command-line switch: url=" + url);
} else if (sw.equals("-username") && i.hasNext()) {
username = (String) i.next();
Log.log(Log.LEVEL_TRACE, MODULE, "Command-line switch: username=" + username);
}
}

if (url != null) {
// we got a URL on the command-line
int j = 0;
boolean found = false;
while (_().properties.containsKey(GURL + j)) {
if (_().properties.getProperty(GURL + j).equals(url)
&& _().properties.getProperty(USERNAME + j).equals(username)) {
// we have probably already loaded and saved thus URL, nothing to do
found = true;
break;
}

j++;
}

if (!found) {
// add it
_().properties.setProperty(GURL + j, url);

if (username != null) {
_().properties.setProperty(USERNAME + j, username);
}

try {
Gallery g = Gallery.readFromProperties(_().properties, j, _().getCore().getMainStatusUpdate());
if (g != null) {
_().getCore().getGalleries().addElement(g);
}
} catch (Exception e) {
Log.log(Log.LEVEL_ERROR, MODULE, "Error trying to load Gallery profile " + i);
Log.logException(Log.LEVEL_ERROR, MODULE, e);
}
}
}

_().runGR();
}

Expand All @@ -201,14 +257,15 @@ public static void setStaticProperties() {
// todo: this should not remain this way
//System.setProperty("apple.awt.fakefullscreen", "true");

try {
// this isn't such a good idea, it crashes with some NVidia drivers
/*try {
if (Float.parseFloat(System.getProperty("java.specification.version")) >= 1.6) {
System.setProperty("sun.java2d.opengl", "true");
}
} catch (RuntimeException e) {
Log.log(Log.LEVEL_ERROR, "Couldn't get property java.specification.version: " +
System.getProperty("java.specification.version"));
}
}*/
}

public void createProperties() {
Expand Down
2 changes: 1 addition & 1 deletion com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -1334,7 +1334,7 @@ public void actionPerformed(ActionEvent e) {
// so ask the user if it's OK to log out.
if (JOptionPane.showConfirmDialog(
(JFrame) this,
GRI18n.getString(MODULE, "logoutQuestion"),
GRI18n.getString(MODULE, "logoutQuestion", new Object[] {getCurrentGallery()}),
"Warning",
JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
return;
Expand Down
61 changes: 30 additions & 31 deletions com/gallery/GalleryRemote/PreviewFrame.java
Expand Up @@ -196,17 +196,8 @@ public void paint(Graphics g) {
g.setColor(Color.black);
g.drawRect(cacheRect.x, cacheRect.y, cacheRect.width, cacheRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.setColor(background);
g.drawLine(cacheRect.x + cacheRect.width / 3, cacheRect.y,
cacheRect.x + cacheRect.width / 3, cacheRect.y + cacheRect.height);
g.drawLine(cacheRect.x + cacheRect.width *2 / 3, cacheRect.y,
cacheRect.x + cacheRect.width * 2 / 3, cacheRect.y + cacheRect.height);
g.drawLine(cacheRect.x, cacheRect.y + cacheRect.height / 3,
cacheRect.x + cacheRect.width, cacheRect.y + cacheRect.height / 3);
g.drawLine(cacheRect.x, cacheRect.y + cacheRect.height * 2 / 3,
cacheRect.x + cacheRect.width, cacheRect.y + cacheRect.height * 2 / 3);
}
g.setColor(background);
drawThirds(g, cacheRect);

g.setClip(null);
} catch (NoninvertibleTransformException e) {
Expand Down Expand Up @@ -254,33 +245,41 @@ public void updateRect() {
g.setXORMode(Color.cyan);
g.drawRect(oldRect.x, oldRect.y, oldRect.width, oldRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.drawLine(oldRect.x + oldRect.width / 3, oldRect.y,
oldRect.x + oldRect.width / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x + oldRect.width *2 / 3, oldRect.y,
oldRect.x + oldRect.width * 2 / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x, oldRect.y + oldRect.height / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height / 3);
g.drawLine(oldRect.x, oldRect.y + oldRect.height * 2 / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height * 2 / 3);
}
drawThirds(g, oldRect);
}

if (inDrag) {
g.setXORMode(Color.cyan);
oldRect = getRect(start, end);
g.drawRect(oldRect.x, oldRect.y, oldRect.width, oldRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.drawLine(oldRect.x + oldRect.width / 3, oldRect.y,
oldRect.x + oldRect.width / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x + oldRect.width *2 / 3, oldRect.y,
oldRect.x + oldRect.width * 2 / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x, oldRect.y + oldRect.height / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height / 3);
g.drawLine(oldRect.x, oldRect.y + oldRect.height * 2 / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height * 2 / 3);
}
drawThirds(g, oldRect);
}
}

private void drawThirds(Graphics g, Rectangle r) {
if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)
|| "thirds".equals(GalleryRemote._().properties.getProperty(PREVIEW_DRAW_THIRDS))) {
g.drawLine(r.x + r.width / 3, r.y,
r.x + r.width / 3, r.y + r.height);
g.drawLine(r.x + r.width * 2 / 3, r.y,
r.x + r.width * 2 / 3, r.y + r.height);
g.drawLine(r.x, r.y + r.height / 3,
r.x + r.width, r.y + r.height / 3);
g.drawLine(r.x, r.y + r.height * 2 / 3,
r.x + r.width, r.y + r.height * 2 / 3);
} else if ("golden".equals(GalleryRemote._().properties.getProperty(PREVIEW_DRAW_THIRDS))) {
double p = 1.6180339887499;
double gw = r.width * p / (2 * p + 1);
double gh = r.height * p / (2 * p + 1);
g.drawLine((int) (oldRect.x + gw), oldRect.y,
(int) (oldRect.x + gw), oldRect.y + oldRect.height);
g.drawLine((int) (oldRect.x + oldRect.width - gw), oldRect.y,
(int) (oldRect.x + oldRect.width - gw), oldRect.y + oldRect.height);
g.drawLine(oldRect.x, (int) (oldRect.y + gh),
oldRect.x + oldRect.width, (int) (oldRect.y + gh));
g.drawLine(oldRect.x, (int) (oldRect.y + oldRect.height - gh),
oldRect.x + oldRect.width, (int) (oldRect.y + oldRect.height -gh));
}
}

Expand Down
8 changes: 7 additions & 1 deletion com/gallery/GalleryRemote/SlideshowFrame.java
Expand Up @@ -612,13 +612,15 @@ public void initTransitionDuration() {
Log.log(Log.LEVEL_TRACE, MODULE, "Is graphics accelerated: " + accelerated);

enableTransitions = accelerated
|| GalleryRemote._().properties.getBooleanProperty(UNACCELERATED_TRANSITION, false);
|| GalleryRemote._().properties.getBooleanProperty(ALLOW_UNACCELERATED_TRANSITION, false);
transitionDuration = enableTransitions?
GalleryRemote._().properties.getIntProperty(SLIDESHOW_TRANSITION_DURATION, 3000):0;

if (transitionDuration == 0) {
enableTransitions = false;
}

Log.log(Log.LEVEL_TRACE, MODULE, "Transitions enabled: " + enableTransitions);
}

class SlideshowPane extends JPanel implements ActionListener {
Expand Down Expand Up @@ -725,11 +727,15 @@ public void paintPicture(Graphics2D g) {
if (! timer.isRunning()) {
timer.start();
}
} else {
imageAlpha = 1;
}
}

Composite composite = g.getComposite();

Log.log(Log.LEVEL_TRACE, MODULE, "Painting alpha=" + imageAlpha);

if (imageAlpha != 1 && previousImage != null) {
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1 - imageAlpha));
g.drawImage(previousImage, previousRect.x, previousRect.y, getContentPane());
Expand Down
10 changes: 5 additions & 5 deletions com/gallery/GalleryRemote/model/Gallery.java
Expand Up @@ -308,7 +308,7 @@ public void setStUrlString(String urlString) {
stUrlString = reformatUrlString(urlString, true);

if (!blockWrites && stUrlString != null) {
GalleryRemote._().properties.setProperty(URL + prefsIndex, stUrlString);
GalleryRemote._().properties.setProperty(GURL + prefsIndex, stUrlString);
}
}

Expand Down Expand Up @@ -634,7 +634,7 @@ public static Gallery readFromProperties(GalleryProperties p, int prefsIndex, St
}

public static Gallery readFromProperties(GalleryProperties p, int prefsIndex, StatusUpdate su, boolean mustHaveUsername) {
String url = p.getProperty(URL + prefsIndex);
String url = p.getProperty(GURL + prefsIndex);
String username = p.getProperty(USERNAME + prefsIndex, true);

if (mustHaveUsername && username == null) {
Expand Down Expand Up @@ -688,9 +688,9 @@ public static Gallery readFromProperties(GalleryProperties p, int prefsIndex, St
}

public void writeToProperties(PropertiesFile p) {
Log.log(Log.LEVEL_TRACE, MODULE, "Wrote to properties: " + toString());
Log.log(Log.LEVEL_TRACE, MODULE, "Writing to properties: " + toString());

p.setProperty(URL + prefsIndex, stUrlString);
p.setProperty(GURL + prefsIndex, stUrlString);
p.setProperty(USERNAME + prefsIndex, username);
if (getPassword() != null && p.getBooleanProperty(SAVE_PASSWORDS)) {
p.setBase64Property(PASSWORD + prefsIndex, password);
Expand Down Expand Up @@ -729,7 +729,7 @@ public void writeToProperties(PropertiesFile p) {
public static void removeFromProperties(PropertiesFile p, int n) {
Log.log(Log.LEVEL_TRACE, MODULE, "Removed from properties: " + n);

p.setProperty(URL + n, null);
p.setProperty(GURL + n, null);
p.setProperty(USERNAME + n, null);
p.setProperty(PASSWORD + n, null);
p.setProperty(TYPE + n, null);
Expand Down
4 changes: 2 additions & 2 deletions com/gallery/GalleryRemote/prefs/PreferenceNames.java
Expand Up @@ -36,7 +36,7 @@ public interface PreferenceNames {
public static final String USERNAME = "username.";
public static final String PASSWORD = "password.";
public static final String TYPE = "type.";
public static final String URL = "url.";
public static final String GURL = "url.";
public static final String STANDALONE = "Standalone";
public static final String POSTNUKE = "PostNuke";
public static final String PHPNUKE = "PHPNuke";
Expand Down Expand Up @@ -92,7 +92,7 @@ public interface PreferenceNames {
public static final String FONT_OVERRIDE_STYLE = "fontOverrideStyle";
public static final String FONT_OVERRIDE_SIZE = "fontOverrideSize";
public static final String PREVIEW_TRANSITION_DURATION = "previewTransitionDuration";
public static final String UNACCELERATED_TRANSITION = "unacceleratedTransition";
public static final String ALLOW_UNACCELERATED_TRANSITION = "allowUnacceleratedTransition";
public static final String PREVIEW_DRAW_THIRDS = "previewDrawThirds";

// Applet
Expand Down
10 changes: 5 additions & 5 deletions com/gallery/GalleryRemote/resources/GRResources.properties
Expand Up @@ -156,8 +156,8 @@ SlidePa.extra=Extra
SlidePa.extraHelp=Location of the extra fields information
SlidePa.url=URL
SlidePa.urlHelp=Location of the URL
SlidePa.url=Album
SlidePa.urlHelp=Location of the name of the album
SlidePa.album=Album
SlidePa.albumHelp=Location of the name of the album
SlidePa.lowRez=Force download of lower-resolution pictures
SlidePa.lowRezHelp=Check this option to make downloading images faster, so the slideshow goes faster
SlidePa.random=Random order
Expand Down Expand Up @@ -490,19 +490,19 @@ ImageUtils.warningTextIM=<html>An optional part of Gallery Remote, <b>ImageMagic
or is malfunctioning. Gallery Remote will not be able to resize images before<br>\
uploading them, and loading thumbnails and previews will be much slower.<br>\
You can find out how to fix this by going to this page:
ImageUtils.warningUrlIM=http://codex.gallery2.org/index.php/Gallery_Remote_Bundled
ImageUtils.warningUrlIM=http://codex.gallery2.org/index.php/Gallery_Remote:Bundled
ImageUtils.warningUrlTextIM=Gallery Remote Bundled
ImageUtils.warningTextJpegtran=<html>An optional part of Gallery Remote, <b>jpegtran</b>, could not be found<br>\
or is malfunctioning. Gallery Remote will not be able to rotate images before<br>\
uploading them.<br>\
You can find out how to fix this by going to this page:
ImageUtils.warningUrlJpegtran=http://codex.gallery2.org/index.php/Gallery_Remote_Bundled
ImageUtils.warningUrlJpegtran=http://codex.gallery2.org/index.php/Gallery_Remote:Bundled
ImageUtils.warningUrlTextJpegtran=Gallery Remote Bundled
ImageUtils.warningTextJpegtranCrop=<html>An optional part of Gallery Remote, <b>jpegtran</b>, could not be found<br>\
or is malfunctioning for the purpose of cropping pictures. Gallery Remote will not be able to losslessly crop images before<br>\
uploading them.<br>\
You can find out how to fix this by going to this page:
ImageUtils.warningUrlJpegtranCrop=http://codex.gallery2.org/index.php/Gallery_Remote_Bundled
ImageUtils.warningUrlJpegtranCrop=http://codex.gallery2.org/index.php/Gallery_Remote:Bundled
ImageUtils.warningUrlTextJpegtranCrop=Gallery Remote Bundled
ImageUtils.warningTextJava=<html>Using Java as a fallback to resize pictures will cause them to lose their EXIF data.<br>\
Do you want to resize with Gallery Remote anyway, or let the server perform the resize (longer upload time).
Expand Down

0 comments on commit 83df704

Please sign in to comment.