Class Shape2DInt

java.lang.Object
All Implemented Interfaces:
java.awt.datatransfer.Transferable, java.lang.Cloneable, java.lang.Comparable<InterfaceShape>, AttributeListener, AttributeObject, InterfaceObject, PersistentObject, VariableObject, PopupMenuObject, NamedObject, InterfaceQueryObject, InterfaceShapeQueryObject, ShapeListener, VertexDataColumnListener, InterfaceTransferable, TreeObject, CleanableObject, XMLObject, IconObject
Direct Known Subclasses:
Circle2DInt, Ellipse2DInt, Image2DInt, Line2DInt, Mesh2DInt, Point2DInt, PointSet2DInt, Polygon2DInt, RadialRep2DInt, Rect2DInt, SectionSet2DInt, Shape2DSelectionSet, ShapeSet2DInt, Text2DInt, Vector2DInt

public abstract class Shape2DInt
extends InterfaceShape
implements ShapeListener, java.lang.Cloneable
Base class for all interfaces to 2D geometrical shapes. Specifies functions and fields common to all shapes.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Details

    • thisShape

      public Shape2D thisShape
    • drawEngine

      public DrawingEngine drawEngine
    • idStr

      public java.lang.String idStr
    • bounds

      public Rect2D bounds
    • nodeListener

      protected ShapeListener nodeListener
    • centerPt

      public org.jogamp.vecmath.Point2f centerPt
    • sceneNode

      public ShapeSceneNode sceneNode
    • parentShape

      public Shape3DInt parentShape
    • child3D

      public Shape3DInt child3D
    • map_idx_to_parent

      protected java.util.HashMap<java.lang.Integer,​java.lang.Integer> map_idx_to_parent
  • Constructor Details

    • Shape2DInt

      public Shape2DInt()
  • Method Details

    • getGeometryInstance

      public Shape getGeometryInstance()
      Description copied from class: InterfaceShape
      Returns an instance of this InterfaceShape's geometry class.
      Specified by:
      getGeometryInstance in class InterfaceShape
      Returns:
    • getParentAttribute

      protected Attribute<?> getParentAttribute​(java.lang.String attrName)
      Specified by:
      getParentAttribute in class InterfaceShape
    • setMapIdxToParent

      public void setMapIdxToParent​(java.util.HashMap<java.lang.Integer,​java.lang.Integer> map_idx_to_parent)
    • getMapIdxToParent

      public java.util.HashMap<java.lang.Integer,​java.lang.Integer> getMapIdxToParent()
    • getGeometry

      public Shape getGeometry()
      Description copied from class: InterfaceShape
      Returns the Shape associated with this object
      Specified by:
      getGeometry in class InterfaceShape
      Returns:
    • setGeometry

      public boolean setGeometry​(Shape geometry)
      Description copied from class: InterfaceShape
      Sets the Shape associated with this object. If the class type is incorrect, returns false
      Specified by:
      setGeometry in class InterfaceShape
      Returns:
    • getVertexShape

      public NodeShape getVertexShape()
    • setVertexShape

      public void setVertexShape​(NodeShape shape)
    • isLabelShape

      public boolean isLabelShape()
    • getVertexCount

      public int getVertexCount()
      Description copied from class: InterfaceShape
      Returns the number of vertices defining the geometry of this shape.
      Specified by:
      getVertexCount in class InterfaceShape
      Returns:
    • getDimensions

      public int[] getDimensions()
      Description copied from interface: VariableObject
      Returns the dimensions of this object as an array of integers
      Specified by:
      getDimensions in interface VariableObject
      Returns:
      the dimensions of this object
    • getVertices

      public java.util.ArrayList<org.jogamp.vecmath.Point2f> getVertices()
    • getVertex

      public org.jogamp.vecmath.Point2f getVertex​(int i)
    • hasParentShape

      public boolean hasParentShape()
      Description copied from class: InterfaceShape
      Is this shape a child of another shape? Usually this refers to shapes which produce themselves in a different dimensionality; e.g., a 3D shape represented on a 2D plane.
      Specified by:
      hasParentShape in class InterfaceShape
      Returns:
    • getModifiedAttribute

      public Attribute<?> getModifiedAttribute()
      Specified by:
      getModifiedAttribute in class InterfaceShape
    • getVertexSelection

      public VertexSelection getVertexSelection()
      TODO: implement me
      Specified by:
      getVertexSelection in class InterfaceShape
    • setVertexSelection

      public void setVertexSelection​(VertexSelection selection)
      Specified by:
      setVertexSelection in class InterfaceShape
    • getClosestVertex

      public int getClosestVertex​(org.jogamp.vecmath.Point2f point)
      Returns the index of the vertex in this shape which is closest to point.
      Parameters:
      point -
      Returns:
    • getClosestVertex3D

      public int getClosestVertex3D​(org.jogamp.vecmath.Point2f point, Plane3D plane)
      If this shape has a parent Shape3DInt object, this method calls the getClosestVertex method of the parent.
      Parameters:
      point - The point to test
      plane - The plane on which this 2D object is described
      Returns:
    • setIcon

      protected void setIcon()
      Overrides:
      setIcon in class InterfaceShape
    • getTreeLabel

      public java.lang.String getTreeLabel()
      Description copied from interface: TreeObject
      Returns the label text to appear in a tree node.
      Specified by:
      getTreeLabel in interface TreeObject
      Overrides:
      getTreeLabel in class AbstractInterfaceObject
      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 AbstractInterfaceObject
    • destroy

      public void destroy​(ShapeEvent event)
    • getParentShape

      public Shape3DInt getParentShape()
    • setChild3D

      public void setChild3D​(Shape3DInt child)
    • getChild3D

      public Shape3DInt getChild3D()
    • getShape3DInt

      public Shape3DInt getShape3DInt​(Plane3D plane)
      Returns a 3D representation of this shape, assuming it belongs to plane.
      Parameters:
      plane - Plane which gives this shape 3D coordinates
      Returns:
      The 3D representation
    • getShape3DInt

      public Shape3DInt getShape3DInt​(Plane3D plane, boolean set_parent)
      Returns a 3D representation of this shape, assuming it belongs to plane.
      Parameters:
      plane - Plane which gives this shape 3D coordinates
      set_parent - Whether to register this shape as a parent on the issued shape
      Returns:
      The 3D representation
    • getShape3D

      protected Shape3DInt getShape3D​(Plane3D plane)
    • setParentShape

      public void setParentShape​(Shape3DInt shape)
    • getCenterPoint

      public org.jogamp.vecmath.Point2f getCenterPoint()
    • drawShape2D

      public void drawShape2D​(java.awt.Graphics2D g, DrawingEngine d)
      Description copied from class: InterfaceShape
      ABSTRACT METHODS
      Specified by:
      drawShape2D in class InterfaceShape
    • draw

      protected void draw​(java.awt.Graphics2D g, DrawingEngine d)
    • needsRedraw

      public boolean needsRedraw​(Attribute<?> a)
      Description copied from class: InterfaceShape
      Returns true if a change to attribute will require a redraw of this shape.
      Specified by:
      needsRedraw in class InterfaceShape
      Returns:
    • fireShapeListeners

      public void fireShapeListeners​(ShapeEvent e)
      Overrides:
      fireShapeListeners in class InterfaceShape
    • isHeritableAttribute

      public boolean isHeritableAttribute​(java.lang.String name)
      Description copied from class: InterfaceShape
      Is this parent attribute inherited by a child shape?
      Specified by:
      isHeritableAttribute in class InterfaceShape
      Returns:
    • isInheritingAttribute

      public boolean isInheritingAttribute​(Attribute<?> attribute)
      Description copied from class: InterfaceShape
      Does this child attribute inherit values from a parent shape?
      Specified by:
      isInheritingAttribute in class InterfaceShape
      Returns:
    • getLabelFont

      public java.awt.Font getLabelFont()
      Specified by:
      getLabelFont in class InterfaceShape
    • setLabelFont

      public void setLabelFont​(java.awt.Font font)
      Specified by:
      setLabelFont in class InterfaceShape
    • getLabelScale

      public float getLabelScale()
      Specified by:
      getLabelScale in class InterfaceShape
    • setLabelScale

      public void setLabelScale​(float scale)
      Specified by:
      setLabelScale in class InterfaceShape
    • getLabelColour

      public java.awt.Color getLabelColour()
      Specified by:
      getLabelColour in class InterfaceShape
    • setLabelColour

      public void setLabelColour​(java.awt.Color colour)
      Specified by:
      setLabelColour in class InterfaceShape
    • hasAlpha

      public boolean hasAlpha()
      Description copied from class: InterfaceShape
      Queries whether this shape has transparency.
      Specified by:
      hasAlpha in class InterfaceShape
      Returns:
    • hasAlpha

      public void hasAlpha​(boolean b)
      Description copied from class: InterfaceShape
      Specifies whether this shape has transparency.
      Specified by:
      hasAlpha in class InterfaceShape
    • showVertices

      public boolean showVertices()
      Description copied from class: InterfaceShape
      Queries whether the vertices of this shape are visible.
      Specified by:
      showVertices in class InterfaceShape
      Returns:
    • showVertices

      public void showVertices​(boolean b)
      Description copied from class: InterfaceShape
      Specifies whether the vertices of this shape are visible.
      Specified by:
      showVertices in class InterfaceShape
    • getVertexScale

      public float getVertexScale()
      Description copied from class: InterfaceShape
      Returns the scale of this shape's vertices
      Specified by:
      getVertexScale in class InterfaceShape
      Returns:
    • getVertexColour

      public java.awt.Color getVertexColour()
      Description copied from class: InterfaceShape
      Returns the colour of this shape's vertices.
      Specified by:
      getVertexColour in class InterfaceShape
      Returns:
    • getAlpha

      public float getAlpha()
      Description copied from class: InterfaceShape
      Gets the current transparency level for this shape.
      Specified by:
      getAlpha in class InterfaceShape
      Returns:
    • setAlpha

      public void setAlpha​(float f)
      Description copied from class: InterfaceShape
      Sets the current transparency level for this shape.
      Specified by:
      setAlpha in class InterfaceShape
    • getLineColour

      public java.awt.Color getLineColour()
      Description copied from class: InterfaceShape
      Returns the colour of this shape's lines/edges.
      Specified by:
      getLineColour in class InterfaceShape
      Returns:
    • getLineStyle

      public java.awt.Stroke getLineStyle()
      Description copied from class: InterfaceShape
      Returns the line/edge style for this shape.
      Specified by:
      getLineStyle in class InterfaceShape
      Returns:
    • setLineStyle

      public void setLineStyle​(java.awt.Stroke s)
      Description copied from class: InterfaceShape
      Returns the line/edge style for this shape.
      Specified by:
      setLineStyle in class InterfaceShape
    • setShape

      public void setShape​(Shape2D newShape)
    • getShape

      public Shape2D getShape()
    • getBoundShape

      public Shape getBoundShape()
    • getBounds

      public Rect2D getBounds()
    • getExtBounds

      public Rect2D getExtBounds()
    • getProximity

      public double getProximity​(org.jogamp.vecmath.Point2f thisPoint)
    • 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
    • getVisibility

      @Deprecated public boolean getVisibility()
      Deprecated.
    • issueTreeNode

      public InterfaceTreeNode issueTreeNode()
      Description copied from class: AbstractInterfaceObject
      Issues a new tree node and sets it using AbstractInterfaceObject.setTreeNode(mgui.interfaces.trees.InterfaceTreeNode). The tree node is stored in this object, which facilitates their destruction when necessary (e.g., when this object is destroyed). All issued tree nodes can informed of changes to their user object using the method AbstractInterfaceObject.updateTreeNodes().
      Specified by:
      issueTreeNode in interface TreeObject
      Overrides:
      issueTreeNode in class AbstractInterfaceObject
      Returns:
      a new InterfaceTreeNode
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode treeNode)
      Description copied from class: InterfaceShape
      Constructs a tree node from this shape. Adds an AttributeTreeNode via the super method, and also adds a node to display the vertex-wise data columns associated with this ShapeInt.

      If overriding this method, subclass implementations should first call this super method to initialize the node and provide a basic construction.

      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class InterfaceShape
      Parameters:
      treeNode - the tree node to construct
    • updateShape

      public void updateShape()
      Specified by:
      updateShape in class InterfaceShape
    • validateNodes

      public boolean validateNodes()
    • printNodes

      public java.lang.String printNodes()
    • contains

      public boolean contains​(org.jogamp.vecmath.Point2f thisPoint)
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • clone

      public java.lang.Object clone()
      Overrides:
      clone in class java.lang.Object
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Responds to a change in a specific attribute by notifying this ShapeInt's shape listeners with an AttributeModified shape event. If overriding, this super method should be called AFTER the special handling has been performed.
      Specified by:
      attributeUpdated in interface AttributeListener
    • 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:
    • 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
      Overrides:
      writeXML in class InterfaceShape
      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
    • writeShapeToXML

      protected void writeShapeToXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar, XMLObject.XMLType type) throws java.io.IOException
      Throws:
      java.io.IOException
    • 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:
    • 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 InterfaceShape
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu​(java.util.List<java.lang.Object> selected)
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object. Allows an associated list of objects to be passed as an argument.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • setGraphic2DPopupMenu

      public void setGraphic2DPopupMenu​(InterfacePopupMenu menu)
      Subclasses should override this if necessary and call super.getGraphic3DPopupMenu() to get this top-level menu and add items to it.
    • 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
    • showPopupMenu

      public void showPopupMenu​(java.awt.event.MouseEvent e)
      Description copied from interface: PopupMenuObject
      Shows a popup menu at the point of the given MouseEvent.
      Specified by:
      showPopupMenu in interface PopupMenuObject
    • getTransferData

      public java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
      Specified by:
      getTransferData in interface java.awt.datatransfer.Transferable
      Throws:
      java.awt.datatransfer.UnsupportedFlavorException
      java.io.IOException
    • getTransferDataFlavors

      public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
      Specified by:
      getTransferDataFlavors in interface java.awt.datatransfer.Transferable
    • isDataFlavorSupported

      public boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor flavor)
      Specified by:
      isDataFlavorSupported in interface java.awt.datatransfer.Transferable
    • performTransfer

      public boolean performTransfer​(javax.swing.TransferHandler.TransferSupport support)
      Specified by:
      performTransfer in interface InterfaceTransferable
    • getVertexDataColumnNames

      public java.util.ArrayList<java.lang.String> getVertexDataColumnNames()
      Description copied from class: InterfaceShape
      Returns a list of the names of all vertex data columns.
      Overrides:
      getVertexDataColumnNames in class InterfaceShape
      Returns:
    • getVertexDataColumns

      public java.util.ArrayList<VertexDataColumn> getVertexDataColumns()
      Description copied from class: InterfaceShape
      Returns a list of all vertex data columns.
      Overrides:
      getVertexDataColumns in class InterfaceShape
      Returns:
    • getVertexDataColumn

      public VertexDataColumn getVertexDataColumn​(java.lang.String name)
      Description copied from class: InterfaceShape
      Returns the vertex data column associated with name.
      Overrides:
      getVertexDataColumn in class InterfaceShape
      Parameters:
      name - Name of the vertex data column
      Returns:
    • addVertexData

      public boolean addVertexData​(java.lang.String key, java.util.ArrayList<MguiNumber> data)
      Description copied from class: InterfaceShape
      Adds a new vertex data column and populates it with data.
      Overrides:
      addVertexData in class InterfaceShape
      Returns:
    • addVertexData

      public boolean addVertexData​(java.lang.String key, java.util.ArrayList<MguiNumber> data, NameMap map)
      Description copied from class: InterfaceShape
      Adds vertex-wise data to this shape.
      Overrides:
      addVertexData in class InterfaceShape
      Parameters:
      key - The key by which this column is to be referred
      data - The values for this column
      map - Name map [optionally null] associating integer keys to names
      Returns:
    • addVertexData

      public boolean addVertexData​(java.lang.String key)
      Description copied from class: InterfaceShape
      Add a vertex-wise data column of type DataBuffer.TYPE_DOUBLE.
      Overrides:
      addVertexData in class InterfaceShape
      Parameters:
      key - The key associated with the data column
    • addVertexData

      public boolean addVertexData​(java.lang.String key, int dataType)
      Description copied from class: InterfaceShape
      Add a vertex-wise data column of type dataType, which must be one of DataBuffer.TYPE_DOUBLE, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_INT. If an incorrect type is specified, this method creates a column of type DataBuffer.TYPE_DOUBLE.
      Overrides:
      addVertexData in class InterfaceShape
      Parameters:
      key - The key associated with the data column
      dataType - The data type with which to store the data
    • removeVertexData

      public void removeVertexData​(java.lang.String key)
      Description copied from class: InterfaceShape
      Remove a vertex data column from this shape. This also removes all associated data, and calls listeners to update, for instance, tree nodes.
      Overrides:
      removeVertexData in class InterfaceShape
    • getCurrentColumn

      public java.lang.String getCurrentColumn()
      Description copied from class: InterfaceShape
      Returns the name of the current data column
      Overrides:
      getCurrentColumn in class InterfaceShape
      Returns:
    • getVertexDataMap

      public java.util.HashMap<java.lang.String,​java.util.ArrayList<MguiNumber>> getVertexDataMap()
      Description copied from class: InterfaceShape
      Retrieves a hash map containing the vertex-wise data associated with this shape.
      Overrides:
      getVertexDataMap in class InterfaceShape
      Returns:
    • setVertexDataMap

      public void setVertexDataMap​(java.util.HashMap<java.lang.String,​java.util.ArrayList<MguiNumber>> data)
      Description copied from class: InterfaceShape
      Sets the hash map specified the vertex-wise data associated with this shape.
      Overrides:
      setVertexDataMap in class InterfaceShape
    • getCurrentVertexData

      public java.util.ArrayList<MguiNumber> getCurrentVertexData()
      Description copied from class: InterfaceShape
      Retrieves the currently selected vertex-wise data column.
      Overrides:
      getCurrentVertexData in class InterfaceShape
    • getLinkedVertexDatum

      public MguiNumber getLinkedVertexDatum​(java.lang.String linked_column, int index)
      Description copied from class: InterfaceShape
      Returns the value at the given vertex, for the given linked column.
      Overrides:
      getLinkedVertexDatum in class InterfaceShape
      Returns:
    • getLinkedVertexData

      public java.util.ArrayList<MguiNumber> getLinkedVertexData​(java.lang.String linked_column)
      Description copied from class: InterfaceShape
      Retrieves the vertex-wise data associated with a data-linked column.
      Overrides:
      getLinkedVertexData in class InterfaceShape
      Returns:
    • hasColumn

      public boolean hasColumn​(java.lang.String s)
      Overrides:
      hasColumn in class InterfaceShape
    • setCurrentColumn

      public void setCurrentColumn​(java.lang.String key)
      Overrides:
      setCurrentColumn in class InterfaceShape
    • setCurrentColumn

      public void setCurrentColumn​(java.lang.String key, boolean update)
      Overrides:
      setCurrentColumn in class InterfaceShape
    • getVertexData

      public java.util.ArrayList<MguiNumber> getVertexData​(java.lang.String column)
      Description copied from class: InterfaceShape
      Returns a live version of the data in column.
      Overrides:
      getVertexData in class InterfaceShape
      Returns:
    • getAllVertexData

      public java.util.ArrayList<java.util.ArrayList<MguiNumber>> getAllVertexData()
      Description copied from class: InterfaceShape
      Returns all vertex-wide data associated with this shape.
      Overrides:
      getAllVertexData in class InterfaceShape
      Returns:
    • getDatumAtVertex

      public MguiNumber getDatumAtVertex​(java.lang.String column, int index)
      Description copied from class: InterfaceShape
      Returns the datum from column at index.
      Overrides:
      getDatumAtVertex in class InterfaceShape
      Returns:
    • hasData

      public boolean hasData()
      Overrides:
      hasData in class InterfaceShape
    • getNonLinkedDataColumns

      public java.util.ArrayList<java.lang.String> getNonLinkedDataColumns()
      Description copied from class: InterfaceShape
      Returns a list of this shape's data columns, minus the linked columns.
      Overrides:
      getNonLinkedDataColumns in class InterfaceShape
      Returns:
    • updateDataColumns

      protected void updateDataColumns()
      Overrides:
      updateDataColumns in class InterfaceShape