Class InterfaceGraphic3D

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
All Implemented Interfaces:
java.awt.event.ActionListener, 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<Tool3D>>, java.util.EventListener, javax.accessibility.Accessible, AttributeListener, AttributeObject, DisplayListener, AxesListener, InterfaceMouseObject, InterfaceObject, CategoryObject, Camera3DListener, MapListener, PopupMenuObject, NamedObject, ShapeModel3DListener, ShapeListener, Toolable<Tool3D>, ToolListener, TreeObject, CleanableObject, XMLObject, IconObject

public class InterfaceGraphic3D
extends InterfaceGraphic<Tool3D>
implements ShapeModel3DListener, ShapeListener, Camera3DListener, java.awt.event.ActionListener, AxesListener
Interface class for Java3D display. Each InterfaceGraphic3D object contains its own SimpleUniverse object for display of Shape3DInt objects. Shape3DInt objects are represented as ShapeSceneNode objects (i.e., Shape2DSceneNode and Shape3DSceneNode), which should be specified by-reference and be updateable. todo: Allow for multiple directional light sources
Since:
1.0
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Field Details

    • currentTool

      public Tool3D currentTool
    • defaultTool

      public Tool3D defaultTool
    • currentSelection

      public ShapeSelectionSet currentSelection
    • tempBounds

      public org.jogamp.java3d.BoundingSphere tempBounds
    • canvas3D

      public InterfaceCanvas3D canvas3D
    • ambientLight

      public org.jogamp.java3d.AmbientLight ambientLight
    • lights

      public java.util.ArrayList<org.jogamp.java3d.DirectionalLight> lights
    • lightSource

      public org.jogamp.java3d.DirectionalLight lightSource
    • currentScene

      public ShapeSceneNode currentScene
    • currentSet

      public ShapeSet3DInt currentSet
    • viewingPlatform

      public org.jogamp.java3d.utils.universe.ViewingPlatform viewingPlatform
    • pickCanvasGeom

      public org.jogamp.java3d.utils.pickfast.PickCanvas pickCanvasGeom
    • pickCanvasNode

      public org.jogamp.java3d.utils.pickfast.PickCanvas pickCanvasNode
    • background

      public org.jogamp.java3d.Background background
    • toolInput3DAdapter

      protected ToolBehavior3DAdapter toolInput3DAdapter
    • lightNode

      protected org.jogamp.java3d.BranchGroup lightNode
    • model

      protected ShapeModel3D model
    • axes_transform

      protected org.jogamp.java3d.TransformGroup axes_transform
    • min_screen_dim

      protected float min_screen_dim
    • R_temp

      protected org.jogamp.java3d.Transform3D R_temp
    • R_temp2

      protected org.jogamp.java3d.Transform3D R_temp2
    • M3_temp

      protected org.jogamp.vecmath.Matrix3d M3_temp
    • axes

      protected Axes3D axes
    • temp_popup_shape

      protected org.jogamp.java3d.BranchGroup temp_popup_shape
  • Constructor Details

    • InterfaceGraphic3D

      public InterfaceGraphic3D​(java.lang.String theName)
    • InterfaceGraphic3D

      public InterfaceGraphic3D()
    • InterfaceGraphic3D

      public InterfaceGraphic3D​(ShapeModel3D m)
  • 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<Tool3D>
      Returns:
    • 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:
    • init

      public void init()
      Overrides:
      init in class InterfaceGraphic<Tool3D>
    • getClipDistances

      public double[] getClipDistances()
    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent e)
      Specified by:
      actionPerformed in interface java.awt.event.ActionListener
    • axesChanged

      public void axesChanged​(AxesEvent event)
      Specified by:
      axesChanged in interface AxesListener
    • setAxes

      public void setAxes​(Axes3D axes)
    • setMap

      public void setMap​(Map map)
      Overrides:
      setMap in class InterfaceGraphic<Tool3D>
    • getView

      public org.jogamp.java3d.View getView()
    • getInterfaceCanvas3D

      public InterfaceCanvas3D getInterfaceCanvas3D()
    • getShowAxes

      public boolean getShowAxes()
    • setShowAxes

      public void setShowAxes​(boolean b)
    • getAxesSize

      public float getAxesSize()
    • setAxesSize

      public void setAxesSize​(float size)
    • repaintAxes

      public void repaintAxes()
    • getMap3D

      public Map3D getMap3D()
    • getBoundsScale

      public float getBoundsScale()
    • setBoundsScale

      public void setBoundsScale​(float scale)
    • getAutoCenter

      public boolean getAutoCenter()
    • setAutoCenter

      public void setAutoCenter​(boolean b)
    • setDefaultTool

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

      public void setBackgroundColour​(java.awt.Color c)
      Overrides:
      setBackgroundColour in class InterfaceGraphic<Tool3D>
    • updateBackground

      public void updateBackground()
    • getCamera

      public Camera3D getCamera()
    • setModel

      public void setModel​(ShapeModel3D m)
    • getPickTolerance

      protected float getPickTolerance()
    • setPickTolerance

      protected void setPickTolerance​(float d)
    • getMinScreenScale

      protected org.jogamp.vecmath.Vector2f getMinScreenScale()
    • getMinScreenScaleWidth

      protected float getMinScreenScaleWidth()
    • getMinScreenScaleHeight

      protected float getMinScreenScaleHeight()
    • updateAxes

      public void updateAxes()
    • componentResized

      public void componentResized​(java.awt.event.ComponentEvent e)
      Resize axes on window resize, after given delay (to avoid excessive updates)
      Specified by:
      componentResized in interface java.awt.event.ComponentListener
      Overrides:
      componentResized in class InterfacePanel
    • cameraAngleChanged

      public void cameraAngleChanged​(CameraEvent e)
      Specified by:
      cameraAngleChanged in interface Camera3DListener
    • cameraChanged

      public void cameraChanged​(CameraEvent e)
      Specified by:
      cameraChanged in interface Camera3DListener
    • getModel

      public ShapeModel3D getModel()
    • getPickCanvasGeom

      public org.jogamp.java3d.utils.pickfast.PickCanvas getPickCanvasGeom()
    • getPickCanvasNode

      public org.jogamp.java3d.utils.pickfast.PickCanvas getPickCanvasNode()
    • getViewingPlatform

      public org.jogamp.java3d.utils.universe.ViewingPlatform getViewingPlatform()
    • addMouseListener

      public void addMouseListener​(java.awt.event.MouseListener m)
      Overrides:
      addMouseListener in class java.awt.Component
    • addMouseMotionListener

      public void addMouseMotionListener​(java.awt.event.MouseMotionListener m)
      Overrides:
      addMouseMotionListener in class java.awt.Component
    • addMouseWheelListener

      public void addMouseWheelListener​(java.awt.event.MouseWheelListener m)
      Overrides:
      addMouseWheelListener in class java.awt.Component
    • 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
    • updateClipDistances

      protected void updateClipDistances()
    • isAutoBackClip

      public boolean isAutoBackClip()
    • 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
    • updateScene

      public void updateScene()
    • updateScene

      public void updateScene​(ShapeSet3DInt shapeSet)
    • 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
    • shapeModelChanged

      public void shapeModelChanged​(ShapeModelEvent event)
      Description copied from interface: ShapeModel3DListener
      Fired when a ShapeModel3D is changed in some way. The specific change is indicated by the EventType of the ShapeModelEvent.
      Specified by:
      shapeModelChanged in interface ShapeModel3DListener
    • 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
    • setCurrentTool

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

      public void toolDeactivated​(ToolEvent e)
      Specified by:
      toolDeactivated in interface ToolListener
      Overrides:
      toolDeactivated in class InterfaceGraphic<Tool3D>
    • getTool

      public Tool getTool()
    • 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<Tool3D>
      Overrides:
      isToolable in class InterfaceGraphic<Tool3D>
      Returns:
    • getToolLock

      public boolean getToolLock()
    • setToolLock

      public void setToolLock​(boolean val)
    • setCurrentSelection2D

      public void setCurrentSelection2D​(ShapeSelectionSet selSet, boolean exclude)
    • toString

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

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

      public boolean setSource​(java.lang.Object source)
      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:
    • getDisplayObjectsNode

      public javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode()
      Description copied from class: InterfaceGraphic
      Returns a tree node containing a list of objects displayable by a class of InterfaceGraphic. Must therefore be overriden by that class.
      Overrides:
      getDisplayObjectsNode in class InterfaceGraphic<Tool3D>
      Returns:
      DefaultMutableTreeNode with a tree list of displayable objects
    • 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<Tool3D>
      Returns:
    • setPopupShape

      protected void setPopupShape​(org.jogamp.java3d.BranchGroup shape)
    • getCurrentTool

      public Tool3D getCurrentTool()
      Specified by:
      getCurrentTool in interface Toolable<Tool3D>
      Overrides:
      getCurrentTool in class InterfaceGraphic<Tool3D>
    • 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<Tool3D>
      Parameters:
      box - Text box to update
      Returns:
      The index of the box; mostly useful for internal purposes
    • centerOnPoint

      public void centerOnPoint​(org.jogamp.vecmath.Point3f p)
    • 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<Tool3D>
    • writeToFileBuffer

      public boolean writeToFileBuffer​(java.io.File file)
      Writes this window to a png image file.
      Returns:
      true if successful
    • writeSnapshotToFile

      public boolean writeSnapshotToFile​(java.io.File file)
      Temp screenshot while off screen rendering doesn't work...
      Overrides:
      writeSnapshotToFile in class InterfaceGraphic<Tool3D>
      Returns:
    • writeToFile

      protected boolean writeToFile​(java.awt.image.BufferedImage image, java.io.File file)
    • postRender

      public void postRender()
      Executes any post-rendering tasks, called through the postSwap method of PostRenderingCanvas3D.
    • 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