/* A graph view for Ptolemy Event Relation Actor (PTERA) domain models. Copyright (c) 2009-2014 The Regents of the University of California. All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. PT_COPYRIGHT_VERSION_2 COPYRIGHTENDKEY */ package ptolemy.vergil.ptera; import ptolemy.actor.gt.GTTools; import ptolemy.actor.gui.Tableau; import ptolemy.domains.ptera.kernel.Event; import ptolemy.kernel.CompositeEntity; import ptolemy.kernel.util.NamedObj; import ptolemy.moml.LibraryAttribute; import ptolemy.vergil.basic.BasicGraphPane; import ptolemy.vergil.modal.FSMGraphFrame; import ptolemy.vergil.modal.FSMGraphModel; import diva.graph.GraphPane; /** A graph view for Ptolemy Event Relation Actor (PTERA) domain models. @author Thomas Huining Feng @version $Id: PteraGraphFrame.java 69607 2014-07-30 17:07:26Z cxh $ @since Ptolemy II 8.0 @Pt.ProposedRating Red (tfeng) @Pt.AcceptedRating Red (tfeng) */ @SuppressWarnings("serial") public class PteraGraphFrame extends FSMGraphFrame { /** Construct a frame associated with the specified Ptera model. * After constructing this, it is necessary * to call setVisible(true) to make the frame appear. * This is typically done by calling show() on the controlling tableau. * This constructor results in a graph frame that obtains its library * either from the model (if it has one) or the default library defined * in the configuration. * @see Tableau#show() * @param entity The model to put in this frame. * @param tableau The tableau responsible for this frame. */ public PteraGraphFrame(CompositeEntity entity, Tableau tableau) { super(entity, tableau); } /** Construct a frame associated with the specified Ptera model. * After constructing this, it is necessary * to call setVisible(true) to make the frame appear. * This is typically done by calling show() on the controlling tableau. * This constructor results in a graph frame that obtains its library * either from the model (if it has one), or the defaultLibrary * argument (if it is non-null), or the default library defined * in the configuration. * @see Tableau#show() * @param entity The model to put in this frame. * @param tableau The tableau responsible for this frame. * @param defaultLibrary An attribute specifying the default library * to use if the model does not have a library. */ public PteraGraphFrame(CompositeEntity entity, Tableau tableau, LibraryAttribute defaultLibrary) { super(entity, tableau, defaultLibrary); } /////////////////////////////////////////////////////////////////// //// protected methods //// /** Create a new graph pane. Note that this method is called in * constructor of the base class, so it must be careful to not reference * local variables that may not have yet been created. * @param entity The object to be displayed in the pane (which must be * an instance of CompositeEntity). * @return The pane that is created. */ @Override protected GraphPane _createGraphPane(NamedObj entity) { _controller = new PteraGraphController(); _controller.setConfiguration(getConfiguration()); _controller.setFrame(this); // NOTE: The cast is safe because the constructor accepts // only CompositeEntity. final FSMGraphModel graphModel = new FSMGraphModel( (CompositeEntity) entity); return new BasicGraphPane(_controller, graphModel, entity); } /** Return the text to be used in the animation menu item. In this class, * always return "Animate Events". * * @return The text for the menu item. */ protected String getAnimationMenuText() { return "Animate Events"; } /** Return the default event MoML. * @return The default event MoML. */ protected String _getDefaultEventMoML() { NamedObj child = GTTools.getChild(_topLibrary, "Event", false, false, true, false); if (child instanceof Event) { return child.exportMoML(); } else { return ""; } } }