com.quiltplayer.controller.ImageController.java Source code

Java tutorial

Introduction

Here is the source code for com.quiltplayer.controller.ImageController.java

Source

/**
 * QuiltPlayer v1.0 Copyright (C) 2008-2009 Vlado Palczynski
 * vlado.palczynski@quiltplayer.com http://www.quiltplayer.com This program is
 * free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation;
 * either version 2 of the License, or (at your option) any later version. This
 * program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 */
package com.quiltplayer.controller;

import java.awt.event.ActionEvent;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.quiltplayer.external.covers.model.LocalImage;
import com.quiltplayer.model.Album;
import com.quiltplayer.view.swing.frame.QuiltPlayerFrame;
import com.quiltplayer.view.swing.listeners.ImageListener;

/**
 * @author Vlado Palczynski
 */
@Controller
public class ImageController implements ImageListener {

    public static final String EVENT_CHANGE_COVER = "change.cover";

    @Autowired
    private QuiltPlayerFrame frame;

    /*
     * (non-Javadoc)
     * 
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals(EVENT_CHANGE_COVER)) {
            final Album album = (Album) e.getSource();

            int imageCount = e.getID();

            // This should be set as primary
            LocalImage toFrontImage = album.getImages().get(imageCount);
            album.changeFrontImage(album, toFrontImage);

            frame.updateUI();
        }
    }
}