Class SimEnvGraphPanel

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Printable, Serializable, EventListener, Accessible

public class SimEnvGraphPanel extends FWDefaultPanel implements Printable
Graph editor (JUNG) showing a solution as graph: resources, SimComponents and outputs as vertices, the links between their variables as edges. Optionally shows the solution tree and allows step-wise simulation runs.
Author:
Andreas Enders
See Also:
  • Field Details

    • jcb

      protected JComboBox jcb
      The LayoutClass selection Combo
  • Constructor Details

    • SimEnvGraphPanel

      public SimEnvGraphPanel(String aXMLFilePath, FWAbstractFunctionality aFunctionality, boolean aCreateButtonPanel, boolean doShowResources, boolean doShowOutput, boolean aReadonly, boolean aEditEnabled, boolean aShowSolutionTree)
      Creates a session for the solution file and shows its graph. The session is stored in the observable parameter named by resultParamKey.
      Parameters:
      aXMLFilePath - path of the solution file
      aFunctionality - the functionality shown by this panel
      aCreateButtonPanel - whether the navigation buttons are shown
      doShowResources - whether resources are shown initially
      doShowOutput - whether outputs are shown initially
      aReadonly - if true the edit mode cannot be switched on
      aEditEnabled - whether the panel starts in edit mode
      aShowSolutionTree - whether the solution tree is shown left of the graph
    • SimEnvGraphPanel

      public SimEnvGraphPanel(net.simplace.sim.FWSimSolution aSolution)
      Creates an editable graph for an existing solution (without functionality and session).
      Parameters:
      aSolution - the solution
  • Method Details

    • reorderByPosition

      public void reorderByPosition()
      Changes the order of execution by the places of the SimComponents on the circle (#62): the components shown are sorted by their angle on the circle (starting right, clockwise as placed), components not shown as vertex (e.g. in a group) keep their position. Then the components are placed on the circle again.
    • go

      protected void go()
      Next: if the solution was changed, it is saved first (or the changes are discarded) - see confirmLeave().
      Overrides:
      go in class FWDefaultPanel
    • back

      protected void back()
      Back: if the solution was changed, it is saved first (or the changes are discarded) - see confirmLeave().
      Overrides:
      back in class FWDefaultPanel
    • refreshAllInputLinks

      public void refreshAllInputLinks()
      Rebuilds the edges to all SimComponents, e.g. after variables of a component were changed which others use (#62).
    • editRules

      public boolean editRules(net.simplace.sim.model.FWSimComponent aComponent)
      Opens the editor of a SimpleSimComponent or DefaultManagement and updates the edges if it was changed (#62).
      Parameters:
      aComponent - the component
      Returns:
      true if changed
    • refreshInputLinks

      public void refreshInputLinks(net.simplace.sim.model.FWSimComponent aComponent)
      Rebuilds the edges to a SimComponent after its inputs were changed (#62).
      Parameters:
      aComponent - the component
    • hasEditableInputs

      public static boolean hasEditableInputs(net.simplace.sim.util.FWSimFieldContainer aContainer)
      Parameters:
      aContainer - a container of the graph
      Returns:
      true if its inputs can be edited with the input dialog: SimComponents whose configuration element is kept when saving (not DefaultManagement, simple or analytics components)
    • editInputs

      public boolean editInputs(net.simplace.sim.model.FWSimComponent aComponent, String aSourceFilter)
      Opens the input dialog of a SimComponent and updates the edges if inputs were changed (#62).
      Parameters:
      aComponent - the component
      aSourceFilter - initial filter of the sources, may be null
      Returns:
      true if inputs were changed
    • addSimFieldContainers

      public void addSimFieldContainers(net.simplace.sim.util.FWSimFieldContainer[] aCaptionArray) throws net.simplace.sim.exceptions.DuplicateSimFieldException
      Parameters:
      aCaptionArray - field containers to add
      Throws:
      net.simplace.sim.exceptions.DuplicateSimFieldException - if a container name is already used
    • addSimFieldContainer

      public void addSimFieldContainer(net.simplace.sim.util.FWSimFieldContainer aFieldContainer) throws net.simplace.sim.exceptions.DuplicateSimFieldException
      Adds a field container as vertex and creates the links from its inputs (SimComponents) or rules (outputs).
      Parameters:
      aFieldContainer - the field container
      Throws:
      net.simplace.sim.exceptions.DuplicateSimFieldException - if the container name is already used
    • removeSimFieldContainer

      public void removeSimFieldContainer(net.simplace.sim.util.FWSimFieldContainer aFieldContainer)
      Removes a field container from the graph and the solution.
      Parameters:
      aFieldContainer - the field container
    • getOutputAdapters

      public ArrayList<net.simplace.sim.io.output.FWSimOutputAdapter> getOutputAdapters()
      Returns:
      Output Adapters
    • writeJPEGImage

      public static void writeJPEGImage(File file, JPanel aPanel)
      copy the visible part of the graph to a file as a jpeg image
      Parameters:
      file - the target file
      aPanel - the panel to paint
    • print

      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
      Specified by:
      print in interface Printable
      Throws:
      PrinterException
      See Also:
    • doTransition

      public void doTransition()
      Animates the transition from the current to the new layout.
    • addSimLink

      public void addSimLink(net.simplace.sim.model.SimFieldLink aSimFieldLink, net.simplace.sim.model.SimVarLink aSimVarLink)
      Adds a variable link to the edge and to the solution (invalid links are logged).
      Parameters:
      aSimFieldLink - the edge
      aSimVarLink - the variable link
    • removeSimLink

      public void removeSimLink(net.simplace.sim.model.SimFieldLink aSimFieldLink, net.simplace.sim.model.SimVarLink aSimVarLink)
      Removes a variable link from the edge and from the solution.
      Parameters:
      aSimFieldLink - the edge
      aSimVarLink - the variable link
    • getSimFieldMap

      public Map<String, net.simplace.sim.util.FWSimFieldContainer> getSimFieldMap()
      Returns:
      the SimFieldMap
    • getSimSolution

      public net.simplace.sim.FWSimSolution getSimSolution()
      Returns:
      the SolutionObject
    • getSimFieldLinksMap

      public net.simplace.sim.util.MultiHashMap<net.simplace.sim.util.FWSimFieldContainer, net.simplace.sim.model.SimFieldLink> getSimFieldLinksMap()
      Returns:
      the simfieldmap
    • getGraphPanel

      public edu.uci.ics.jung.graph.Graph<net.simplace.sim.util.FWSimFieldContainer, net.simplace.sim.model.SimFieldLink> getGraphPanel()
      Returns:
      the hypergraph
    • getSimSession

      public net.simplace.sim.FWSimSession getSimSession()
      Returns:
      the simSession
    • isVisible

      public boolean isVisible(net.simplace.sim.util.FWSimFieldContainer aFieldContainer)
      Parameters:
      aFieldContainer - the field container
      Returns:
      if Field should be visible (outputs and resources depend on the show toggles)
    • showOutputs

      public boolean showOutputs()
      Returns:
      if outputs should be shown
    • showResources

      public boolean showResources()
      Returns:
      if resources should be shown
    • initializeLayout

      public void initializeLayout()
      Creates the layout selected in the layout combo box and animates the transition to it.
    • getSimSimulation

      public net.simplace.sim.FWSimSimulation getSimSimulation()
      Returns:
      the current simulation object