This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 103 - Pages: 7 [ Previous | 1 2 3 4 5 6 7 ] - Last Post: 23 Jul 19, 15:33 Last Post By: AndreWolff
RobM

Posts: 4,071
Registered: 4-Aug-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 21 Jul 19, 14:49   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
Just did a quick experiment. I reinstalled jAlbum 17.1.5, created a project with Slide Show 4, and tried to use the "Panoramic image" custom panel. Got multiple errors when I checked one of the boxes, then clicked in the "Max. image width" field. So these are not new problems.
Too many variables involved in this issue, to such an extent that I don’t see how posting anything further would be of use. My opinion stands, it stands the best chance of being fixed and, at the same time, making the code robust, it needs to be a compiled skin.
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 21 Jul 19, 14:53   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:

Please confirm the accuracy of that statement; are you saying the problem now occurs in your skins without using my external tool
yes
and that they worked with previous versions of jAlbum when using the gps tool.
It has nothing to do with a GPS tool, only with panoramic images.
It did work a long time, but somewhere in time this problem was created. The user panel code is not changed the last 2 years, so I can't explain why I get now a silent crash. Nevertherless the parameters in the panel are correctly saved.
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 15:30   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I removed the bug with the "Max. image width" field by removing this field, it uses now always the default value width of 50000 pixels.

I see the silent crash now in the new verion only after using your video GPS tool, if I open the edit window of a picture or video directly after the tool is used.

