geofasc.swing.tool
public class Canvas extends JLayeredPane implements ContainerListener
Canvas
is intended to be used as a container with a
null-layout for AbstractFigure
s but also other Component
s
(also besides figures).JComponent.AccessibleJComponent
Component.BaselineResizeBehavior
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Canvas()
Creates a new empty
Canvas . |
Canvas(Component... comps)
Creates a new
Canvas putting the passed components into it. |
Modifier and Type | Method and Description |
---|---|
void |
add(Component... comps)
Adds the given components to this canvas.
|
Component |
add(Component comp) |
void |
componentAdded(ContainerEvent e)
Overridden for automatically calling methods
JComponent.revalidate() and
Component.repaint() if a child component is added to this figure and the
figure has been already displayed. |
void |
componentRemoved(ContainerEvent e)
Overridden for automatically calling methods
JComponent.revalidate() and
Component.repaint() if a child component is removed from this figure and
the figure has been already displayed. |
int |
getComponentCount() |
Component[] |
getComponents() |
int |
getFigureCount()
Gets the number of figures in this canvas.
|
AbstractFigure[] |
getFigures()
Gets all the figures in this canvas.
|
int |
getHeight() |
Point |
getLocation() |
Dimension |
getSize() |
int |
getWidth() |
int |
getX() |
int |
getY() |
boolean |
isEnabled() |
boolean |
isSelfContainerListener()
Returns whether this canvas is its own container listener.
|
boolean |
isVisible() |
void |
moveToBack(Component c) |
void |
moveToFront(Component c) |
void |
remove(Component... comps)
Removes the given components from this canvas.
|
void |
remove(Component c) |
void |
removeAll() |
void |
setEnabled(boolean enabled) |
void |
setSelfContainerListener(boolean b)
Sets this canvas as its own container listener.
|
void |
setVisible(boolean visible) |
getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getPosition, highestLayer, isOptimizedDrawingEnabled, lowestLayer, paint, putLayer, remove, setLayer, setLayer, setPosition
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, 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, transferFocusBackward, transferFocusUpCycle
public Canvas()
Canvas
.public Canvas(Component... comps)
Canvas
putting the passed components into it.comps
- the inital components to put into this canvaspublic void componentAdded(ContainerEvent e)
JComponent.revalidate()
and
Component.repaint()
if a child component is added to this figure and the
figure has been already displayed.
Actually this has to be done manually calling the mentioned methods for
efficiency reasons (e.g., adding multiple components to this figure). To
do more efficiently call setSelfContainerListener(boolean)
with
false
to deactivate this figure as its own container
listener, then add the components and fo revalidating as well as
repainting manually.componentAdded
in interface ContainerListener
public void componentRemoved(ContainerEvent e)
JComponent.revalidate()
and
Component.repaint()
if a child component is removed from this figure and
the figure has been already displayed.
Actually this has to be done manually calling the mentioned methods for
efficiency reasons (e.g., removing multiple or all child components of
this figure). To do more efficiently call
setSelfContainerListener(boolean)
with false
to
deactivate this figure as its own container listener, then remove the
components and do validating as well as repainting manually.componentRemoved
in interface ContainerListener
public void add(Component... comps)
comps
- the components to addpublic int getComponentCount()
getComponentCount
in class Container
public Component[] getComponents()
getComponents
in class Container
public int getFigureCount()
public AbstractFigure[] getFigures()
public int getHeight()
getHeight
in class JComponent
public Point getLocation()
getLocation
in class Component
public int getWidth()
getWidth
in class JComponent
public int getX()
getX
in class JComponent
public int getY()
getY
in class JComponent
public boolean isSelfContainerListener()
componentAdded(ContainerEvent)
,
componentRemoved(ContainerEvent)
,
setSelfContainerListener(boolean)
public void moveToBack(Component c)
moveToBack
in class JLayeredPane
public void moveToFront(Component c)
moveToFront
in class JLayeredPane
public void remove(Component... comps)
comps
- the components to removepublic void removeAll()
removeAll
in class JLayeredPane
public void setSelfContainerListener(boolean b)
b
- true or falsecomponentAdded(ContainerEvent)
,
componentRemoved(ContainerEvent)
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public void setVisible(boolean visible)
setVisible
in class JComponent