001/* The graph frame for interface automata.
002
003 Copyright (c) 1998-2016 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026
027 */
028package ptolemy.vergil.modal.ia;
029
030import diva.graph.GraphPane;
031import ptolemy.actor.gui.Tableau;
032import ptolemy.kernel.CompositeEntity;
033import ptolemy.kernel.util.NamedObj;
034import ptolemy.moml.LibraryAttribute;
035import ptolemy.vergil.modal.FSMGraphFrame;
036import ptolemy.vergil.modal.FSMGraphModel;
037
038///////////////////////////////////////////////////////////////////
039//// InterfaceAutomatonGraphFrame
040
041/**
042 This is a graph editor frame for ptolemy InterfaceAutomaton models.
043 Given a composite entity and a tableau, it creates an editor and populates
044 the menus and toolbar.  This overrides the base class to associate with the
045 editor an instance of InterfaceAutomatonGraphController.
046
047 @author  Steve Neuendorffer, Yuhong Xiong, Contributor: Edward A. Lee
048 @version $Id$
049 @since Ptolemy II 8.0
050 @Pt.ProposedRating Red (yuhong)
051 @Pt.AcceptedRating Red (johnr)
052 */
053@SuppressWarnings("serial")
054public class InterfaceAutomatonGraphFrame extends FSMGraphFrame {
055    /** Construct a frame associated with the specified model.
056     *  After constructing this, it is necessary
057     *  to call setVisible(true) to make the frame appear.
058     *  This is typically done by calling show() on the controlling tableau.
059     *  This constructor results in a graph frame that obtains its library
060     *  either from the model (if it has one) or the default library defined
061     *  in the configuration.
062     *  @see Tableau#show()
063     *  @param entity The model to put in this frame.
064     *  @param tableau The tableau responsible for this frame.
065     */
066    public InterfaceAutomatonGraphFrame(CompositeEntity entity,
067            Tableau tableau) {
068        this(entity, tableau, null);
069    }
070
071    /** Construct a frame associated with the specified model.
072     *  After constructing this, it is necessary
073     *  to call setVisible(true) to make the frame appear.
074     *  This is typically done by calling show() on the controlling tableau.
075     *  This constructor results in a graph frame that obtains its library
076     *  either from the model (if it has one), or the <i>defaultLibrary</i>
077     *  argument (if it is non-null), or the default library defined
078     *  in the configuration.
079     *  @see Tableau#show()
080     *  @param entity The model to put in this frame.
081     *  @param tableau The tableau responsible for this frame.
082     *  @param defaultLibrary An attribute specifying the default library
083     *   to use if the model does not have a library.
084     */
085    public InterfaceAutomatonGraphFrame(CompositeEntity entity, Tableau tableau,
086            LibraryAttribute defaultLibrary) {
087        super(entity, tableau, defaultLibrary);
088    }
089
090    ///////////////////////////////////////////////////////////////////
091    ////                         protected methods                 ////
092
093    /** Create a new graph pane. Note that this method is called in
094     *  constructor of the base class, so it must be careful to not reference
095     *  local variables that may not have yet been created.
096     *  @param entity The object to be displayed in the pane (which must
097     *   be an instance of CompositeEntity).
098     *  @return The pane that is created.
099     */
100    @Override
101    protected GraphPane _createGraphPane(NamedObj entity) {
102        _controller = new InterfaceAutomatonGraphController(_directory);
103        _controller.setConfiguration(getConfiguration());
104        _controller.setFrame(this);
105
106        // NOTE: The cast is safe because the constructor accepts
107        // only CompositeEntity.
108        final FSMGraphModel graphModel = new FSMGraphModel(
109                (CompositeEntity) entity);
110        return new GraphPane(_controller, graphModel);
111    }
112}