package org.helioviewer.jhv.gui.components.statusplugins;

import java.awt.Dimension;

import javax.swing.BorderFactory;

import org.helioviewer.jhv.layers.LayersModel;

/**
 * Status panel for displaying the framerate for image series.
 * 
 * <p>
 * The information of this panel is always shown for the active layer.
 * 
 * <p>
 * This panel is not visible, if the active layer is not an image series.
 * 
 * @author Markus Langenberg
 */
public class FramerateStatusPanel extends ViewStatusPanelPlugin {

    private static final long serialVersionUID = 1L;

    /**
     * Default constructor.
     */
    public FramerateStatusPanel() {
        setBorder(BorderFactory.createEtchedBorder());

        setPreferredSize(new Dimension(70, 20));
        setText("fps:");

        setVisible(true);
        LayersModel.getSingletonInstance().addLayersListener(this);
    }

    private void updateFramerate() {

        int idx = LayersModel.getSingletonInstance().getActiveLayer();

        if (LayersModel.getSingletonInstance().isValidIndex(idx)) {

            double fps = LayersModel.getSingletonInstance().getFPS(idx);
            String fpsString = Double.toString(fps);

            setVisible(true);
            setText("fps: " + fpsString);

        } else {

            setVisible(false);

        }

    }

    public void activeLayerChanged(int idx) {
        this.updateFramerate();
    }

    public void subImageDataChanged() {
        this.updateFramerate();
    }
}

@@ -78,16 +78,44 @@
 mension;
+%0Aimport java.awt.EventQueue;
 %0A%0Aimport
@@ -928,25 +928,24 @@
 amerate() %7B%0A
-%0A
         int 
@@ -1003,17 +1003,16 @@
 ayer();%0A
-%0A
         
@@ -1071,17 +1071,16 @@
 idx)) %7B%0A
-%0A
         
@@ -1270,17 +1270,16 @@
 tring);%0A
-%0A
         
@@ -1287,17 +1287,16 @@
  else %7B%0A
-%0A
         
@@ -1318,17 +1318,16 @@
 false);%0A
-%0A
         
@@ -1324,24 +1324,360 @@
 ;%0A        %7D%0A
+    %7D%0A%0A    private void updateFramerate_eq() %7B%0A        if (EventQueue.isDispatchThread()) %7B%0A            updateFramerate();%0A        %7D else %7B%0A            EventQueue.invokeLater(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A                    updateFramerate();%0A                %7D%0A            %7D);%0A        %7D
 %0A    %7D%0A%0A    
@@ -1718,37 +1718,32 @@
  idx) %7B%0A        
-this.
 updateFramerate(
@@ -1733,32 +1733,35 @@
  updateFramerate
+_eq
 ();%0A    %7D%0A%0A    p
@@ -1807,13 +1807,8 @@
     
-this.
 upda
@@ -1810,28 +1810,31 @@
  updateFramerate
+_eq
 ();%0A    %7D%0A%7D%0A
@@ -1831,10 +1831,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Update fps status from EventQueue