Package mgui.interfaces.graphics
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 mgui.interfaces.InterfacePanel
attributes, displayListeners, isDestroyed, last_click_point, statusBar, tree_nodes, treeNode, type
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 theIcon
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 barprotected 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 bytool
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>
booleansetCurrentTool(E tool)
<E extends T>
booleansetDefaultTool(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, asXMLType.Normal
.Methods inherited from class mgui.interfaces.InterfacePanel
_init, addDisplayListener, attributeUpdated, clean, cleanUpPanel, collapseAllCategories, collapseCategory, collapseOtherCategories, componentHidden, componentMoved, componentResized, componentShown, destroy, expandAllCategories, expandCategory, fireDisplayListeners, getAttribute, getAttributes, getAttributeValue, getLocalAttributes, getPopupMenu, getSource, getTitle, getTreeLabel, getType, isDestroyed, issueTreeNode, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, removeDisplayListener, setAttribute, setAttributes, setSource, setTreeNode, setType, shapeUpdated, showPanel, showPopupMenu, updateDisplay, updateDisplays, updateFromDialog, updateTreeNodes
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
Methods inherited from interface mgui.interfaces.xml.XMLObject
getDTD, getLocalName, getShortXML, getXML, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, writeXML
-
Field Details
-
status_listeners
-
status_map
-
toolInputAdapter
-
excludeToSelection
public boolean excludeToSelection -
theMap
-
init_once
protected boolean init_once -
graphic_listeners
-
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 theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Overrides:
getObjectIcon
in classInterfacePanel
- Returns:
-
compareTo
-
init
protected void init()- Specified by:
init
in classInterfacePanel
-
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
- Specified by:
toolStateChanged
in interfaceToolListener
-
toolDeactivated
- Specified by:
toolDeactivated
in interfaceToolListener
-
addGraphicListener
-
removeGraphicListener
-
fireGraphicListeners
protected void fireGraphicListeners() -
getTypeStr
-
getType
-
getSourceTypes
-
addMouseListener
- Specified by:
addMouseListener
in interfaceInterfaceMouseObject
-
removeMouseListener
- Specified by:
removeMouseListener
in interfaceInterfaceMouseObject
-
setExcludeToSelection
public void setExcludeToSelection(boolean ex) -
getMap
-
setMap
-
mapUpdated
- Specified by:
mapUpdated
in interfaceMapListener
-
isDisplayable
public boolean isDisplayable(java.lang.Object obj) -
setStatusBar
- Overrides:
setStatusBar
in classInterfacePanel
-
updateStatusBox
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
-
removeMouseObject
-
getName
public java.lang.String getName()Description copied from interface:NamedObject
Gets the name for this object.- Specified by:
getName
in interfaceNamedObject
- Overrides:
getName
in classjava.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 interfaceNamedObject
- Overrides:
setName
in classjava.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
-
getPopupMenu
Description copied from interface:PopupMenuObject
Produces and returns a popup menu for this object.- Specified by:
getPopupMenu
in interfacePopupMenuObject
- Overrides:
getPopupMenu
in classInterfacePanel
- 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 interfacePopupMenuObject
- Overrides:
handlePopupEvent
in classInterfacePanel
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
in classInterfacePanel
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseDragged
in classInterfacePanel
-
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.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. -
getCurrentTool
- Specified by:
getCurrentTool
in interfaceToolable<T extends Tool>
-
setTool
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 bytool
.
-
setCurrentTool
- Specified by:
setCurrentTool
in interfaceToolable<T extends Tool>
-
setDefaultTool
- Specified by:
setDefaultTool
in interfaceToolable<T extends Tool>
-
isToolable
Description copied from interface:Toolable
Tests whether this object is toolable bytool
- Specified by:
isToolable
in interfaceToolable<T extends Tool>
- Returns:
-