All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
ItlkNetViewer

public class ItlkNetEditor extends NetEditor
A class which override the NetEditor to build an Interlock Simulator editor
See Also:
  • Constructor Details

    • ItlkNetEditor

      public ItlkNetEditor(JFrame parent)
      Construction
      Parameters:
      parent - Parent frame
  • Method Details

    • loadFile

      public void loadFile(String fileName) throws IOException
      Override loadFile to reinitialise object struct after a load
      Overrides:
      loadFile in class NetEditor
      Parameters:
      fileName - File name
      Throws:
      IOException - In case of failure
      See Also:
    • setEditable

      public void setEditable(boolean b)
      Sets the editor in EDIT/TRACE mode
      Overrides:
      setEditable in class NetEditor
      Parameters:
      b - EDIT/TRACE mode
      See Also:
      • NetEditor.isEditable
    • getRoot

      public NetObject getRoot()
      Returns:
      the root of the scheme (The only VCC object) or null
    • prepareObjects

      public void prepareObjects()
      Prepare object for logical evaluation, must be called once before playing logic
    • swapItlkState

      public void swapItlkState(NetObject o)
      Swap an interlock state
      Parameters:
      o - Net object to swap
    • setCreateMode

      public void setCreateMode(int type, int userType)
      Sets the editor in creation mode
      Parameters:
      type - NetEditor creation mode
      userType - User mode creation type
    • createBubbleObject

      public NetObject createBubbleObject(int x, int y)
      Overriding createBubbleObject to create our specific NetObject
      Overrides:
      createBubbleObject in class NetEditor
      Parameters:
      x - X position
      y - Y position
      Returns:
      Created object
      See Also:
    • addObject

      public boolean addObject(NetObject o)
      Description copied from class: NetEditor
      Add a NetObject to the editor.
      Overrides:
      addObject in class NetEditor
      Parameters:
      o - Object to be added
      Returns:
      true if the object has been succesfully added.
    • removeObject

      public void removeObject(NetObject o)
      Description copied from class: NetEditor
      Remove a NetObject from the editor.
      Overrides:
      removeObject in class NetEditor
      Parameters:
      o - Object to be removed
    • clearObjects

      public void clearObjects()
      Description copied from class: NetEditor
      Clear all object in the editor.
      Overrides:
      clearObjects in class NetEditor
    • paintLinks

      public void paintLinks(Graphics2D g2)
      Description copied from class: NetEditor
      Paint link of the scheme. Called by paint() before paintObjects(). You can override it to custom the link painting. Here is an example code for painting all links (Note that this code not handle link selection when the editor is editable):
        public void paintLinks(Graphics2D g2) {
          g2.setColor(Color.black);
          for (int i = 0; i < getNetObjectNumber() ; i++) {
            NetObject o = getNetObjectAt(i);
            for (int j = 0; j < o.getChildrenNumber() ; j++ ) {
              o.paintLink(g2,o.getChildAt(j),true);
            }
          }
        }
      
      Overrides:
      paintLinks in class NetEditor
      Parameters:
      g2 - Graphics object
      See Also:
    • paintObjects

      public void paintObjects(Graphics2D g2)
      Description copied from class: NetEditor
      Paint object of the scheme. Called by paint() after paintLinks(). You can override it to custom the object painting.
        public void paintObjects(Graphics2D g2) {
          for (int i = 0; i < getNetObjectNumber() ; i++)
            getNetObjectAt(i).paint(g2);
        }
       
      Overrides:
      paintObjects in class NetEditor
      Parameters:
      g2 - Graphics object
      See Also: