com.swfm.mica.core
Class MiContainer

java.lang.Object
  extended bycom.swfm.mica.core.MiPart
      extended bycom.swfm.mica.core.MiContainer
All Implemented Interfaces:
MiiActionTypes, MiiAttributeTypes, MiiDragAndDropParticipant, MiiEventTypes, MiiNames, MiiPropertyTypes, MiiTypes
Direct Known Subclasses:
MiAttachments, MiClipBoard, MiEditor, MiGeneralAttributesPanel, MiGraphicsNode, MiImageCreationPanel, MiLayer, MiLayout, MiReference, MiShapeCreationPanel, MiSystemClipboard, MiTransactionManager

public class MiContainer
extends MiPart

This class is a MiPart that can contain other MiParts. The MiPart methods that can add, inquire and remove MiParts are implemented here.

Version:
%I% %G%
Author:
Michael L. Davis

Field Summary
                 
Constructor Summary
MiContainer()
          Constructs a new MiContainer.
 
Method Summary
 void appendPart(MiPart part)
          Appends the given part to this container.
 void calcMinimumSize(MiSize size)
          Gets the minimum size of this MiPart.
 void calcPreferredSize(MiSize size)
          Gets the preferred size of this MiPart.
 boolean containsPart(MiPart part)
          Gets whether the given part is in this container.
 MiPart deepCopy()
          Makes and returns a copy of this container and all of it's parts.
 void doImport(MiDataTransferOperation transfer)
          Import the data specified by the given data transfer operation.
 int getIndexOfPart(MiPart obj)
          Gets the index of the given part in this container.
 boolean getIntersectionWithLine(MiPoint insidePoint, MiPoint otherPoint, MiPoint returnedIntersectionPoint)
          Gets whether if there is an intersection between the line formed by the given points and the outer bounds of this MiPart.
 boolean getKeepConnectionsBelowNodes()
          Gets whether the connections are to be drawn before (behind) nodes.
 int getNumberOfParts()
          Gets the number of parts this container has.
 MiPart getPart(int index)
          Gets the part of this container at the given index.
 MiPart getPart(java.lang.String name)
          Gets the part of this container with the given name.
 java.lang.String[] getSupportedImportFormats()
          Gets list of data formats that this MiPart is able to import.
 boolean hasEventHandlers()
          Gets whether this MiPart or any of it's attachments or parts has event handlers assigned.
 boolean hasValidCachedEventHandlerInfo()
          Gets whether the cached information about the event handlers assigned to this MiPart and it's parts is valid.
 void insertPart(MiPart part, int index)
          Inserts the given part at the given index into this container.
 void invalidateCachedEventHandlerInfo()
          Invalidates the cached information about the event handlers assigned to this MiPart and it's containers.
 boolean isContainerOf(MiPart part)
          Gets whether the given part is in this container or in one of the parts of this container.
 MiPart isContainerOf(java.lang.String name)
          Gets the part with the given name in this container or in one of the parts of this container.
 MiPart isContainerOfWithAttachments(java.lang.String name)
           
 boolean pick(MiBounds area)
          Gets whether the given area intersects the bounds of this MiPart.
 void pickDeepListContents(MiBounds area, MiParts list)
          Gets the list of parts, not including this MiPart, whose bounds intersects the given area.
 MiPart pickObject(MiBounds area)
          Returns the top MiPart at the given area.
 void removeAllParts()
          Removes all parts from this container.
 void removePart(int index)
          Removes the part from this container at the given index.
 void removePart(MiPart part)
          Removes the given part from this container.
 void setKeepConnectionsBelowNodes(boolean flag)
          Sets whether the order of the MiParts in this container are kept such that MiConnections are at the begining of the list.
 void setPart(MiPart part, int index)
          Replaces the part at the given index with the given part.
 void translate(int partNum, MiVector vector)
          Translates a part of this container at the given index.
 
Methods inherited from class com.swfm.mica.core.MiPart
_reCalcBounds, _render, _replaceBounds, _setContainer, _setDrawManager, _setValidatingLayout, appendActionHandler, appendActionHandler, appendActionHandler, appendActionHandler, appendActionHandler, appendAttachment, appendAttachment, appendCommandHandler, appendCommandHandler, appendCommandHandler, appendConnection, appendContainer, appendEventHandler, appendItem, appendPoint, appendPoint, applyCustomLookAndFeel, containsItem, containsOpaqueRectangles, copy, copy, deleteAllConnections, deleteAllParts, deleteSelf, dispatchAction, dispatchAction, dispatchAction, dispatchActionRequest, dispatchActionRequest, dispatchActionRequest, dispatchEvent, doExport, draw, drawNow, drawNow, flip, flip, freeAccessLock, get1DShapeStrokeBackgroundColor, get1DShapeStrokesFilled, getAccessLock, getActionHandler, getActionsGenerated, getActionsLocallyGenerated, getActionsRequestedFromParts, getAfterRenderer, getAlphaCompositeRenderMode, getAnnotationPointManager, getAssociatedParts, getAttachment, getAttachment, getAttachmentMargins, getAttachments, getAttributeLockMask, getAttributePublicMask, getAttributes, getAttributeValue, getBackgroundColor, getBackgroundImage, getBackgroundRenderer, getBackgroundTile, getBalloonHelp, getBeforeRenderer, getBlackColor, getBorderHiliteColor, getBorderHiliteWidth, getBorderLook, getBorderRenderer, getBounds, getBounds, getCenter, getCenter, getCenterOfRotation, getCenterX, getCenterY, getColor, getConnection, getConnectionPointManager, getContainer, getContainerRequestedActions, getContainingEditor, getContainingWindow, getContextCursor, getContextMenu, getContextMenu, getControlPointManager, getCustomLookAndFeels, getCustomLookAndFeels, getDarkColor, getDeepConnection, getDeepConnection, getDeepConnections, getDeeplyInvalidateAreas, getDefaultAttributes, getDialogHelp, getDoubleBuffer, getDragAndDropBehavior, getDrawBounds, getDrawManager, getEventHandler, getEventHandler, getEventHandlerWithClass, getEventHandlingDisabledByContainer, getEventHandlingEnabled, getFlipped, getFont, getFontHorizontalJustification, getFontPointSize, getFontVerticalJustification, getHasBorderHilite, getHasShadow, getHeight, getID, getIncomingInvalidLayoutNotificationsEnabled, getIndexOfItem, getInnerBounds, getInnerBounds, getInvalidAreaNotificationsEnabled, getInvalidLayoutNotificationsEnabled, getItem, getItem, getKeyFocusTraversalGroup, getLayout, getLayoutManipulator, getLightColor, getLineEndSize, getLineEndsRenderer, getLineEndsSizeFnOfLineWidth, getLineEndStyle, getLineStartSize, getLineStartStyle, getLineStyle, getLineWidth, getLocallyRequestedEventTypes, getManipulator, getMargins, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumPickAreaSize, getMinimumSize, getMinimumWidth, getName, getNumberOfActionHandlers, getNumberOfAttachments, getNumberOfConnections, getNumberOfContainers, getNumberOfDeepConnections, getNumberOfEventHandlers, getNumberOfItems, getNumberOfPoints, getNumberOfResources, getOutgoingInvalidLayoutNotificationsEnabled, getPoint, getPoint, getPointEntryAngle, getPointExitAngle, getPointX, getPointY, getPreferredSize, getPropertyDescriptions, getPropertyValue, getPrototypeManipulator, getRelativeLocation, getResource, getResourceName, getRootWindow, getRotation, getSelectionGraphics, getShadowColor, getShadowDirection, getShadowLength, getShadowRenderer, getShadowShape, getShadowStyle, getSize, getSnapPointManager, getStatusHelp, getSupportedExportFormats, getThisOrPartHasInvalidArea, getToolHintHelp, getTotalNumberOfPartsCreated, getTransform, getTransparency, getValidatingLayout, getVisibilityAnimator, getWhiteColor, getWidth, getWriteMode, getXmax, getXmin, getXorColor, getYmax, getYmin, hasAttachment, hasAttribute, hasEnterKeyFocus, hasEventHandler, hasFixedAspectRatio, hasFixedHeight, hasFixedWidth, hasKeyboardFocus, hasMouseFocus, hasOverriddenMinimumSize, hasOverriddenPreferredSize, hasProperty, hasTotallyInvalidArea, hasValidLayout, insertActionHandler, insertActionHandler, insertActionHandler, insertConnection, insertContainer, insertEventHandler, insertItem, insertPoint, insertPoint, invalidateArea, invalidateArea, invalidateLayout, isAcceptingEnterKeyFocus, isAcceptingKeyboardFocus, isAcceptingMouseFocus, isAcceptingTabKeys, isActionDispatchingEnabled, isConnectable, isConnectedTo, isCopyable, isCopyableAsPartOfCopyable, isDeletable, isDoubleBuffered, isDragAndDropSource, isDragAndDropTarget, isFilled, isFontBold, isFontItalic, isFontUnderlined, isHidden, isMovable, isOpaqueRectangle, isPickable, isPickableWhenTransparent, isPrintable, isSavable, isSelectable, isSelected, isSensitive, isShowing, isSnappable, isUngroupable, isValidConnectionDestination, isValidConnectionSource, isVisible, layoutParts, makeImageFromArea, makeLayoutManipulator, makeManipulator, optimizedInvalidateArea, optimizedInvalidateDrawBoundsArea, overrideAttributes, overrideEventHandlingDisabledByContainer, packLayout, pickDeepList, preRenderToDoubleBuffer, refreshBounds, refreshLookAndFeel, refreshLookAndFeel, removeActionHandler, removeActionHandler, removeActionHandlers, removeAllActionHandlers, removeAllAttachments, removeAllConnections, removeAllEventHandlers, removeAllItems, removeAllManipulators, removeAttachment, removeAttachment, removeCommandHandler, removeCommandHandler, removeConnection, removeConnection, removeContainer, removeContainer, removeEventHandler, removeFromAllContainers, removeItem, removeItem, removePoint, removeResource, removeSelf, replaceDrawBounds, replaceSelf, requestEnterKeyFocus, requestKeyboardFocus, rotate, rotate, rotateTo, scale, scale, scale, select, set1DShapeStrokeBackgroundColor, set1DShapeStrokesFilled, setAcceptingEnterKeyFocus, setAcceptingKeyboardFocus, setAcceptingMouseFocus, setAcceptingTabKeys, setActionDispatchingEnabled, setAfterRenderer, setAlphaCompositeRenderMode, setAnnotationPointManager, setAttachmentDrawnAfter, setAttachmentMargins, setAttachmentsVisibility, setAttributeLockMask, setAttributePublicMask, setAttributes, setAttributeValue, setAttributeValue, setAttributeValue, setAttributeValue, setAttributeValue, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundRenderer, setBackgroundTile, setBalloonHelp, setBalloonHelpMessage, setBeforeRenderer, setBlackColor, setBorderHiliteColor, setBorderHiliteWidth, setBorderLook, setBorderRenderer, setBounds, setBounds, setCenter, setCenter, setCenterX, setCenterY, setColor, setColor, setConnectable, setConnectionPointManager, setContextCursor, setContextMenu, setControlPointManager, setCopyable, setCopyableAsPartOfCopyable, setCustomLookAndFeels, setCustomLookAndFeels, setDarkColor, setDeeplyInvalidateAreas, setDefaultAttributes, setDeletable, setDialogHelp, setDialogHelpMessage, setDoubleBuffer, setDoubleBuffered, setDragAndDropBehavior, setEventHandlingEnabled, setFilled, setFixedAspectRatio, setFixedHeight, setFixedWidth, setFont, setFontBold, setFontHorizontalJustification, setFontItalic, setFontPointSize, setFontUnderlined, setFontVerticalJustification, setHasBorderHilite, setHasShadow, setHeight, setHidden, setIncomingInvalidLayoutNotificationsEnabled, setInvalidAreaNotificationsEnabled, setInvalidLayoutNotificationsEnabled, setIsDragAndDropSource, setIsDragAndDropTarget, setIsOpaqueRectangle, setItem, setKeyFocusTraversalGroup, setLayout, setLightColor, setLineEndSize, setLineEndSizeFnOfLineWidth, setLineEndsRenderer, setLineEndStyle, setLineStartSize, setLineStartStyle, setLineStyle, setLineWidth, setMargins, setMaximumHeight, setMaximumWidth, setMinimumHeight, setMinimumPickAreaSize, setMinimumSize, setMinimumWidth, setMouseFocus, setMovable, setName, setNumberOfPoints, setOutgoingInvalidLayoutNotificationsEnabled, setPickable, setPickableWhenTransparent, setPoint, setPoint, setPreferredSize, setPrintable, setPropertyValue, setPropertyValues, setPrototypeManipulator, setResource, setSavable, setSelectable, setSelectionGraphics, setSensitive, setShadowColor, setShadowDirection, setShadowLength, setShadowRenderer, setShadowStyle, setSize, setSize, setSnappable, setSnapPointManager, setStatusHelp, setStatusHelpMessage, setSupportedImportFormats, setToolHintHelp, setToolHintMessage, setTransparency, setTransparency, setUngroupable, setVisibilityAnimator, setVisible, setWhiteColor, setWidth, setWriteMode, setXmax, setXmin, setXorColor, setYmax, setYmin, supportsImportOfSpecificInstance, toString, translate, translate, translatePoint, validateLayout, validatePropertyValue, waitUntilRedrawn
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MiContainer

