Interface IFigure

All Known Subinterfaces:
Connection, FreeformFigure, IImageFigure, IScalablePane, IScrollableFigure, Orientable, RotatableDecoration, ScalableFigure
All Known Implementing Classes:
AbstractImageFigure, AbstractPointListShape, ArrowButton, BlockFlow, Button, CheckBox, Clickable, ConnectionLayer, Ellipse, Figure, FlowAdapter, FlowFigure, FlowPage, FreeformLayer, FreeformLayeredPane, FreeformViewport, GhostImageFigure, ImageFigure, InlineFlow, Label, LabeledContainer, Layer, LayeredPane, LightweightSystem.RootFigure, Panel, Polygon, PolygonDecoration, PolygonShape, Polyline, PolylineConnection, PolylineDecoration, PolylineShape, PuristicScrollPane, PuristicScrollPane.PuristicScrollBar, RectangleFigure, RoundedRectangle, ScalableFreeformLayeredPane, ScalableLayeredPane, ScalablePolygonShape, ScrollableThumbnail, ScrollBar, ScrollPane, Shape, TextFlow, Thumbnail, Toggle, ToggleButton, Triangle, Viewport

public interface IFigure
A lightweight graphical object. Figures are rendered to a Graphics object. Figures can be composed to create complex graphics.
  • Field Details

  • Method Details

    • add

      void add(IFigure figure)
      Adds the given IFigure as a child of this IFigure. The same as calling add(figure, null, -1).
      Parameters:
      figure - The IFigure to add
    • add

      void add(IFigure figure, int index)
      Adds the given IFigure as a child of this IFigure at the given index. The same as calling add(figure, null, index).
      Parameters:
      figure - The IFigure to add
      index - The index where the IFigure should be added
    • add

      void add(IFigure figure, Object constraint)
      Adds the given IFigure as a child of this IFigure with the given constraint. The same as calling add(figure, constraint, -1).
      Parameters:
      figure - The IFigure to add
      constraint - The newly added IFigure's constraint
    • add

      void add(IFigure figure, Object constraint, int index)
      Adds the child with the specified index and constraint. The child's parent is currently not null, it is removed from that parent. If this figure has a LayoutManager, then LayoutManager.setConstraint(IFigure, Object) shall be called on the layout.
      Parameters:
      figure - The IFigure to add
      constraint - The newly added IFigure's constraint
      index - The index where the IFigure should be added
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      IllegalArgumentException - if adding the child creates a cycle
    • addAncestorListener

      void addAncestorListener(AncestorListener listener)
      Registers the given listener as an AncestorListener of this figure.
      Parameters:
      listener - The listener to add
    • addCoordinateListener

      void addCoordinateListener(CoordinateListener listener)
      Registers the given listener as a CoordinateListener of this figure.
      Parameters:
      listener - the listener to add
      Since:
      3.1
    • addFigureListener

      void addFigureListener(FigureListener listener)
      Registers the given listener as a FigureListener of this figure.
      Parameters:
      listener - The listener to add
    • addFocusListener

      void addFocusListener(FocusListener listener)
      Registers the given listener as a FocusListener of this figure.
      Parameters:
      listener - The listener to add
    • addKeyListener

      void addKeyListener(KeyListener listener)
      Registers the given listener as a KeyListener of this figure.
      Parameters:
      listener - The listener to add
    • addLayoutListener

      void addLayoutListener(LayoutListener listener)
      Registers the given listener on this figure.
      Parameters:
      listener - The listener to add
      Since:
      3.1
    • addMouseListener

      void addMouseListener(MouseListener listener)
      Registers the given listener as a MouseListener of this IFigure.
      Parameters:
      listener - The listener to add
    • addMouseMotionListener

      void addMouseMotionListener(MouseMotionListener listener)
      Registers the given listener as a MouseMotionListener of this IFigure.
      Parameters:
      listener - The listener to add
    • addNotify

      void addNotify()
      Called after this IFigure is added to its parent.
    • addPropertyChangeListener

      void addPropertyChangeListener(PropertyChangeListener listener)
      Registers the given listener as a PropertyChangeListener of this IFigure.
      Parameters:
      listener - The listener to add
    • addPropertyChangeListener

      void addPropertyChangeListener(String property, PropertyChangeListener listener)
      Registers the given listener as a PropertyChangeListener of this IFigure, interested only in the given property.
      Parameters:
      property - The property the listener is interested in
      listener - The listener to add
    • containsPoint

      boolean containsPoint(int x, int y)
      Returns true if the point (x, y) is contained within this IFigure's bounds.
      Parameters:
      x - The X coordinate
      y - The Y coordinate
      Returns:
      true if the point (x,y) is contained in this IFigure's bounds
    • containsPoint

      boolean containsPoint(Point p)
      Returns true if the Point p is contained within this IFigure's bounds.
      Parameters:
      p - The point
      Returns:
      true if the Point p is contained within this IFigure's bounds
    • erase

      void erase()
      Erases this IFigure.
    • findFigureAt

      IFigure findFigureAt(int x, int y)
      Returns the IFigure at the specified location. May return this or null.
      Parameters:
      x - The X coordinate
      y - The Y coordinate
      Returns:
      The IFigure at the specified location
    • findFigureAt

      IFigure findFigureAt(int x, int y, TreeSearch search)
      Returns the IFigure at the specified location based on the conditional TreeSearch. May return this or null
      Parameters:
      x - the X coordinate
      y - the Y coordinate
      search - the conditional TreeSearch
      Returns:
      the IFigure at the specified location
    • findFigureAt

      IFigure findFigureAt(Point p)
      Returns the IFigure at the specified location. May return this or null.
      Parameters:
      p - The point
      Returns:
      The IFigure at the specified location
    • findFigureAtExcluding

      IFigure findFigureAtExcluding(int x, int y, Collection<IFigure> collection)
      Returns the IFigure at the specified location, excluding any IFigures in collection. May return this or null.
      Parameters:
      x - The X coordinate
      y - The Y coordinate
      collection - A collection of IFigures to be excluded
      Returns:
      The IFigure at the specified location, excluding any IFigures in collection
    • findMouseEventTargetAt

      IFigure findMouseEventTargetAt(int x, int y)
      Returns the IFigure located at the given location which will accept mouse events.
      Parameters:
      x - The X coordinate
      y - The Y coordinate
      Returns:
      The IFigure located at the given location which will accept mouse events
    • getBackgroundColor

      Color getBackgroundColor()
      Returns the background color. Background color can be inherited from the parent.
      Returns:
      The background color
    • getBorder

      Border getBorder()
      Returns the current border by reference.
      Returns:
      The current border
    • getBounds

      Rectangle getBounds()
      Returns the smallest rectangle completely enclosing the IFigure. Implementation may return the Rectangle by reference. For this reason, callers of this method must not modify the returned Rectangle. The Rectangle's values may change in the future.
      Returns:
      This IFigure's bounds
    • getChildren

      List<? extends IFigure> getChildren()
      Returns an unmodifiable list of children by reference.
      Returns:
      An unmodifiable list of children by reference
    • getClientArea

      Rectangle getClientArea()
      Returns the rectangular area within this Figure's bounds in which children will be placed (via LayoutManagers) and the painting of children will be clipped.
      Returns:
      The client area
    • getClientArea

      Rectangle getClientArea(Rectangle rect)
      Copies the client area into the specificied Recangle, and returns that rectangle for convenience.
      Parameters:
      rect - The destination rectangle for the client area
      Returns:
      The same instance that was passed in, modified to contain the client area
    • getClippingStrategy

      IClippingStrategy getClippingStrategy()
      Returns the IClippingStrategy used by this figure to clip its children
      Returns:
      the IClipppingStrategy used to clip this figure's children.
      Since:
      3.6
    • getCursor

      Cursor getCursor()
      Returns the Cursor used when the mouse is over this IFigure.
      Returns:
      The Cursor used when the mouse is over this IFigure
    • getFont

      Font getFont()
      Returns the current Font by reference.
      Returns:
      The current Font
    • getForegroundColor

      Color getForegroundColor()
      Returns the foreground color.
      Returns:
      The foreground color
    • getInsets

      Insets getInsets()
      Returns the current Insets. May be returned by reference. The returned value should not be modified.
      Returns:
      The current Insets.
    • getLayoutManager

      LayoutManager getLayoutManager()
      Returns the current LayoutManager by reference.
      Returns:
      The current LayoutManager by reference
    • getLocalBackgroundColor

      Color getLocalBackgroundColor()
      Returns the background Color of this Figure. Does not inherit this Color from the parent, may return null.
      Returns:
      The local background Color
    • getLocalForegroundColor

      Color getLocalForegroundColor()
      Returns the local foreground Color of this Figure. Does not inherit this Color from the parent, may return null.
      Returns:
      The local foreground Color
    • getLocation

      default Point getLocation()
      Returns the top-left corner of this Figure's bounds.
      Returns:
      The top-left corner of this Figure's bounds
      Since:
      3.14
    • getMaximumSize

      Dimension getMaximumSize()
      Returns a hint indicating the largest desireable size for the IFigure. Returned Dimension is by value.
      Returns:
      The maximum size
    • getMinimumSize

      Dimension getMinimumSize()
      Returns a hint indicating the smallest desireable size for the IFigure. The returned dimension may be by reference, and it must not be modified by the caller.
      Returns:
      The minimum size
    • getMinimumSize

      Dimension getMinimumSize(int wHint, int hHint)
      Returns a hint indicating the smallest desireable size for the IFigure. The returned dimension may be by reference, and it must not be modified by the caller.
      Parameters:
      wHint - the width hint
      hHint - the height hint
      Returns:
      The minimum size
    • getParent

      IFigure getParent()
      Returns the IFigure that is the current parent of this IFigure or null if there is no parent.
      Returns:
      null or the parent figure
    • getPreferredSize

      Dimension getPreferredSize()
      Returns the preferred size for this IFigure. The returned value must not be modified by the caller. If the figure has no preference, it returns its current size. The same as calling getPreferredSize(-1, -1).
      Returns:
      The preferred size
    • getPreferredSize

      Dimension getPreferredSize(int wHint, int hHint)
      Returns the preferred size for this IFigure using the provided width and height hints. The returned dimension may be by reference, and it must not be modified by the caller. A value of -1 indicates that there is no constraint in that direction.
      Parameters:
      wHint - a width hint
      hHint - a height hint
      Returns:
      The preferred size
    • getSize

      Dimension getSize()
      Returns the current size. Returned Dimension is by value.
      Returns:
      The current size
    • getToolTip

      IFigure getToolTip()
      Returns a IFigure that is the tooltip for this IFigure.
      Returns:
      This IFigure's tooltip
    • getUpdateManager

      UpdateManager getUpdateManager()
      Returns the UpdateManager for this IFigure by reference.
      Returns:
      The update manager
    • handleFocusGained

      void handleFocusGained(FocusEvent event)
      Called when this IFigure has gained focus.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a FocusListener with this IFigure.

      Parameters:
      event - The focus event
    • handleFocusLost

      void handleFocusLost(FocusEvent event)
      Called when this IFigure has lost focus.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a FocusListener with this IFigure.

      Parameters:
      event - The focus event
    • handleKeyPressed

      void handleKeyPressed(KeyEvent event)
      Called when a key is pressed while this IFigure has focus.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a KeyListener with this IFigure.

      Parameters:
      event - The key event
    • handleKeyReleased

      void handleKeyReleased(KeyEvent event)
      Called when a key is released while this IFigure has focus.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a KeyListener with this IFigure.

      Parameters:
      event - The key event
    • handleMouseDoubleClicked

      void handleMouseDoubleClicked(MouseEvent event)
      Called when a mouse button has been double-clicked while within this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseDragged

      void handleMouseDragged(MouseEvent event)
      Called when the mouse has been dragged within this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseMotionListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseEntered

      void handleMouseEntered(MouseEvent event)
      Called when the mouse has entered this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseMotionListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseExited

      void handleMouseExited(MouseEvent event)
      Called when the mouse has exited this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseMotionListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseHover

      void handleMouseHover(MouseEvent event)
      Called when the mouse has hovered over this IFigure.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseMotionListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseMoved

      void handleMouseMoved(MouseEvent event)
      Called when the mouse has moved within this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseMotionListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMousePressed

      void handleMousePressed(MouseEvent event)
      Called when a mouse button has been pressed while within this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseListener with this IFigure.

      Parameters:
      event - The mouse event
    • handleMouseReleased

      void handleMouseReleased(MouseEvent event)
      Called when a mouse button has been released while within this IFigure's bounds.

      NOTE: You should not override this method. If you are interested in receiving notification of this type of event, you should register a MouseListener with this IFigure.

      Parameters:
      event - The mouse event
    • hasFocus

      boolean hasFocus()
      Returns true if this IFigure has focus.
      Returns:
      true if this IFigure has focus
    • internalGetEventDispatcher

      EventDispatcher internalGetEventDispatcher()
      This method is for internal purposes only and should not be called.
      Returns:
      The event dispatcher
    • intersects

      boolean intersects(Rectangle rect)
      Returns true if this IFigure's bounds intersect with the given Rectangle. Figure is asked so that non-rectangular IFigures can reduce the frequency of paints.
      Parameters:
      rect - The rectangle to check for intersection
      Returns:
      true if this IFigure's bounds intersect with the given Rectangle
    • invalidate

      void invalidate()
      Invalidates this IFigure. If this figure has a LayoutManager, then LayoutManager.invalidate() should be called on that layout.
    • invalidateTree

      void invalidateTree()
      Invalidates this figure as well as all contained within.
    • isCoordinateSystem

      boolean isCoordinateSystem()
      Returns true if this figure is capable of applying a local coordinate system which affects its children.
      Returns:
      true if this figure provides local coordinates to children
      Since:
      3.1
    • isEnabled

      boolean isEnabled()
      Returns true if this IFigure is enabled.
      Returns:
      true if this IFigure is enabled
    • isFocusTraversable

      boolean isFocusTraversable()
      Returns true if this IFigure can gain focus on a TraverseEvent.
      Returns:
      true if this IFigure can gain focus on a TraverseEvent
    • isMirrored

      boolean isMirrored()
      Returns:
      true if this figure is hosted in a Control that is mirrored
      Since:
      3.1
    • isOpaque

      boolean isOpaque()
      Returns true if this IFigure is opaque.
      Returns:
      true if this IFigure is opaque
    • isRequestFocusEnabled

      boolean isRequestFocusEnabled()
      Returns true if this IFigure can receive focus on a call to requestFocus().
      Returns:
      true if this IFigure can receive focus on a call to requestFocus()
    • isShowing

      boolean isShowing()
      Returns true if this IFigure is showing. This figure is only showing if it is visible and its parent is showing, or it has no parent.
      Returns:
      true if this IFigure is showing
    • isVisible

      boolean isVisible()
      returns true if this figure's visibility flag is set to true. Does not walk up the parent chain.
      Returns:
      true if the figure's visibility flag is set
    • paint

      void paint(Graphics graphics)
      Paints this IFigure and its children.
      Parameters:
      graphics - The Graphics object used for painting
    • remove

      void remove(IFigure figure)
      Removes the given child from this figure's children. If this figure has a LayoutManager, then LayoutManager.remove(IFigure) shall be called on that layout with the child.
      Parameters:
      figure - The IFigure to remove
    • removeAncestorListener

      void removeAncestorListener(AncestorListener listener)
      Unregisters the given listener, so that it will no longer receive notification of ancestor events.
      Parameters:
      listener - The listener to remove
    • removeCoordinateListener

      void removeCoordinateListener(CoordinateListener listener)
      Unregisters the given listener, so that it will no longer receive notification of coordinate changes.
      Parameters:
      listener - the listener to remove
      Since:
      3.1
    • removeFigureListener

      void removeFigureListener(FigureListener listener)
      Unregisters the given listener, so that it will no longer receive notification of IFigure events.
      Parameters:
      listener - The listener to remove
    • removeFocusListener

      void removeFocusListener(FocusListener listener)
      Unregisters the given listener, so that it will no longer receive notification of focus events.
      Parameters:
      listener - The listener to remove
    • removeKeyListener

      void removeKeyListener(KeyListener listener)
      Removes the first occurence of the given listener.
      Parameters:
      listener - The listener to remove
    • removeLayoutListener

      void removeLayoutListener(LayoutListener listener)
      Removes the most recent occurence of the given listener.
      Parameters:
      listener - the listener to remove
      Since:
      3.1
    • removeMouseListener

      void removeMouseListener(MouseListener listener)
      Unregisters the given listener, so that it will no longer receive notification of mouse events.
      Parameters:
      listener - The listener to remove
    • removeMouseMotionListener

      void removeMouseMotionListener(MouseMotionListener listener)
      Unregisters the given listener, so that it will no longer receive notification of mouse motion events.
      Parameters:
      listener - The listener to remove
    • removeNotify

      void removeNotify()
      Called before this IFigure is removed from its parent.
    • removePropertyChangeListener

      void removePropertyChangeListener(PropertyChangeListener listener)
      Unregisters the given listener, so that it will no longer receive notification of any property changes.
      Parameters:
      listener - The listener to remove
    • removePropertyChangeListener

      void removePropertyChangeListener(String property, PropertyChangeListener listener)
      Unregisters the given listener, so that it will no longer receive notification of changes in the given property. This will only unregister the listener for the given property. If the listener is registered to listen to other properties, this will not affect the notification of the listener regarding those properties.
      Parameters:
      property - The property that the listener is no longer interested in
      listener - The listener no longer interested in the property
    • repaint

      void repaint()
      Repaints this IFigure.
    • repaint

      void repaint(int x, int y, int w, int h)
      Repaints the rectangular area within this IFigure whose upper-left corner is located at the point (x,y) and whose width and height are w and h, respectively.
      Parameters:
      x - The X coordinate of the area to repaint
      y - The Y coordinate of the area to repaint
      w - The width of the area to repaint
      h - The height of the area to repaint
    • repaint

      void repaint(Rectangle rect)
      Repaints the rectangular area within this IFigure represented by rect.
      Parameters:
      rect - The rectangular area to be repainted
    • requestFocus

      void requestFocus()
      Requests focus from the EventDispatcher.
    • revalidate

      void revalidate()
      Invalidates this figure and revalidates() its parent. If a figure does not have a parent, it will request a validation from it UpdateManager. Calling this method does not guarantee that a repaint will occur.
    • setBackgroundColor

      void setBackgroundColor(Color c)
      Sets the background color.
      Parameters:
      c - The new background color
    • setBorder

      void setBorder(Border b)
      Sets the border.
      Parameters:
      b - The new border
    • setBounds

      void setBounds(Rectangle rect)
      Sets the bounds to the bounds of the specified Rectangle.
      Parameters:
      rect - The new bounds
    • setClippingStrategy

      void setClippingStrategy(IClippingStrategy clippingStrategy)
      Registers a clipping strategy to specify how clipping is performed for child figures.
      Parameters:
      clippingStrategy -
      Since:
      3.6
    • setConstraint

      void setConstraint(IFigure child, Object constraint)
      Convenience method to set the constraint of the specified child in the current LayoutManager.
      Parameters:
      child - The figure whose constraint is being set
      constraint - the constraint
      Throws:
      IllegalArgumentException - if the child is not contained by this Figure
    • setCursor

      void setCursor(Cursor cursor)
      Sets the cursor.
      Parameters:
      cursor - The new cursor
    • setEnabled

      void setEnabled(boolean value)
      Sets this IFigure to be enabled.
      Parameters:
      value - true if this IFigure should be enabled
    • setFocusTraversable

      void setFocusTraversable(boolean value)
      Sets the ability for this IFigure to gain focus on a TraverseEvent.
      Parameters:
      value - true if this IFigure should gain focus on a TraverseEvent
    • setFont

      void setFont(Font f)
      Sets the font.
      Parameters:
      f - The new font
    • setForegroundColor

      void setForegroundColor(Color c)
      Sets the foreground color.
      Parameters:
      c - The new foreground color
    • setLayoutManager

      void setLayoutManager(LayoutManager lm)
      Sets the LayoutManager.
      Parameters:
      lm - The new layout manager
    • setLocation

      void setLocation(Point p)
      Sets the location of this IFigure.
      Parameters:
      p - The new location
    • setMaximumSize

      void setMaximumSize(Dimension size)
      Sets the maximum size this IFigure can be.
      Parameters:
      size - The new maximum size
    • setMinimumSize

      void setMinimumSize(Dimension size)
      Sets the minimum size this IFigure can be.
      Parameters:
      size - The new minimum size
    • setOpaque

      void setOpaque(boolean isOpaque)
      Sets this IFigure to be opaque if isOpaque is true and transparent if isOpaque is false.
      Parameters:
      isOpaque - true is this IFigure should be opaque
    • setParent

      void setParent(IFigure parent)
      Sets this IFigure's parent.
      Parameters:
      parent - The new parent IFigure
    • setPreferredSize

      void setPreferredSize(Dimension size)
      Sets this IFigure's preferred size.
      Parameters:
      size - The new preferred size
    • setRequestFocusEnabled

      void setRequestFocusEnabled(boolean requestFocusEnabled)
      Sets the ability for this Figure to gain focus on a call to requestFocus().
      Parameters:
      requestFocusEnabled - true if this IFigure should gain focus on a call to requestFocus()
    • setSize

      void setSize(Dimension d)
      Sets this IFigure's size.
      Parameters:
      d - The new size
    • setSize

      void setSize(int w, int h)
      Sets this IFigure's size.
      Parameters:
      w - The new width
      h - The new height
    • setToolTip

      void setToolTip(IFigure figure)
      Sets a tooltip that is displayed when the mouse hovers over this IFigure.
      Parameters:
      figure - The tooltip IFigure
    • setVisible

      void setVisible(boolean visible)
      Sets this IFigure's visibility.
      Parameters:
      visible - true if this IFigure should be visible
    • translate

      void translate(int x, int y)
      Moves this IFigure x pixels horizontally and y pixels vertically.
      Parameters:
      x - The amount to move this IFigure horizontally
      y - The amount to move this IFigure vertically
    • translateFromParent

      void translateFromParent(Translatable t)
      Translates a Translatable from this IFigure's parent's coordinates to this IFigure's local coordinates.
      Parameters:
      t - The object to translate
    • translateToAbsolute

      void translateToAbsolute(Translatable t)
      Translates a Translatable that is relative to this figure's bounds to absolute.
      Parameters:
      t - The object to translate
    • translateToParent

      void translateToParent(Translatable t)
      Translates a Translatable from this IFigure's coordinates to its parent's coordinates.
      Parameters:
      t - The object to translate
    • translateToRelative

      void translateToRelative(Translatable t)
      Translates a Translatable in absolute coordinates to be relative to this figure's bounds.
      Parameters:
      t - The object to translate
    • validate

      void validate()
      Indicates that this figure should make itself valid. Validation includes invoking layout on a LayoutManager if present, and then validating all children figures. Default validation uses pre-order, depth-first ordering.