package org.helioviewer.jhv.gui.components;

import java.awt.event.MouseMotionListener;
import java.util.ArrayList;

import org.helioviewer.jhv.display.Displayer;
import org.helioviewer.jhv.layers.LayersListener;
import org.helioviewer.viewmodel.view.ComponentView;
import org.helioviewer.viewmodel.view.jp2view.JHVJP2View;

/**
 * This class represents an image component that is used to display the image of
 * all images.
 *
 * @author caplins
 * @author Alen Agheksanterian
 * @author Benjamin Wamsler
 * @author Stephan Pagel
 * @author Markus Langenberg
 */
public class MainImagePanel extends BasicImagePanel implements LayersListener {

    // ///////////////////////////////////////////////////////////////////////////
    // Definitions
    // ///////////////////////////////////////////////////////////////////////////

    // default serialVersionUID
    private static final long serialVersionUID = 1L;
    private final int loadingTasks = 0;

    private final ArrayList<MouseMotionListener> mouseMotionListeners = new ArrayList<MouseMotionListener>();

    // ///////////////////////////////////////////////////////////////////////////
    // Methods
    // ///////////////////////////////////////////////////////////////////////////

    /**
     * The public constructor
     * */
    public MainImagePanel() {
        // call constructor of super class
        super();

        // the one GLCanvas
        add(renderedImageComponent);

        Displayer.getLayersModel().addLayersListener(this);
    }

    /**
     * {@inheritDoc}
     */

    @Override
    public void setView(ComponentView newView) {
        if (renderedImageComponent != null)
            for (MouseMotionListener l : mouseMotionListeners)
                renderedImageComponent.removeMouseMotionListener(l);

        super.setView(newView);

        if (newView != null) {
            if (renderedImageComponent != null)
                for (MouseMotionListener l : mouseMotionListeners)
                    renderedImageComponent.addMouseMotionListener(l);
        }
    }

    /**
     * {@inheritDoc}
     */

    @Override
    public void addMouseMotionListener(MouseMotionListener l) {
        if (l != null)
            mouseMotionListeners.add(l);
    }

    /**
     * {@inheritDoc}
     */

    @Override
    public void removeMouseMotionListener(MouseMotionListener l) {
        if (l != null)
            mouseMotionListeners.remove(l);
    }

    @Override
    public void layerAdded(int idx) {

    }

    @Override
    public void layerRemoved(int oldIdx) {

    }

    @Override
    public void activeLayerChanged(JHVJP2View view) {
    }

}

@@ -137,186 +137,32 @@
 wer.
-jhv.display.Displayer;%0Aimport org.helioviewer.jhv.layers.LayersListener;%0Aimport org.helioviewer.viewmodel.view.ComponentView;%0Aimport org.helioviewer.viewmodel.view.jp2view.JHVJP2
+viewmodel.view.Component
 View
@@ -459,254 +459,10 @@
 nel 
-implements LayersListener %7B%0A%0A    // ///////////////////////////////////////////////////////////////////////////%0A    // Definitions%0A    // ///////////////////////////////////////////////////////////////////////////%0A%0A    // default serialVersionUID
+%7B%0A
 %0A   
@@ -514,48 +514,8 @@
  1L;
-%0A    private final int loadingTasks = 0;
 %0A%0A  
@@ -627,190 +627,8 @@
 );%0A%0A
-    // ///////////////////////////////////////////////////////////////////////////%0A    // Methods%0A    // ///////////////////////////////////////////////////////////////////////////%0A%0A
     
@@ -832,68 +832,8 @@
 );%0A%0A
-        Displayer.getLayersModel().addLayersListener(this);%0A
     
@@ -1763,206 +1763,6 @@
  %7D%0A%0A
-    @Override%0A    public void layerAdded(int idx) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void layerRemoved(int oldIdx) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void activeLayerChanged(JHVJP2View view) %7B%0A    %7D%0A%0A
 %7D%0A

remove unused code