Package mgui.interfaces.shapes
Class ShapeModel3D
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.shapes.ShapeModel3D
- All Implemented Interfaces:
java.awt.datatransfer.Transferable
,DisplayPanelListener
,InterfaceGraphicListener
,WindowListener
,InterfaceObject
,PopupMenuObject
,NamedObject
,ShapeSelectionListener
,ShapeListener
,InterfaceTransferable
,TreeObject
,TreeKeyHandler
,CleanableObject
,XMLObject
,IconObject
public class ShapeModel3D extends AbstractInterfaceObject implements ShapeListener, InterfaceObject, WindowListener, InterfaceGraphicListener, XMLObject, ShapeSelectionListener, DisplayPanelListener, IconObject, PopupMenuObject, TreeKeyHandler, InterfaceTransferable
The top container for all shape interfaces.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected SpatialUnit
default_unit
protected InterfaceDisplayPanel
displayPanel
protected boolean
excludeToSelection
protected ShapeSelectionSet
exclusionFilter
protected boolean
is_live3d
protected org.jogamp.java3d.Locale
locale
protected java.util.ArrayList<ShapeModel3DListener>
model_listeners
protected Shape3DSceneNode
model_node
protected ShapeSet3DInt
modelSet
protected java.util.HashMap<InterfaceGraphic2D,Polygon3DInt>
section_polygons
protected org.jogamp.java3d.BranchGroup
sections_node
java.util.ArrayList<ShapeSelectionSet>
selections
protected javax.swing.tree.DefaultMutableTreeNode
selectionSetNode
protected java.util.ArrayList<ShapeListener>
shape_listeners
protected java.util.ArrayList<ShapeSelectionListener>
slisteners
protected org.jogamp.java3d.BranchGroup
temp_shapes
protected org.jogamp.java3d.VirtualUniverse
universe
protected ShapeSelectionSet
working_selection
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
Constructors Constructor Description ShapeModel3D()
ShapeModel3D(java.lang.String name)
ShapeModel3D(java.lang.String name, ShapeSet3DInt set)
ShapeModel3D(java.lang.String name, ShapeSet3DInt set, SpatialUnit default_unit)
-
Method Summary
Modifier and Type Method Description void
addGraphics3D(InterfaceGraphic3D g)
void
addModelListener(ShapeModel3DListener s)
void
addSelectionListener(ShapeSelectionListener s)
void
addSelectionSet(ShapeSelectionSet selSet)
void
addShapeListener(ShapeListener s)
void
addTempShape(org.jogamp.java3d.BranchGroup shape)
protected void
cleanTreeNodes()
void
clearTempShapes()
void
clearWorkingSelection()
void
destroy()
Destroy this object (prepare it to be removed from memory)void
displayPanelChanged(DisplayPanelEvent e)
protected void
fireModelListeners(ShapeModelEvent e)
protected void
fireSelectionListeners(ShapeSelectionEvent e)
protected void
fireShapeListeners(ShapeEvent e)
SpatialUnit
getDefaultUnit()
Returns the default spatial unit for this shape modelInterfaceDisplayPanel
getDisplayPanel()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationboolean
getExcludeToSelection()
ShapeSelectionSet
getExclusionFilter()
org.jogamp.java3d.Locale
getLocale()
java.lang.String
getLocalName()
Returns the local name associated with this XML object.org.jogamp.java3d.BranchGroup
getModel()
ShapeSet3DInt
getModelSet()
long
getNextID()
javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.InterfacePopupMenu
getPopupMenu()
Produces and returns a popup menu for this object.InterfacePopupMenu
getPopupMenu(java.util.List<java.lang.Object> selection)
Produces and returns a popup menu for this object.ShapeSelectionSet
getSelectionSet(java.lang.String name)
protected javax.swing.tree.DefaultMutableTreeNode
getSelectionSetNode()
java.util.ArrayList<ShapeSelectionSet>
getSelectionSets()
Returns a list of this model's selection sets, including its working set.java.util.ArrayList<ShapeSelectionSet>
getSelectionSets(InterfaceShape thisShape)
java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.java.lang.Object
getTransferData(java.awt.datatransfer.DataFlavor flavor)
java.awt.datatransfer.DataFlavor[]
getTransferDataFlavors()
InterfaceTreeNode
getTreeNodeCopy()
ShapeSelectionSet
getWorkingSelection()
Returns the working selection set for this model.java.lang.String
getXML()
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab, XMLObject.XMLType type)
java.lang.String
getXMLSchema()
Returns the XML schema for this object's XML representationvoid
graphicSourceChanged(GraphicEvent e)
void
graphicUpdated(GraphicEvent e)
void
handlePopupEvent(java.awt.event.ActionEvent e)
Handles an event on this object's popup menu.void
handleTreeKeyEvent(java.awt.event.KeyEvent event)
Handle the keyevent
on this object's tree node.void
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.void
handleXMLString(java.lang.String s)
Handles a string within an XML element.boolean
hasSelectionSet(ShapeSelectionSet selSet)
boolean
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
boolean
isDestroyed()
Test whether this object has been destroyedboolean
isLive3D()
Indicates whether this model has a live 3D nodeInterfaceTreeNode
issueTreeNode()
Issues a new tree node and sets it usingAbstractInterfaceObject.setTreeNode(mgui.interfaces.trees.InterfaceTreeNode)
.boolean
performTransfer(javax.swing.TransferHandler.TransferSupport support)
void
refreshModel()
Updates this model by setting its shape scene node.void
removeGraphics3D(InterfaceGraphic3D g)
void
removeModelListener(ShapeModel3DListener s)
void
removeSelectionListener(ShapeSelectionListener s)
void
removeSelectionSet(ShapeSelectionSet selSet)
void
removeShapeListener(ShapeListener s)
void
removeTempShape(org.jogamp.java3d.BranchGroup shape)
boolean
setDefaultUnit(java.lang.String name)
Sets the default spatial unit for this model.void
setDisplayPanel(InterfaceDisplayPanel panel)
void
setExcludeToSelection(boolean b)
void
setExclusionFilter(java.lang.String selStr)
void
setExclusionFilter(ShapeSelectionSet selSet)
void
setExclusionFilter(ShapeSelectionSet selSet, boolean update)
void
setModelSet(ShapeSet3DInt set)
void
setName(java.lang.String name)
Sets the name for this object.protected void
setSectionsNode()
Sets theBranchGroup
which visualizes the 2D windows which have section sets as their source which are members of this model.void
setSelectionSets(java.util.ArrayList<ShapeSelectionSet> sets)
void
setTreeNode()
void
setTreeNode(InterfaceTreeNode treeNode)
Sets the children for this node'sInterfaceTreeNode
.void
shapeSelectionChanged(ShapeSelectionEvent e)
void
shapeUpdated(ShapeEvent e)
A shape that this object is listening to has been updated.void
showPopupMenu(java.awt.event.MouseEvent e)
Shows a popup menu at the point of the givenMouseEvent
.java.lang.String
toString()
void
windowSourceChanged(WindowEvent e)
void
windowUpdated(WindowEvent e)
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, asXMLType.Normal
.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes the XML representation of this object to file.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar, java.io.File root_dir)
Writes this model to an XML writer, setting the specified root directory.Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, getName, getTreeLabel, updateTreeNodes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mgui.interfaces.util.CleanableObject
clean
Methods inherited from interface mgui.interfaces.NamedObject
getName
Methods inherited from interface mgui.interfaces.trees.TreeObject
getTreeLabel
-
Field Details
-
universe
protected org.jogamp.java3d.VirtualUniverse universe -
locale
protected org.jogamp.java3d.Locale locale -
model_node
-
sections_node
protected org.jogamp.java3d.BranchGroup sections_node -
section_polygons
-
modelSet
-
shape_listeners
-
model_listeners
-
selections
-
slisteners
-
exclusionFilter
-
excludeToSelection
protected boolean excludeToSelection -
selectionSetNode
protected javax.swing.tree.DefaultMutableTreeNode selectionSetNode -
displayPanel
-
temp_shapes
protected org.jogamp.java3d.BranchGroup temp_shapes -
is_live3d
protected boolean is_live3d -
default_unit
-
working_selection
-
-
Constructor Details
-
ShapeModel3D
public ShapeModel3D() -
ShapeModel3D
public ShapeModel3D(java.lang.String name) -
ShapeModel3D
-
ShapeModel3D
-
-
Method Details
-
isLive3D
public boolean isLive3D()Indicates whether this model has a live 3D node- Returns:
-
setName
public void setName(java.lang.String name)Description copied from interface:NamedObject
Sets the name for this object.- Specified by:
setName
in interfaceNamedObject
- Overrides:
setName
in classAbstractInterfaceObject
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Returns:
-
getDefaultUnit
Returns the default spatial unit for this shape model- Returns:
-
getWorkingSelection
Returns the working selection set for this model.- Returns:
-
clearWorkingSelection
public void clearWorkingSelection() -
setDefaultUnit
public boolean setDefaultUnit(java.lang.String name)Sets the default spatial unit for this model.- Parameters:
name
-- Returns:
-
setDisplayPanel
-
getDisplayPanel
-
displayPanelChanged
- Specified by:
displayPanelChanged
in interfaceDisplayPanelListener
-
addTempShape
public void addTempShape(org.jogamp.java3d.BranchGroup shape) -
removeTempShape
public void removeTempShape(org.jogamp.java3d.BranchGroup shape) -
clearTempShapes
public void clearTempShapes() -
shapeSelectionChanged
- Specified by:
shapeSelectionChanged
in interfaceShapeSelectionListener
-
setModelSet
-
showPopupMenu
public void showPopupMenu(java.awt.event.MouseEvent e)Description copied from interface:PopupMenuObject
Shows a popup menu at the point of the givenMouseEvent
.- Specified by:
showPopupMenu
in interfacePopupMenuObject
-
getPopupMenu
Description copied from interface:PopupMenuObject
Produces and returns a popup menu for this object.- Specified by:
getPopupMenu
in interfacePopupMenuObject
- Returns:
-
getPopupMenu
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 interfacePopupMenuObject
- Returns:
-
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 interfacePopupMenuObject
-
handleTreeKeyEvent
public void handleTreeKeyEvent(java.awt.event.KeyEvent event)Description copied from interface:TreeKeyHandler
Handle the keyevent
on this object's tree node.- Specified by:
handleTreeKeyEvent
in interfaceTreeKeyHandler
-
getNextID
public long getNextID() -
refreshModel
public void refreshModel()Updates this model by setting its shape scene node. Filters the model shape set ifexcludeToSelection
is true. -
setSectionsNode
protected void setSectionsNode()Sets theBranchGroup
which visualizes the 2D windows which have section sets as their source which are members of this model. -
getLocale
public org.jogamp.java3d.Locale getLocale() -
setExcludeToSelection
public void setExcludeToSelection(boolean b) -
getExcludeToSelection
public boolean getExcludeToSelection() -
setExclusionFilter
public void setExclusionFilter(java.lang.String selStr) -
setExclusionFilter
-
setExclusionFilter
-
getExclusionFilter
-
hasSelectionSet
-
getSelectionSets
Returns a list of this model's selection sets, including its working set.- Returns:
-
getSelectionSet
-
getSelectionSets
-
getModelSet
-
addGraphics3D
-
removeGraphics3D
-
getModel
public org.jogamp.java3d.BranchGroup getModel() -
issueTreeNode
Description copied from class:AbstractInterfaceObject
Issues a new tree node and sets it usingAbstractInterfaceObject.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 methodAbstractInterfaceObject.updateTreeNodes()
.- Specified by:
issueTreeNode
in interfaceTreeObject
- Overrides:
issueTreeNode
in classAbstractInterfaceObject
- Returns:
- a new
InterfaceTreeNode
-
setTreeNode
public void setTreeNode() -
setTreeNode
Description copied from interface:TreeObject
Sets the children for this node'sInterfaceTreeNode
.- Specified by:
setTreeNode
in interfaceTreeObject
- Overrides:
setTreeNode
in classAbstractInterfaceObject
-
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)- Specified by:
isDataFlavorSupported
in interfacejava.awt.datatransfer.Transferable
-
getTransferDataFlavors
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()- Specified by:
getTransferDataFlavors
in interfacejava.awt.datatransfer.Transferable
-
performTransfer
public boolean performTransfer(javax.swing.TransferHandler.TransferSupport support)- Specified by:
performTransfer
in interfaceInterfaceTransferable
-
getTransferData
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException- Specified by:
getTransferData
in interfacejava.awt.datatransfer.Transferable
- Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
-
cleanTreeNodes
protected void cleanTreeNodes() -
getSelectionSetNode
protected javax.swing.tree.DefaultMutableTreeNode getSelectionSetNode() -
fireModelListeners
-
fireShapeListeners
-
fireSelectionListeners
-
addShapeListener
-
removeShapeListener
-
addModelListener
-
removeModelListener
-
addSelectionListener
-
removeSelectionListener
-
shapeUpdated
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 interfaceShapeListener
-
addSelectionSet
-
setSelectionSets
-
removeSelectionSet
-
graphicSourceChanged
- Specified by:
graphicSourceChanged
in interfaceInterfaceGraphicListener
-
graphicUpdated
- Specified by:
graphicUpdated
in interfaceInterfaceGraphicListener
-
windowUpdated
- Specified by:
windowUpdated
in interfaceWindowListener
-
destroy
public void destroy()Description copied from interface:InterfaceObject
Destroy this object (prepare it to be removed from memory)- Specified by:
destroy
in interfaceInterfaceObject
- Specified by:
destroy
in interfaceShapeListener
- Overrides:
destroy
in classAbstractInterfaceObject
-
isDestroyed
public boolean isDestroyed()Description copied from interface:InterfaceObject
Test whether this object has been destroyed- Specified by:
isDestroyed
in interfaceInterfaceObject
- Specified by:
isDestroyed
in interfaceShapeListener
- Overrides:
isDestroyed
in classAbstractInterfaceObject
- Returns:
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getTreeNodeCopy
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObject
Returns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObject
Returns the local name associated with this XML object.- Specified by:
getLocalName
in interfaceXMLObject
- 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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXML
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription 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 ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription 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 ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar, java.io.File root_dir) throws java.io.IOExceptionWrites this model to an XML writer, setting the specified root directory.- Parameters:
tab
-writer
-type
-progress_bar
-root_dir
-- 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 interfaceXMLObject
- Returns:
-
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- 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 interfaceXMLObject
- 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 interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
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 interfaceXMLObject
- Parameters:
s
- String to handle
-
windowSourceChanged
- Specified by:
windowSourceChanged
in interfaceWindowListener
-