I know where the crash is created, in this piece of code:
  public void setAlbumObject(AlbumObject ao) {
    super.setAlbumObject(ao);
    saveUI();
It gives this error
Caused by: bsh.EvalError: Command not found: saveUI() : at Line: 61 
Very strange because this code is executed without problems if I open the panoramic image user panel.

I hope David or another expert can explain this!
JeffTucker

Posts: 8,023
Registered: 31-Jan-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 15:45   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I couldn't resist having a fiddle with this. Between knowing that my own custom UI code doesn't call saveUI() at all (it's no longer necessary), and swiping some error-checking from ctwist's Mirage code, I arrived at this:
import java.awt.SystemColor;
import java.util.HashMap;
import javax.swing.*;
import se.datadosen.component.JLabelFor;
import se.datadosen.component.StateMonitor;
import static se.datadosen.component.StateMonitor.enable;
import se.datadosen.jalbum.AlbumObject;
import se.datadosen.jalbum.AlbumObjectProperties;
import se.datadosen.jalbum.Category;
import se.datadosen.jalbum.JAlbumContext;
import se.datadosen.jalbum.JCustomPanel;
class DemoSkinCustom extends JCustomPanel {
// Fields
    JCheckBox isPano = new JCheckBox("Panoramic");
    JSpinner custMaxImageWidth = new JSpinner(new SpinnerNumberModel(5000, 3000, 50000, 1000));
// Set up custom UI panel
    public DemoSkinCustom(JAlbumContext context) {
        super(context);
// Listeners
        new StateMonitor() {
            public void onChange() {
                boolean isImage = currentAO.getCategory() == Category.image;
                enable(isImage && isPano.isSelected(), custMaxImageWidth);
                AlbumObjectProperties currentProps = currentAO.getProperties();
                HashMap<String, Object> currentUserVars = (HashMap<String, Object>) currentProps.get("userVariables");
                if (isPano.isSelected()) {
                    if (currentUserVars == null) {
                        currentUserVars = new HashMap();
                    }
                    currentUserVars.put("maxImageWidth", custMaxImageWidth.getValue().toString());
                } else {
                    if (currentUserVars != null) {
                        currentUserVars.remove("maxImageWidth");
                    }
                }
                if (currentUserVars == null || currentUserVars.isEmpty()) {
                    currentProps.remove("userVariables");
                } else {
                    currentProps.put("userVariables", currentUserVars);
                }
                currentProps.save();
            }
        }.add(isPano);
// Spinner format
        custMaxImageWidth.setEditor(new JSpinner.NumberEditor(custMaxImageWidth, "#####"));
// Layout
        setBackground(SystemColor.text);
        setOpaque(false);
        add(isPano);
        add("br", new JLabelFor("Max image width", custMaxImageWidth));
        add(custMaxImageWidth);
// Init
        init();
    }
    public void setAlbumObject(AlbumObject ao) {
        if (ao != null) {
            super.setAlbumObject(ao);
            boolean isImage = currentAO.getCategory() == Category.image;
            isPano.setEnabled(isImage);
            custMaxImageWidth.setEnabled(isImage && isPano.isSelected());
        }
    }
}
This enables a Panoramic checkbox in the edit panel only for images - disabled for folders, videos, etc., where it would make no sense. If you check the box, you can use the spinner to select a width. That action populates the user variables with an entry for maxImageWidth (not visible unless you close/open the edit panel, or move to the next object, but it's there nonetheless). If you uncheck the box, that value is removed from the user variables.

If the user manually removes the user variable, the image-specific maxImageWidth is no longer applied unless he toggles the Panoramic checkbox - the skin can't overcome all the odd things a user might do.

Tested, and it all seems to work.
JeffTucker

Posts: 8,023
Registered: 31-Jan-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 15:48   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Oh, and in SlideModel.java:
public class SlideModel {
    public boolean isPano = false;
    public int custMaxImageWidth = 5000;
}
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 16:18   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Attachment FancyBoxTest.jaskin (731.9 KB)
jGromit wrote:
Tested, and it all seems to work.
Well I don't know how you tested it, but I added it to the onload.bsh file of my FancyBox skin and got this error:
bsh.ParseException: Parse error at line 76, column 31. Encountered: , in onload.bsh at line number 76

I don't know how to correct this line 76:

HashMap<String, Object> currentUserVars = (HashMap<String, Object>) currentProps.get("userVariables");

The jaskin file is enclosed.

Anyhow many thanks for your work!!
JeffTucker

Posts: 8,023
Registered: 31-Jan-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 16:32   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I wouldn't even attempt to use this in an intepreted onload.bsh. That puts you into the BeanShell realm, and it's an unsupported dinosaur. This is the custom UI panel from a compiled UI. In fact, I used the demo project from this post for tinkering: https://jalbum.net/forum/thread.jspa?threadID=54799

As long as you stubbornly refuse to move to a compiled UI, you're going to keep having these kinds of problems, and none of the rest of us is willing to spend time trying to debug them. Working with onload.bsh is just miserable, and I won't do it.

(This thread started with a request for jAlbum to allow the addition of GPS coordinates to videos. How did we get here?)
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 22 Jul 19, 17:11   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
I wouldn't even attempt to use this in an intepreted onload.bsh.
Not so pessimistic, with some additions I have it running in onload.bsh:
class DemoSkinCustom extends JCustomPanel {
// Fields
    JCheckBox isPano = new JCheckBox("Panoramic");
    JSpinner custMaxImageWidth = new JSpinner(new SpinnerNumberModel(5000, 3000, 50000, 1000));
// Set up custom UI panel
    public DemoSkinCustom(JAlbumContext context) {
        super(context);
// Listeners
        new StateMonitor() {
            public void onChange() {
                boolean isImage = currentAO.getCategory() == Category.image;
                enable(isImage && isPano.isSelected(), custMaxImageWidth);
                AlbumObjectProperties currentProps = currentAO.getProperties();
                //HashMap<String, Object> currentUserVars = (HashMap<String, Object>) currentProps.get("userVariables");
                HashMap currentUserVars = (HashMap) properties.get(AlbumObjectProperties.USER_VARIABLES);
                if (isPano.isSelected()) {
                    if (currentUserVars == null) {
                        currentUserVars = new HashMap();
                    }
                    currentUserVars.put("maxImageWidth", custMaxImageWidth.getValue().toString());
                } else {
                    if (currentUserVars != null) {
                        currentUserVars.remove("maxImageWidth");
                    }
                }
                if (currentUserVars == null || currentUserVars.isEmpty()) {
                    currentProps.remove("userVariables");
                } else {
                    currentProps.put("userVariables", currentUserVars);
                }
                currentProps.save();
            }
        }.add(isPano);
// Spinner format
        custMaxImageWidth.setEditor(new JSpinner.NumberEditor(custMaxImageWidth, "#####"));
// Layout
        setBackground(SystemColor.text);
        setOpaque(false);
        add(isPano);
        add("br", new JLabelFor("Max image width", custMaxImageWidth));
        add(custMaxImageWidth);
// Init
        init();
    }
    public void setAlbumObject(AlbumObject ao) {
        if (ao != null) {
            super.setAlbumObject(ao);
            boolean isImage = currentAO.getCategory() == Category.image;
            isPano.setEnabled(isImage);
            custMaxImageWidth.setEnabled(isImage && isPano.isSelected());
        }
    }
}
 
 
// Make some convenient references available
JAlbumContext context = JAlbumContext.getInstance();
PluginContext pc = context.getPluginContext();
EditPanel editPanel = pc.getEditPanel();
 
DemoSkinCustom DemoSkinCustom = new DemoSkinCustom(context);
// Install custom panel in Jalbum's edit panel
editPanel.addCustomTab("Panoramic image", DemoSkinCustom);
/*
Now I have to add user variable "pan360".

Edit:
There is a problem: the edit window shows no image, only a black background.

This is caused by the statement:
HashMap currentUserVars = (HashMap) properties.get(AlbumObjectProperties.USER_VARIABLES);

Edited by: AndreWolff on 22-Jul-2019 19:04
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 09:28   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
I couldn't resist having a fiddle with this. Between knowing that my own custom UI code doesn't call saveUI() at all (it's no longer necessary),
Correct, I can safely remove it from my code:
 public void setAlbumObject(AlbumObject ao) {
    super.setAlbumObject(ao);
//  saveUI();
//  removeAll();
    if (ao != null) {
      cAO = ao;
      cProps = cAO.getProperties();
      File currentContextFile = ao.getFile();
      add(panoramicSphericalImage)  // line 67
but now Robs video GPS gives another message if I open an Edit window:
Exception in thread "AWT-EventQueue-0" java.security.PrivilegedActionException: bsh.EvalError: Undefined argument: 
panoramicSphericalImage  : at Line: 67 :
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 09:40   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
Please confirm the accuracy of that statement; are you saying the problem now occurs in your skins without using my external tool, and that they worked with previous versions of jAlbum when using the gps tool.
Until now I tried to prevent a silent crash after using your tool by changing something in my skins, without success.

Now I tried to change something in your tool to prevent a silent crash.
This was more successfully: by removing the setAccessibility statements the silent crash is gone!

The corrected tool is enclosed.
RobM

Posts: 4,071
Registered: 4-Aug-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 10:09   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 14:57   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Well if I remove both setAccessibility(true); and setAccessibility(false); all works fine,
but with only setAccessibility(false); outcommented it works also fine.
RobM

Posts: 4,071
Registered: 4-Aug-2006
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 15:13   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
For future reference, the posted ’corrected version’ is not a corrected version, it is a variant to possibly work around issues with SS4 and the like skins. The resultant code breaks jAlbum’s protocols.
AndreWolff

Posts: 1,975
Registered: 14-Dec-2007
Re: Make it possible to add GPS coordinates to movies and pictures in jAlbum
Posted: 23 Jul 19, 15:33   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
The resultant code breaks jAlbum’s protocols.
What do you mean with that?
I tested my modified version of your tool with other skins like the Tiger skin and it works there also perfect.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums