* If configure() has been called (prior to the plot getting created), * then the configurations that it specified have been deferred. Those * configurations are performed at this time. * * @param container The container into which to place the plot, or * null to specify that a new plot should be created. */ @Override public void place(PortableContainer container) { _getImplementation().setPlatformContainer( container != null ? container.getPlatformContainer() : null); _getImplementation().removeNullContainer(); if (container != null) { if (container.getPlatformContainer() instanceof PlotBoxInterface) { // According to FindBugs the cast is an error: // [M D BC] Unchecked/unconfirmed cast [BC_UNCONFIRMED_CAST] // However it is checked that _container instanceof PlotBox, // so FindBugs is wrong. plot = (PlotBoxInterface) container.getPlatformContainer(); plot.setButtons(true); } else { if (plot == null) { plot = _newPlot(); plot.setTitle(getName()); } plot.setButtons(true); container.add(plot); // java.awt.Component.setBackground(color) says that // if the color "parameter is null then this component // will inherit the background color of its parent." plot.setBackground(null); } // If the container is non-null and configurations have // been deferred, implement them now. // There was a bug here where we got a ConcurrentModificationException // because ModelPane.setModel() called ModelPane._closeDisplays(), // which called PlotterBase.place(null) and then _implementDeferredConfigurations // iterated through the list of bases while it was being modified. // To replicate, do open Spectrum.xml and do View -> Run Window. _implementDeferredConfigurations(); } } /** Clear the plot, if there is one. Notice that unlike * initialize(), this clears the entire plot. * @see #initialize() * @exception IllegalActionException If the parent class throws it. */ @Override public void preinitialize() throws IllegalActionException { super.preinitialize(); if (plot != null) { // Do not clear the axes. plot.clear(false); plot.repaint(); if (((BooleanToken) automaticRescale.getToken()).booleanValue()) { plot.setAutomaticRescale(true); } } } /** Override the base class to remove the plot from its graphical * container if the argument is null. * @param container The proposed container. * @exception IllegalActionException If the base class throws it. * @exception NameDuplicationException If the base class throws it. */ @Override public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException { Nameable previousContainer = getContainer(); super.setContainer(container); if (container != previousContainer && previousContainer != null) { _remove(); } } /** Specify the associated frame and set its properties (size, etc.) * to match those stored in the _windowProperties attribute. * @param frame The associated frame. */ public void setFrame(Object frame) { _getImplementation().setFrame(frame); } /** Set a name to present to the user. *
If the Plot window has been rendered, then the title of the * Plot window will be updated to the value of the name parameter.
* @param name A name to present to the user. * @see #getDisplayName() */ @Override public void setDisplayName(String name) { super.setDisplayName(name); // See http://bugzilla.ecoinformatics.org/show_bug.cgi?id=4302 _getImplementation().setTableauTitle(name); } /** Set or change the name. If a null argument is given the * name is set to an empty string. * Increment the version of the workspace. * This method is write-synchronized on the workspace. *If the Plot window has been rendered, then the title of the * Plot window will be updated to the value of the name parameter.
* @param name The new name. * @exception IllegalActionException If the name contains a period * or if the object is a derived object and the name argument does * not match the current name. * @exception NameDuplicationException Not thrown in this base class. * May be thrown by derived classes if the container already contains * an object with this name. * @see #getName() * @see #getName(NamedObj) */ @Override public void setName(String name) throws IllegalActionException, NameDuplicationException { super.setName(name); // See http://bugzilla.ecoinformatics.org/show_bug.cgi?id=4302 _getImplementation().setTableauTitle(name); } /** If the fillOnWrapup parameter is true, rescale the * plot so that all the data is visible. * @exception IllegalActionException If the superclass throws it. */ @Override public void wrapup() throws IllegalActionException { if (((BooleanToken) fillOnWrapup.getToken()).booleanValue()) { if (plot != null) { plot.fillPlot(); } } if (plot != null) { // If we are generating code, then plot might be null; plot.setAutomaticRescale(false); } super.wrapup(); } /////////////////////////////////////////////////////////////////// //// protected methods //// /** Write a MoML description of the contents of this object, which * in this class is the configuration information. This method is called * by exportMoML(). Each description is indented according to the * specified depth and terminated with a newline character. * @param output The output stream to write to. * @param depth The depth in the hierarchy, to determine indenting. * @exception IOException If an I/O error occurs. */ @Override protected void _exportMoMLContents(Writer output, int depth) throws IOException { // Make sure that the current position of the frame, if any, // is up to date. _getImplementation().updateWindowAndSizeAttributes(); super._exportMoMLContents(output, depth); // NOTE: Cannot include xml spec in the header because processing // instructions cannot be nested in XML (lame, isn't it?). String header = ""; if (plot != null) { output.write(_getIndentPrefix(depth) + "This code is used as part of the dependency injection needed for the * HandSimDroid project, see $PTII/ptserver. This code uses dependency * inject to determine what implementation to use at runtime. * This method eventually reads ptolemy/actor/ActorModule.properties. * {@link ptolemy.actor.injection.ActorModuleInitializer#initializeInjector()} * should be called before this method is called. If it is not * called, then a message is printed and initializeInjector() is called.
* @return the implementation. */ protected PlotterBaseInterface _getImplementation() { if (_implementation == null) { if (PtolemyInjector.getInjector() == null) { System.err.println("Warning: main() did not call " + "ActorModuleInitializer.initializeInjector(), " + "so PlotterBase is calling it for you."); ActorModuleInitializer.initializeInjector(); } _implementation = PtolemyInjector.getInjector().getInstance( PlotterBaseInterface.class); _implementation.init(this); } return _implementation; } /** If configurations have been deferred, implement them now. * Also, configure the plot legends, if appropriate. */ protected void _implementDeferredConfigurations() { if (_configureSources != null) { // Coverity indicates that configure() can modify // _configureSources, _configureTexts and _configureBases, // which would invalidate the iterators because the // underlying list would be modified. However, the logic // of this program is such that configure() would only add // to these lists if plot was not yet a PlotInterface. // However, place() sets plot to a plotter and then calls // this method, so logically, the underlying lists cannot // be moderated. However, derived classes could do // something different, so copying the lists is a good // idea. Iterator