public MiContainer()
Constructs a new MiContainer.

Method Detail

getSupportedImportFormats

public java.lang.String[] getSupportedImportFormats()
Gets list of data formats that this MiPart is able to import. This is used during drag and drop operations in order to match data formats between the source and target. This list should be in order of most preferred to least preferred.

Specified by:
getSupportedImportFormats in interface MiiDragAndDropParticipant
Overrides:
getSupportedImportFormats in class MiPart
Returns:
array of data formats or null (the default).
See Also:
doImport(com.swfm.mica.core.MiDataTransferOperation), MiPart.setSupportedImportFormats(java.lang.String[]), MiPart.getSupportedExportFormats()

setKeepConnectionsBelowNodes

public void setKeepConnectionsBelowNodes(boolean flag)
Sets whether the order of the MiParts in this container are kept such that MiConnections are at the begining of the list. This is useful when and one does not want connections to be drawn in front of the nodes.

Parameters:
flag - true if connections to be drawn first
See Also:
MiConnection.setTruncateLineAtEndPointPartBoundries(boolean), getKeepConnectionsBelowNodes()

getKeepConnectionsBelowNodes

public boolean getKeepConnectionsBelowNodes()
Gets whether the connections are to be drawn before (behind) nodes.

Returns:
true if connections to be drawn first
See Also:
setKeepConnectionsBelowNodes(boolean)

doImport

public void doImport(MiDataTransferOperation transfer)
Import the data specified by the given data transfer operation. If the data is textual then a MiText shape is created and appended to this container. If the data is a MiPart then it is appended to this container.

Specified by:
doImport in interface MiiDragAndDropParticipant
Overrides:
doImport in class MiPart
Parameters:
transfer - the data to import

translate

public void translate(int partNum,
                      MiVector vector)
Translates a part of this container at the given index.

Parameters:
partNum - the index of the part to translate
vector - the translation factor

pick

public boolean pick(MiBounds area)
Gets whether the given area intersects the bounds of this MiPart.

Overrides:
pick in class MiPart
Parameters:
area - the area
Returns:
true if the given area overlaps the bounds of this MiPart.

pickObject

public MiPart pickObject(MiBounds area)
Returns the top MiPart at the given area.

Overrides:
pickObject in class MiPart
Parameters:
area - the given area
Returns:
the top part or null, if none

pickDeepListContents

public void pickDeepListContents(MiBounds area,
                                 MiParts list)
Gets the list of parts, not including this MiPart, whose bounds intersects the given area. The list is sorted from topmost to bottommost part.

Overrides:
pickDeepListContents in class MiPart
Parameters:
area - the area
list - the (returned) list of parts
Returns:
the list, possibly empty, of parts

getNumberOfParts

public int getNumberOfParts()
Gets the number of parts this container has.

Overrides:
getNumberOfParts in class MiPart
Returns:
the number of parts

getPart

public MiPart getPart(int index)
Gets the part of this container at the given index.

Overrides:
getPart in class MiPart
Parameters:
index - the index of the part to get
Returns:
the part at the index

getPart

public MiPart getPart(java.lang.String name)
Gets the part of this container with the given name.

Overrides:
getPart in class MiPart
Parameters:
name - the name of the part to get
Returns:
the part or null

appendPart

public void appendPart(MiPart part)
Appends the given part to this container.

Overrides:
appendPart in class MiPart
Parameters:
part - the part to append
Throws:
java.lang.IllegalArgumentException - if append a part to itself

insertPart

public void insertPart(MiPart part,
                       int index)
Inserts the given part at the given index into this container.

Overrides:
insertPart in class MiPart
Parameters:
part - the part to insert
index - where to insert the part
Throws:
java.lang.IllegalArgumentException - if add a part to itself

setPart

public void setPart(MiPart part,
                    int index)
Replaces the part at the given index with the given part.

Overrides:
setPart in class MiPart
Parameters:
part - the part to insert
index - where to place the part

removePart

public void removePart(int index)
Removes the part from this container at the given index.

Overrides:
removePart in class MiPart
Parameters:
index - index of the part to remove.

removePart

public void removePart(MiPart part)
Removes the given part from this container.

Overrides:
removePart in class MiPart
Parameters:
part - the part to remove.

getIndexOfPart

public int getIndexOfPart(MiPart obj)
Gets the index of the given part in this container.

Overrides:
getIndexOfPart in class MiPart
Parameters:
obj - the part to get the index of.
Returns:
the index of the part or -1 if no such part exists in this container

removeAllParts

public void removeAllParts()
Removes all parts from this container.

Overrides:
removeAllParts in class MiPart

deepCopy

public MiPart deepCopy()
Makes and returns a copy of this container and all of it's parts.

Overrides:
deepCopy in class MiPart
Returns:
the copy
See Also:
MiPart.copy()

containsPart

public boolean containsPart(MiPart part)
Gets whether the given part is in this container.

Overrides:
containsPart in class MiPart
Parameters:
part - the part to check for
Returns:
true if this container contains the part

isContainerOf

public boolean isContainerOf(MiPart part)
Gets whether the given part is in this container or in one of the parts of this container.

Overrides:
isContainerOf in class MiPart
Parameters:
part - the part to check for
Returns:
true if this container or one of it's parts contains the part

isContainerOf

public MiPart isContainerOf(java.lang.String name)
Gets the part with the given name in this container or in one of the parts of this container.

Overrides:
isContainerOf in class MiPart
Parameters:
name - the name of the part to look for
Returns:
the first part found with the given name or null

isContainerOfWithAttachments

public MiPart isContainerOfWithAttachments(java.lang.String name)
Overrides:
isContainerOfWithAttachments in class MiPart

hasEventHandlers

public boolean hasEventHandlers()
Gets whether this MiPart or any of it's attachments or parts has event handlers assigned.

Overrides:
hasEventHandlers in class MiPart
Returns:
true if event handlers were assigned

hasValidCachedEventHandlerInfo

public boolean hasValidCachedEventHandlerInfo()
Gets whether the cached information about the event handlers assigned to this MiPart and it's parts is valid.

Overrides:
hasValidCachedEventHandlerInfo in class MiPart
Returns:
true if info is valid

invalidateCachedEventHandlerInfo

public void invalidateCachedEventHandlerInfo()
Invalidates the cached information about the event handlers assigned to this MiPart and it's containers.


calcMinimumSize

public void calcMinimumSize(MiSize size)
Gets the minimum size of this MiPart. Override this, if desired, as it implements the core functionality. The default behavior is to: return the minimum size as determined by the layout assigned to this container or if only one part in this container, return it's minimum size or if no parts are in this container, return what the super class returns or return the union of all minimum sizes of all parts of this container

Overrides:
calcMinimumSize in class MiPart
Parameters:
size - the (returned) minimum size
See Also:
MiPart.getMinimumSize(com.swfm.mica.core.MiSize)

calcPreferredSize

public void calcPreferredSize(MiSize size)
Gets the preferred size of this MiPart. Override this, if desired, as it implements the core functionality. The default behavior is to: return the preferred size as determined by the layout assigned to this container or if only one part in this container, return it's preferred size or if no parts are in this container, return the current size of this container (or zero if this has reversed bounds). or return the union of all preferred sizes of all parts of this container at their present location

Overrides:
calcPreferredSize in class MiPart
Parameters:
size - the (returned) preferred size
See Also:
MiPart.getPreferredSize(com.swfm.mica.core.MiSize)

getIntersectionWithLine

public boolean getIntersectionWithLine(MiPoint insidePoint,
                                       MiPoint otherPoint,
                                       MiPoint returnedIntersectionPoint)
Gets whether if there is an intersection between the line formed by the given points and the outer bounds of this MiPart. If, there is, also returns the point of intersection. This method is most usefull when insidePoint is inside these bounds.

Overrides:
getIntersectionWithLine in class MiPart
Parameters:
insidePoint - the point inside this MiPart's outer bounds
otherPoint - the point outside this MiPart's outer bounds
returnedIntersectionPoint - the (returned) point of intersection of the line between the two given points and the outer bounds of this MiPart
Returns:
true if there was an intersection