Class InterfaceGraphic<T extends Tool>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mgui.interfaces.InterfacePanel
mgui.interfaces.graphics.InterfaceGraphic<T>
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Comparable<InterfaceGraphic<T>>, java.util.EventListener, javax.accessibility.Accessible, AttributeListener, AttributeObject, DisplayListener, InterfaceMouseObject, InterfaceObject, CategoryObject, MapListener, PopupMenuObject, NamedObject, ShapeListener, Toolable<T>, ToolListener, TreeObject, CleanableObject, XMLObject, IconObject
Direct Known Subclasses:
InterfaceConsoleDisplay, InterfaceDataTable, InterfaceGraphDisplay, InterfaceGraphic2D, InterfaceGraphic3D, InterfaceLayoutWindow, InterfacePlotDisplay

public abstract class InterfaceGraphic<T extends Tool>
extends InterfacePanel
implements Toolable<T>, InterfaceMouseObject, IconObject, MapListener, ToolListener, XMLObject, java.lang.Comparable<InterfaceGraphic<T>>
The base class for all graphical interface windows. Has a list of implementing subclasses and has several methods for determining a particular instance type. Methods for setting interface-specific tools are also declared in this class.

TODO: make this class more generic; either by building a list of implementing classes at runtime, or by having them set by the instantiating frame.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  InterfaceGraphic.GraphicType  

    Nested classes/interfaces inherited from class javax.swing.JPanel

    javax.swing.JPanel.AccessibleJPanel

    Nested classes/interfaces inherited from class javax.swing.JComponent

    javax.swing.JComponent.AccessibleJComponent

    Nested classes/interfaces inherited from class java.awt.Container

    java.awt.Container.AccessibleAWTContainer

    Nested classes/interfaces inherited from class java.awt.Component

    java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy

    Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject

    XMLObject.XMLEncoding, XMLObject.XMLType
  • Field Summary

    Fields
    Modifier and Type Field Description
    boolean excludeToSelection  
    protected java.util.ArrayList<InterfaceGraphicListener> graphic_listeners  
    protected boolean init_once  
    protected boolean is_snapshot  
    protected java.io.File last_screen_shot_file  
    protected java.util.HashMap<java.lang.String,​java.lang.Object> post_render_tasks  
    protected java.util.ArrayList<GraphicMouseListener> status_listeners  
    protected java.util.HashMap<GraphicMouseListener,​java.lang.Integer> status_map  
    protected Map theMap  
    InterfaceGraphicWindow title_panel  
    ToolInputAdapter toolInputAdapter  

    Fields inherited from class javax.swing.JComponent

    listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW

    Fields inherited from class java.awt.Component

    accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

    Fields inherited from interface java.awt.image.ImageObserver

    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
  • Constructor Summary

    Constructors
    Constructor Description
    InterfaceGraphic()  
  • Method Summary

    Modifier and Type Method Description
    void addGraphicListener​(InterfaceGraphicListener l)  
    void addMouseListener​(InterfaceMouseListener thisObj)  
    void addStatusListener​(GraphicMouseListener thisObj)  
    int compareTo​(InterfaceGraphic panel)  
    protected void fireGraphicListeners()  
    java.awt.Color getBackgroundColour()  
    T getCurrentTool()  
    javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode()
    Returns a tree node containing a list of objects displayable by a class of InterfaceGraphic.
    Map getMap()  
    org.jogamp.vecmath.Point2f getMouseCoords​(java.awt.Point p)
    Return the mapped coordinates, depending on the InterfaceGraphic window, for the given screen coordinates.
    java.lang.String getName()
    Gets the name for this object.
    javax.swing.Icon getObjectIcon()
    Returns the Icon associated with this object.
    protected int getPopupLength()  
    InterfacePopupMenu getPopupMenu()
    Produces and returns a popup menu for this object.
    static java.util.ArrayList<InterfaceGraphic<?>> getSourceTypes()  
    java.util.ArrayList<java.lang.String> getStatusMessages​(java.awt.Point p)
    Returns a list of status messages, to be displayed in the status bar
    protected javax.swing.tree.DefaultMutableTreeNode getTreeNode​(ShapeSet3DInt set)  
    static InterfaceGraphic.GraphicType getType​(java.lang.String str)  
    static java.lang.String getTypeStr​(InterfaceGraphic.GraphicType g)  
    void handlePopupEvent​(java.awt.event.ActionEvent e)
    Handles an event on this object's popup menu.
    protected void init()  
    boolean isDisplayable​(java.lang.Object obj)  
    boolean isToolable​(Tool tool)
    Tests whether this object is toolable by tool
    void mapUpdated​(MapEvent e)  
    void mouseDragged​(java.awt.event.MouseEvent e)  
    void mouseMoved​(java.awt.event.MouseEvent e)  
    void removeGraphicListener​(InterfaceGraphicListener l)  
    void removeMouseListener​(InterfaceMouseListener thisObj)  
    void removeMouseObject​(GraphicMouseListener thisObj)  
    void setBackgroundColour​(java.awt.Color c)  
    <E extends T>
    boolean
    setCurrentTool​(E tool)  
    <E extends T>
    boolean
    setDefaultTool​(E tool)  
    void setExcludeToSelection​(boolean ex)  
    void setMap​(Map m)  
    void setName​(java.lang.String name)
    Sets the name for this object.
    void setStatusBar​(InterfaceStatusBarPanel status_bar)  
    boolean setTool​(Tool tool)
    Sets the current tool.
    void toolDeactivated​(ToolEvent e)  
    void toolStateChanged​(ToolEvent e)  
    int updateStatusBox​(InterfaceGraphicTextBox box, java.awt.event.MouseEvent e)
    Notifies this window to update the given status text box with information as it sees fit.
    boolean writeSnapshotToFile​(java.io.File file)
    Writes a snapshot of this window to file as a Portable Network Graphics (png) image.
    void writeXML​(int tab, java.io.Writer writer)
    Writes the XML representation of this object to file.
    void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
    Writes the XML representation of this object to file, as XMLType.Normal.

    Methods inherited from class javax.swing.JPanel

    getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI

    Methods inherited from class javax.swing.JComponent

    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update

    Methods inherited from class java.awt.Container

    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree

    Methods inherited from class java.awt.Component

    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • status_listeners

      protected java.util.ArrayList<GraphicMouseListener> status_listeners
    • status_map

      protected java.util.HashMap<GraphicMouseListener,​java.lang.Integer> status_map
    • toolInputAdapter

      public ToolInputAdapter toolInputAdapter
    • excludeToSelection

      public boolean excludeToSelection
    • theMap

      protected Map theMap
    • init_once

      protected boolean init_once
    • graphic_listeners

      protected java.util.ArrayList<InterfaceGraphicListener> graphic_listeners
    • title_panel

      public InterfaceGraphicWindow title_panel
    • post_render_tasks

      protected java.util.HashMap<java.lang.String,​java.lang.Object> post_render_tasks
    • last_screen_shot_file

      protected java.io.File last_screen_shot_file
    • is_snapshot

      protected boolean is_snapshot
  • Constructor Details

    • InterfaceGraphic

      public InterfaceGraphic()
  • Method Details

    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Overrides:
      getObjectIcon in class InterfacePanel
      Returns:
    • compareTo

      public int compareTo​(InterfaceGraphic panel)
      Specified by:
      compareTo in interface java.lang.Comparable<T extends Tool>
    • init

      protected void init()
      Specified by:
      init in class InterfacePanel
    • getMouseCoords

      public org.jogamp.vecmath.Point2f getMouseCoords​(java.awt.Point p)
      Return the mapped coordinates, depending on the InterfaceGraphic window, for the given screen coordinates.
      Parameters:
      p -
      Returns:
      mapped coordinates; or null if not applicable.
    • getStatusMessages

      public java.util.ArrayList<java.lang.String> getStatusMessages​(java.awt.Point p)
      Returns a list of status messages, to be displayed in the status bar
      Returns:
    • toolStateChanged

      public void toolStateChanged​(ToolEvent e)
      Specified by:
      toolStateChanged in interface ToolListener
    • toolDeactivated

      public void toolDeactivated​(ToolEvent e)
      Specified by:
      toolDeactivated in interface ToolListener
    • addGraphicListener

      public void addGraphicListener​(InterfaceGraphicListener l)
    • removeGraphicListener

      public void removeGraphicListener​(InterfaceGraphicListener l)
    • fireGraphicListeners

      protected void fireGraphicListeners()
    • getTypeStr

      public static java.lang.String getTypeStr​(InterfaceGraphic.GraphicType g)
    • getType

      public static InterfaceGraphic.GraphicType getType​(java.lang.String str)
    • getSourceTypes

      public static java.util.ArrayList<InterfaceGraphic<?>> getSourceTypes()
    • addMouseListener

      public void addMouseListener​(InterfaceMouseListener thisObj)
      Specified by:
      addMouseListener in interface InterfaceMouseObject
    • removeMouseListener

      public void removeMouseListener​(InterfaceMouseListener thisObj)
      Specified by:
      removeMouseListener in interface InterfaceMouseObject
    • setExcludeToSelection

      public void setExcludeToSelection​(boolean ex)
    • getMap

      public Map getMap()
    • setMap

      public void setMap​(Map m)
    • mapUpdated

      public void mapUpdated​(MapEvent e)
      Specified by:
      mapUpdated in interface MapListener
    • isDisplayable

      public boolean isDisplayable​(java.lang.Object obj)
    • setStatusBar

      public void setStatusBar​(InterfaceStatusBarPanel status_bar)
      Overrides:
      setStatusBar in class InterfacePanel
    • updateStatusBox

      public int updateStatusBox​(InterfaceGraphicTextBox box, java.awt.event.MouseEvent e)
      Notifies this window to update the given status text box with information as it sees fit. Boxes are mapped to indices within this class; By default, if the box's index is 1, the value will be set to the name of the current window; otherwise it will be set to an empty string. Overriding classes should call this super method first.
      Parameters:
      box - Text box to update
      Returns:
      The index of the box; mostly useful for internal purposes
    • addStatusListener

      public void addStatusListener​(GraphicMouseListener thisObj)
    • removeMouseObject

      public void removeMouseObject​(GraphicMouseListener thisObj)
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Overrides:
      getName in class java.awt.Component
      Returns:
    • setName

      public void setName​(java.lang.String name)
      Description copied from interface: NamedObject
      Sets the name for this object.
      Specified by:
      setName in interface NamedObject
      Overrides:
      setName in class java.awt.Component
    • setBackgroundColour

      public void setBackgroundColour​(java.awt.Color c)
    • getBackgroundColour

      public java.awt.Color getBackgroundColour()
    • getDisplayObjectsNode

      public javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode()
      Returns a tree node containing a list of objects displayable by a class of InterfaceGraphic. Must therefore be overriden by that class.
      Parameters:
      p - InterfaceDisplayPanel containing displayable data objects
      Returns:
      DefaultMutableTreeNode with a tree list of displayable objects
    • getTreeNode

      protected javax.swing.tree.DefaultMutableTreeNode getTreeNode​(ShapeSet3DInt set)
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Overrides:
      getPopupMenu in class InterfacePanel
      Returns:
    • getPopupLength

      protected int getPopupLength()
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
      Overrides:
      handlePopupEvent in class InterfacePanel
    • mouseMoved

      public void mouseMoved​(java.awt.event.MouseEvent e)
      Specified by:
      mouseMoved in interface java.awt.event.MouseMotionListener
      Overrides:
      mouseMoved in class InterfacePanel
    • mouseDragged

      public void mouseDragged​(java.awt.event.MouseEvent e)
      Specified by:
      mouseDragged in interface java.awt.event.MouseMotionListener
      Overrides:
      mouseDragged in class InterfacePanel
    • writeSnapshotToFile

      public boolean writeSnapshotToFile​(java.io.File file)
      Writes a snapshot of this window to file as a Portable Network Graphics (png) image.
      Parameters:
      file -
      Returns:
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • getCurrentTool

      public T getCurrentTool()
      Specified by:
      getCurrentTool in interface Toolable<T extends Tool>
    • setTool

      public boolean setTool​(Tool tool)
      Sets the current tool. Use this method if the type of the InterfaceGraphic object is unknown.
      Parameters:
      tool -
      Returns:
      false if this object is not toolable by tool.
    • setCurrentTool

      public <E extends T> boolean setCurrentTool​(E tool)
      Specified by:
      setCurrentTool in interface Toolable<T extends Tool>
    • setDefaultTool

      public <E extends T> boolean setDefaultTool​(E tool)
      Specified by:
      setDefaultTool in interface Toolable<T extends Tool>
    • isToolable

      public boolean isToolable​(Tool tool)
      Description copied from interface: Toolable
      Tests whether this object is toolable by tool
      Specified by:
      isToolable in interface Toolable<T extends Tool>
      Returns: