|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JList com.mindfusion.diagramming.ShapeListBox
public class ShapeListBox
The ShapeListBox control displays a set of shapes defined via the Shape
class.
Shapes from the list box can be dragged to the Diagram
drawing canvas to
create new boxes. Changing the shape of an existing box can be implemented by handling
the ShapeListBoxListener.shapeSelected(com.mindfusion.diagramming.Shape, int)
event and assigning the selected shape
to a box by calling ShapeNode.setShape(com.mindfusion.diagramming.Shape)
.
Initially, the ShapeListBox displays all shapes accessible via Shape.fromId(java.lang.String)
. You
can limit the list to only a subset of the available shapes by calling the setShapeFilter(java.lang.String[])
method. It is also possible to load a shape library from a file using the ShapeLibrary
class, and display the loaded shapes as shown below:
ShapeLibrary lib = ShapeLibrary.loadFrom("shapeLib.shl");
shapeListBox.setShapes(lib.getShapes());
The control creates an icon image for each shape added. The size of an icon displayed in the
list box can be defined via the setIconSize(java.awt.Dimension)
method, and setIconMargin(java.awt.Dimension)
specifies
the horizontal and vertical margin of the icon.
If the AllowRename
property is enabled, users can press the F2 key and
rename a shape in the list box. When a shape is renamed, the ShapeListBoxListener.shapeRenamed(com.mindfusion.diagramming.Shape, int, java.lang.String)
event is raised. If AllowRemove
is enabled, list box items can be deleted
by pressing the Del key. When a shape is removed, the ShapeListBoxListener.shapeRemoved(com.mindfusion.diagramming.Shape, int)
event is raised.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JList |
---|
javax.swing.JList.AccessibleJList |
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JList |
---|
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 | |
---|---|
ShapeListBox()
Initializes a new instance of the ShapeListBox class. |
Method Summary | |
---|---|
void |
addShape(Shape shape)
Adds a single Shape to the list box. |
void |
addShapeListener(ShapeListBoxListener l)
Adds a listener for select, rename and delete events. |
void |
addShapes(Shape[] shapes)
Adds an array of Shape objects to the list box. |
void |
addShapes(ShapeList shapes)
Adds a list of Shape objects to the list box. |
void |
clearShapes()
Removes all shapes from the ShapeListBox, leaving it empty |
protected void |
fireShapeRemoved(Shape shape,
int index)
|
protected void |
fireShapeRenamed(Shape shape,
int i,
java.lang.String oldName)
|
protected void |
fireShapeSelected(Shape shape,
int index)
|
boolean |
getAllowRemove()
Gets a value indicating whether deletion of listbox items by pressing Del is allowed. |
boolean |
getAllowRename()
Gets a value indicating whether inline renaming of listbox items is allowed. |
java.awt.geom.Point2D |
getDefaultShapeSize()
Gets the size of the shape that is created when dragging items from the list box to the flowchart. |
java.awt.Dimension |
getIconMargin()
Gets the horizontal and vertical margins of the shape icons in the ListBox |
java.awt.Dimension |
getIconSize()
Gets the size of the shape icons displayed in the ListBox. |
Shape |
getShapeAt(int index)
Returns the Shape at the specified index. |
int |
getShapeCount()
Returns the number of shapes after filtering. |
java.awt.Color |
getShapeFillColor()
Gets the fill color of the shapes in the list box. |
java.lang.String[] |
getShapeFilter()
Gets the identifiers of the shapes that should be displayed in the list box. |
Shape[] |
getShapes()
Retrieves all shapes visible in the list box after filtering. |
boolean |
getShowLabels()
Gets a value indicating whether to show text labels along with icons for each list item. |
void |
invalidateShapeAt(int i)
Invalidates the specified shape, causing its icon to be recreated and redrawn. |
protected void |
onKeyDown(java.awt.event.KeyEvent e)
|
protected void |
paintComponent(java.awt.Graphics g)
|
void |
removeShapeAt(int i)
Removes a shape from the list box. |
void |
removeShapeListener(ShapeListBoxListener l)
Removes previously added listener for select, rename and delete events |
void |
resumeRepaint()
Resumes repainting the control after a suspendRepaint() call. |
void |
setAllowRemove(boolean value)
|
void |
setAllowRename(boolean value)
Sets a value specifying whether inline renaming of listbox items is allowed. |
void |
setDefaultShapeSize(java.awt.geom.Point2D.Float value)
Sets the size of the shape that is created when dragging items from the list box to the flowchart. |
void |
setIconMargin(java.awt.Dimension value)
Sets the horizontal and vertical margins of the shape icons in the ListBox |
void |
setIconSize(java.awt.Dimension value)
Sets the size of the shape icons displayed in the ListBox. |
void |
setShapeAt(int index,
Shape shape)
Sets the shape at the specified position. |
void |
setShapeFillColor(java.awt.Color value)
Sets the fill color of the shapes in the list box. |
void |
setShapeFilter(java.lang.String[] value)
Sets the identifiers of the shapes that should be displayed in the list box. |
void |
setShapes(Shape[] shapes)
Replaces all current shapes with the specified ones. |
void |
setShowLabels(boolean value)
|
void |
startInlineEdit()
Initiates inline editing of shape id. |
void |
suspendRepaint()
Stops repainting the control. |
Methods inherited from class javax.swing.JList |
---|
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, 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, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, transferFocusBackward, 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, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ShapeListBox()
Method Detail |
---|
protected void onKeyDown(java.awt.event.KeyEvent e)
public java.awt.Dimension getIconMargin()
Dimension
object specifying the margins size.public void setIconMargin(java.awt.Dimension value)
value
- A Dimension
object specifying the margins size.public java.awt.Dimension getIconSize()
Dimension
object specifying the icon size.public void setIconSize(java.awt.Dimension value)
value
- A Dimension
object specifying the icon size.public java.awt.geom.Point2D getDefaultShapeSize()
Point2D
object representing the default ShapeNode
size.public void setDefaultShapeSize(java.awt.geom.Point2D.Float value)
value
- A Point2D
object representing the default ShapeNode
size.public java.awt.Color getShapeFillColor()
Color
object representing the shapes color.public void setShapeFillColor(java.awt.Color value)
value
- A Color
object representing the shapes color.public java.lang.String[] getShapeFilter()
public void setShapeFilter(java.lang.String[] value)
value
- An array of strings containing the shape identifiers.public void addShape(Shape shape)
Shape
to the list box.
shape
- The Shape
that should be added to the list.public void addShapes(Shape[] shapes)
Shape
objects to the list box.
shapes
- The shapes that should be added to the list.public void addShapes(ShapeList shapes)
Shape
objects to the list box.
shapes
- A ShapeList
containing the shapes that should be added to the list.public Shape getShapeAt(int index)
Shape
at the specified index.
index
- The shape position in the list.
public void setShapeAt(int index, Shape shape)
index
- The shape position in the list.shape
- The Shape
that should be added to the list.public int getShapeCount()
public void removeShapeAt(int i)
i
- The shape position in the list.public void clearShapes()
public void invalidateShapeAt(int i)
i
- public Shape[] getShapes()
Shape
objects.public void setShapes(Shape[] shapes)
shapes
- An array of Shape
objects.public boolean getAllowRename()
true
if renaming is allowed, otherwise false
.public void setAllowRename(boolean value)
value
- true
if renaming is allowed, otherwise false
.public boolean getAllowRemove()
Shape
definitions themselves.
true
if deletion is allowed, otherwise false
.public void setAllowRemove(boolean value)
public boolean getShowLabels()
true
if labels are shown.public void setShowLabels(boolean value)
public void addShapeListener(ShapeListBoxListener l)
l
- A ShapeListBoxListener
object.public void removeShapeListener(ShapeListBoxListener l)
l
- protected void fireShapeRemoved(Shape shape, int index)
protected void fireShapeSelected(Shape shape, int index)
protected void fireShapeRenamed(Shape shape, int i, java.lang.String oldName)
public void startInlineEdit()
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void suspendRepaint()
public void resumeRepaint()
suspendRepaint()
call.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |