Class InterfaceGraphic2D

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
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<Tool2D>>, java.util.EventListener, javax.accessibility.Accessible, AttributeListener, AttributeObject, DisplayListener, InterfaceMouseObject, InterfaceObject, CategoryObject, MapListener, PopupMenuObject, NamedObject, ShapeListener, Toolable<Tool2D>, ToolListener, TreeObject, CleanableObject, XMLObject, IconObject

public class InterfaceGraphic2D
extends InterfaceGraphic<Tool2D>
implements ShapeListener
Graphical interface window for display 2D shapes (Shape2DInt). Shapes must be contained by a SectionSet3DInt object to be displayed.

TODO: implement using a JLayeredPane, allowing annotations, etc.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Field Details

    • drawEngine

      protected DrawingEngine drawEngine
    • currentTool

      public Tool2D currentTool
    • defaultTool

      public Tool2D defaultTool
    • temp_shapes

      protected java.util.ArrayList<Shape2DInt> temp_shapes
    • currentSelection

      public ShapeSelectionSet currentSelection
    • currentSections

      public SectionSet3DInt currentSections
    • shape3DObjects

      protected ShapeSet2DInt shape3DObjects
    • childSets

      protected java.util.ArrayList<ShapeSet2DInt> childSets
    • grids

      public java.util.ArrayList<Graphic2DGrid> grids
    • graphicListeners

      protected java.util.ArrayList<InterfaceGraphicListener> graphicListeners
    • needs_update

      protected transient boolean needs_update
    • needs_regen

      protected transient boolean needs_regen
    • section_changed

      protected transient boolean section_changed
    • shapeList

      public java.util.ArrayList<Shape2DInt> shapeList
  • Constructor Details

    • InterfaceGraphic2D

      public InterfaceGraphic2D​(java.lang.String name)
      Instantiate and initialize a new 2D graphics window called name.
      Parameters:
      name -
    • InterfaceGraphic2D

      public InterfaceGraphic2D()
      Instantiate and initialize a new 2D graphics window.
  • 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 InterfaceGraphic<Tool2D>
      Returns:
    • init

      protected void init()
      Overrides:
      init in class InterfaceGraphic<Tool2D>
    • getPickShapes

      public java.util.ArrayList<PickInfoShape2D> getPickShapes​(java.awt.Point point)
      Return a list of PickInfoShape2D objects containing information about the shapes intersecting point. Shapes will be sorted according to render order.
      Parameters:
      point -
      Returns:
    • moveSectionTo

      public void moveSectionTo​(org.jogamp.vecmath.Point3f point)
      Set the current section to the one which is closest to point
      Parameters:
      point -
    • centerSectionAt

      public void centerSectionAt​(org.jogamp.vecmath.Point2f point)
      Centers the section at the specified 2D point
      Parameters:
      point -
    • centerSectionAt

      public void centerSectionAt​(org.jogamp.vecmath.Point3f point)
      Centers the section at the specified 3D point, projected onto its plane
      Parameters:
      point -
    • getShapeModel

      public ShapeModel3D getShapeModel()
    • destroy

      public void destroy()
      Description copied from interface: InterfaceObject
      Destroy this object (prepare it to be removed from memory)
      Specified by:
      destroy in interface InterfaceObject
      Specified by:
      destroy in interface ShapeListener
      Overrides:
      destroy in class InterfacePanel
    • isDestroyed

      public boolean isDestroyed()
      Description copied from interface: InterfaceObject
      Test whether this object has been destroyed
      Specified by:
      isDestroyed in interface InterfaceObject
      Specified by:
      isDestroyed in interface ShapeListener
      Overrides:
      isDestroyed in class InterfacePanel
      Returns:
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Description copied from interface: AttributeListener
      Called when an Attribute's value has been updated.
      Specified by:
      attributeUpdated in interface AttributeListener
      Overrides:
      attributeUpdated in class InterfacePanel
    • needsRedraw

      public boolean needsRedraw​(Attribute<?> a)
    • paintComponent

      public void paintComponent​(java.awt.Graphics g)
      Overrides:
      paintComponent in class javax.swing.JComponent
    • updateStatusBox

      public int updateStatusBox​(InterfaceGraphicTextBox box, java.awt.event.MouseEvent e)
      Description copied from class: InterfaceGraphic
      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.
      Overrides:
      updateStatusBox in class InterfaceGraphic<Tool2D>
      Parameters:
      box - Text box to update
      Returns:
      The index of the box; mostly useful for internal purposes
    • addGrid

      public void addGrid​(Graphic2DGrid grid)
    • removeGrid

      public void removeGrid​(Graphic2DGrid grid)
    • set3DObjects

      protected void set3DObjects()
      Sets the 2D section-projected shapes from the 3D objects in the current model.
    • insertShape3D

      public void insertShape3D​(Shape2DInt shape)
    • removeShape3D

      public void removeShape3D​(Shape2DInt shape)
    • addGraphicListener

      public void addGraphicListener​(InterfaceGraphicListener l)
      Overrides:
      addGraphicListener in class InterfaceGraphic<Tool2D>
    • removeGraphicListener

      public void removeGraphicListener​(InterfaceGraphicListener l)
      Overrides:
      removeGraphicListener in class InterfaceGraphic<Tool2D>
    • updateDisplay

      public void updateDisplay()
      Description copied from class: InterfacePanel
      Requests this panel to update its display.
      Specified by:
      updateDisplay in interface DisplayListener
      Overrides:
      updateDisplay in class InterfacePanel
    • updateDisplays

      public void updateDisplays()
      Overrides:
      updateDisplays in class InterfacePanel
    • updateCurrentSectionSet

      public void updateCurrentSectionSet()
    • updateCurrentSectionSet

      public void updateCurrentSectionSet​(boolean update)
    • getCurrentPlane

      public Plane3D getCurrentPlane()
    • appendTempShape

      public void appendTempShape​(Shape2DInt shape)
      Append a temporary shape to the bottom of the stack (renders first)
      Parameters:
      shape -
    • insertTempShape

      public void insertTempShape​(Shape2DInt shape)
      Insert a temporary shape at the top of the stack (renders last)
      Parameters:
      shape -
    • insertTempShape

      public void insertTempShape​(Shape2DInt shape, int pos)
      Insert a temporary shape at pos in the stack
      Parameters:
      shape -
    • clearTempShapes

      public void clearTempShapes()
      Remove all temporary shapes from the stack
    • removeTempShape

      public void removeTempShape​(Shape2DInt shape)
      Remove temporary shape shape from the stack
      Parameters:
      shape -
    • drawShape2D

      public void drawShape2D​(Shape2DInt thisShape)
    • drawMouseShapes

      public void drawMouseShapes()
    • addShapeInt

      public void addShapeInt​(Shape2DInt thisShape)
    • addShapeInt

      public void addShapeInt​(Shape2DInt thisShape, int pos)
    • addModelShape2D

      public void addModelShape2D​(Shape2DInt thisShape, boolean update)
    • addModelShape2D

      public void addModelShape2D​(Shape2DInt thisShape, boolean updateShape, boolean updateListeners)
    • drawMouseObjects

      public void drawMouseObjects()
    • addPropertyChangeObject

      public void addPropertyChangeObject​(GraphicPropertyListener thisObj)
    • addPropertyChangeListener

      public void addPropertyChangeListener​(java.beans.PropertyChangeListener thisListener)
      Overrides:
      addPropertyChangeListener in class java.awt.Container
    • removePropertyChangeListener

      public void removePropertyChangeListener​(java.beans.PropertyChangeListener thisListener)
      Overrides:
      removePropertyChangeListener in class java.awt.Component
    • setDefaultTool

      public boolean setDefaultTool​(Tool2D tool)
      Specified by:
      setDefaultTool in interface Toolable<Tool2D>
      Overrides:
      setDefaultTool in class InterfaceGraphic<Tool2D>
    • setCurrentTool

      public boolean setCurrentTool​(Tool2D thisTool)
      Specified by:
      setCurrentTool in interface Toolable<Tool2D>
      Overrides:
      setCurrentTool in class InterfaceGraphic<Tool2D>
    • toolStateChanged

      public void toolStateChanged​(ToolEvent event)
      Specified by:
      toolStateChanged in interface ToolListener
      Overrides:
      toolStateChanged in class InterfaceGraphic<Tool2D>
    • 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<Tool2D>
      Overrides:
      isToolable in class InterfaceGraphic<Tool2D>
      Returns:
    • finishTool

      public void finishTool()
    • getCurrentTool

      public Tool2D getCurrentTool()
      Specified by:
      getCurrentTool in interface Toolable<Tool2D>
      Overrides:
      getCurrentTool in class InterfaceGraphic<Tool2D>
    • pickShape

      public Shape2DInt pickShape​(java.awt.Point pickPt, int pickRadius)
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode treeNode)
      Description copied from interface: TreeObject
      Sets the children for this node's InterfaceTreeNode.
      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class InterfacePanel
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.awt.Component
    • getTitle

      public java.lang.String getTitle()
      Overrides:
      getTitle in class InterfacePanel
    • getToolLock

      public boolean getToolLock()
    • setToolLock

      public void setToolLock​(boolean val)
    • setCurrentSelection

      public void setCurrentSelection​(ShapeSelectionSet thisSet, boolean exclude)
    • setCurrentSectionSet

      public void setCurrentSectionSet​(SectionSet3DInt set)
    • getCurrentSectionSet

      public SectionSet3DInt getCurrentSectionSet()
      Sets the current section set for this graphic object.
      Returns:
    • setCurrentSection

      public void setCurrentSection​(int i)
      Sets the current section for the section set to be rendered in this graphic object.
      Parameters:
      i -
    • getCurrentSection

      public int getCurrentSection()
      Gets the current section for the section set being rendered.
      Returns:
    • setSource

      public boolean setSource​(java.lang.Object obj)
      Description copied from class: InterfacePanel
      Sets the source object for this panel.
      Overrides:
      setSource in class InterfacePanel
      Returns:
    • getSource

      public java.lang.Object getSource()
      Description copied from class: InterfacePanel
      Returns the source object for this panel; returns null if no source object is set.
      Overrides:
      getSource in class InterfacePanel
      Returns:
    • setExcludeToSelection

      public void setExcludeToSelection​(boolean exclude)
      Overrides:
      setExcludeToSelection in class InterfaceGraphic<Tool2D>
    • isDisplayable

      public boolean isDisplayable​(java.lang.Object obj)
      Overrides:
      isDisplayable in class InterfaceGraphic<Tool2D>
    • fireGraphicSourceChanged

      protected void fireGraphicSourceChanged()
    • fireGraphicListeners

      protected void fireGraphicListeners​(GraphicEvent e)
    • getShapeSet2D

      public ShapeSet2DInt getShapeSet2D()
    • addShape2D

      public void addShape2D​(Shape2DInt thisShape)
    • addShape2D

      public void addShape2D​(Shape2DInt thisShape, boolean updateShape, boolean updateListeners)
    • setShapeSet2D

      public void setShapeSet2D()
    • setCurrentShapeSet

      protected void setCurrentShapeSet​(ShapeSet2DInt set)
    • getDisplayObjectsNode

      public javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode()
      Returns a tree node containing a list of objects displayable by this class of InterfaceGraphic. Thus, a hierarchical list of SectionSet3DInt objects from the data model.
      Overrides:
      getDisplayObjectsNode in class InterfaceGraphic<Tool2D>
      Parameters:
      p - InterfaceDisplayPanel containing displayable data objects
      Returns:
      DefaultMutableTreeNode with a tree list of SectionSet3DInt objects
    • getTreeNode

      protected javax.swing.tree.DefaultMutableTreeNode getTreeNode​(ShapeSet3DInt set)
      Overrides:
      getTreeNode in class InterfaceGraphic<Tool2D>
    • mapUpdated

      public void mapUpdated​(MapEvent e)
      Specified by:
      mapUpdated in interface MapListener
      Overrides:
      mapUpdated in class InterfaceGraphic<Tool2D>
    • regenerateDisplay

      public void regenerateDisplay()
      Regenerates all the shapes in this display.
    • shapeUpdated

      public void shapeUpdated​(ShapeEvent e)
      Description copied from interface: ShapeListener
      A shape that this object is listening to has been updated. The specific type of event is defined by ShapeEvent.EventType.
      Specified by:
      shapeUpdated in interface ShapeListener
      Overrides:
      shapeUpdated in class InterfacePanel
    • find3DChildren

      public java.util.ArrayList<Shape2DInt> find3DChildren​(Shape3DInt shape)
    • find3DChild

      public Shape2DInt find3DChild​(Shape3DInt shape)
    • 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 InterfaceGraphic<Tool2D>
      Returns:
    • getPopupLength

      protected int getPopupLength()
      Overrides:
      getPopupLength in class InterfaceGraphic<Tool2D>
    • 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 InterfaceGraphic<Tool2D>
    • keyPressed

      public void keyPressed​(java.awt.event.KeyEvent e)
      Specified by:
      keyPressed in interface java.awt.event.KeyListener
      Overrides:
      keyPressed in class InterfacePanel
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML​(int tab)
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName)
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
    • handleXMLString

      public void handleXMLString​(java.lang.String s)
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) 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
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • getDrawingEngine

      public DrawingEngine getDrawingEngine()