Package controller

Source Code of controller.ClipsController

package controller;

//----- JDK Imports ------------------------------------------------------------
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.AbstractButton;
import javax.swing.JButton;

//----- Quicktime Imports ------------------------------------------------------
import quicktime.std.movies.Movie;

//----- Phoenix Imports --------------------------------------------------------
import util.ImageUtils;
import view.ClipsWindow;

/**
* Video Phoenix
* Version 0.2.0
* Copyright (c) 2007 Lunderskov, Ian; Pan, Jiabei; Rebelsky, Samuel;
* Whisenhunt, Heather; Young, Ian; Zuleta Benavides, Luis.
* All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* @author  Lunderskov, Ian; Pan, Jiabei; Rebelsky, Samuel; Whisenhunt, Heather;
*          Young, Ian; Zuleta Benavides, Luis
* @author  Glimmer Labs
* @version 0.2.0
*/
public class ClipsController
{
  /*--------*-------------------------------------------------------------------
   * Fields *
   *--------*/

  // one window for this controller
  public view.ClipsWindow window;

  // this controller's instance of Phoenix
  public PhoenixController phoenix;


  /*--------------*-------------------------------------------------------------
   * Constructors *
   *--------------*/

  /**
   * Create a new ClipsController
   *
   * @param phoenix  PhoenixController for this ClipsController
   */
  public ClipsController(PhoenixController phoenix)
  {
    this.phoenix = phoenix;
    this.window = new ClipsWindow(this);
  } // ClipsController(PhoenixController)


  /*---------*------------------------------------------------------------------
   * Methods *
   *---------*/

  /**
   * Add a movie to the ClipsWindow
   *
   * @param mov   Movie to be added
   * @param name  Name to be displayed in the ClipsWindow
   */
  public void addClip(Movie mov, String name)
  {
    if (mov == null) return;

    // add it to the movie list, so that it can be referenced again by variable
    MovieController.movieList.put(name, mov);

    // overwrite anything with the same name
    Component[] comps = this.window.box.getComponents();
    for (int i = 0; i < comps.length; i++)
    {
      if (comps[i].getName().equals(name))
      {
        ((JButton)this.window.box.getComponent(i)).
        setIcon(ImageUtils.getIcon(mov));
        return;
      } // if (comps[i].getName().equals(name))
    } // for

    // if name does not already exist, make new icon and add to ClipsWindow
    JButton newClip = new JButton(name, ImageUtils.getIcon(mov));;
    newClip.setName(name);
    newClip.setVerticalTextPosition(AbstractButton.BOTTOM);
    newClip.setHorizontalTextPosition(AbstractButton.CENTER);
    newClip.setPreferredSize(new Dimension(100, 115));
    newClip.addActionListener(this.window);
    newClip.setFocusable(false);
    this.window.box.add(newClip);
    this.window.box.validate();
    newClip.setVisible(true);
    this.window.updateUI();
  } // addClip(Movie, String)

  /**
   * Clear the contents of the ClipsWindow
   */
  public void clear()
  {
    this.window.box.removeAll();
  } // clear()
} // class ClipsController
TOP

Related Classes of controller.ClipsController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.