Class Contour

All Implemented Interfaces:
IContour, ImageObserver, MenuContainer, Serializable

public class Contour extends JComponent implements IContour
A Contour is a lightweight component which only paints the outline of component when dragged. It is also used as a placeholder for some information during dragging.

Notes: this class has to be public so that JIDE can use it in different packages, not meant to release to end user as a public API. JIDE will not guarantee the class will remain as it is.

See Also:
  • Field Details

  • Constructor Details

    • Contour

      public Contour()
      Default Constructor.
    • Contour

      public Contour(int tabHeight)
      Constructor with tab height.
      Parameters:
      tabHeight - the tab height
  • Method Details

    • isDoubleBuffered

      public boolean isDoubleBuffered()
      Returns whether this component should use a buffer to paint.
      Overrides:
      isDoubleBuffered in class JComponent
      Returns:
      true if this component is double buffered, otherwise false
    • paint

      public void paint(Graphics g)
      Paint a rectangle or tab-shape using DOTTED_STROKE with width of WIDTH.
      Overrides:
      paint in class JComponent
      Parameters:
      g -
    • setBounds

      public void setBounds(Rectangle r)
      Overwrite setBounds so that width and height are always even.
      Specified by:
      setBounds in interface IContour
      Overrides:
      setBounds in class Component
      Parameters:
      r - the new bounding rectangle for this component
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overwrite setBounds so that width and height are always even.

      It looks ugly for either dimension is odd when painting with DOTTED_STROKE

      Specified by:
      setBounds in interface IContour
      Overrides:
      setBounds in class Component
      Parameters:
      x - the new x-coordinate of this component
      y - the new y-coordinate of this component
      width - the new width of this component
      height - the new height of this component
    • getTabHeight

      public int getTabHeight()
      Gets tab height.
      Specified by:
      getTabHeight in interface IContour
      Returns:
      tab height
    • setTabHeight

      public void setTabHeight(int tabHeight)
      Sets the tab height.
      Specified by:
      setTabHeight in interface IContour
      Parameters:
      tabHeight -
    • isTabDocking

      public boolean isTabDocking()
      Returns true if the contour is in tab-dock mode.
      Specified by:
      isTabDocking in interface IContour
      Returns:
      true if tab-docking; false otherwise
    • setTabDocking

      public void setTabDocking(boolean tabDocking)
      Sets the tab-docking mode.
      Specified by:
      setTabDocking in interface IContour
      Parameters:
      tabDocking - new mode
    • getTabSide

      public int getTabSide()
      Gets the side of the tab.
      Specified by:
      getTabSide in interface IContour
      Returns:
      the side of the tab
    • setTabSide

      public void setTabSide(int tabSide)
      Sets the side of the tab.
      Specified by:
      setTabSide in interface IContour
      Parameters:
      tabSide -
    • isFloating

      public boolean isFloating()
      Returns true if the contour is in floating mode.
      Specified by:
      isFloating in interface IContour
      Returns:
      true if floating; false otherwise
    • setFloating

      public void setFloating(boolean floating)
      Sets the floating mode.
      Specified by:
      setFloating in interface IContour
      Parameters:
      floating - new mode
    • getAttachedComponent

      public Component getAttachedComponent()
      Gets the attached component of this contour.
      Specified by:
      getAttachedComponent in interface IContour
      Returns:
      the attached component
    • setAttachedComponent

      public void setAttachedComponent(Component attachedComponent)
      Sets the attached components.
      Specified by:
      setAttachedComponent in interface IContour
      Parameters:
      attachedComponent - attached component to be set
    • getAttachedSide

      public int getAttachedSide()
      Gets the side of the attached component which the contour is attached to.
      Specified by:
      getAttachedSide in interface IContour
      Returns:
      side the attached side
    • setAttachedSide

      public void setAttachedSide(int attachedSide)
      Sets the side of the attached component which the contour is attached to.
      Specified by:
      setAttachedSide in interface IContour
      Parameters:
      attachedSide - the new attached side to be set
    • isSingle

      public boolean isSingle()
      When you dragged a component, several other components could be dragged. For example, if user drags on title bar of FrameContainer, all components in the FrameContainer are considered as dragged. If user drags on tab, only selected one is dragged.
      Specified by:
      isSingle in interface IContour
      Returns:
      true if all dragged components are affected; false otherwise.
    • setSingle

      public void setSingle(boolean single)
      Sets the value of single.
      Specified by:
      setSingle in interface IContour
      Parameters:
      single - true if all dragged components are affected; false otherwise.
    • isAllowDocking

      public boolean isAllowDocking()
      Checks if docking is allowed.
      Specified by:
      isAllowDocking in interface IContour
      Returns:
      true if docking is allowed; false otherwise.
    • setAllowDocking

      public void setAllowDocking(boolean allowDocking)
      Sets the value of docking.
      Specified by:
      setAllowDocking in interface IContour
      Parameters:
      allowDocking - true if docking is allowed; false otherwise.
    • getRelativeContainer

      public Container getRelativeContainer()
      Specified by:
      getRelativeContainer in interface IContour
    • setRelativeContainer

      public void setRelativeContainer(Container relativeContainer)
      Specified by:
      setRelativeContainer in interface IContour
    • getSaveX

      public int getSaveX()
      Gets saved X position of contour before it's hidden.
      Specified by:
      getSaveX in interface IContour
      Returns:
      saved X position
    • getSaveY

      public int getSaveY()
      Gets saved Y position of contour before it's hidden.
      Specified by:
      getSaveY in interface IContour
      Returns:
      saved Y position
    • getSaveMouseModifier

      public int getSaveMouseModifier()
      Gets saved mouse modifier before the contour is hidden.
      Specified by:
      getSaveMouseModifier in interface IContour
      Returns:
      saved mouse modifier
    • getSaveDraggedComponent

      public JComponent getSaveDraggedComponent()
      Gets saved dragged component before the contour is hidden.
      Specified by:
      getSaveDraggedComponent in interface IContour
      Returns:
      saved dragged component
    • setDraggingInformation

      public void setDraggingInformation(JComponent comp, int saveX, int saveY, int saveMouseModifier)
      Stores information before the contour is hidden. Those information will be used to restore when the contour is set visible again.
      Specified by:
      setDraggingInformation in interface IContour
      Parameters:
      comp - the dragged component
      saveX - X position of the contour
      saveY - Y position of the contour
      saveMouseModifier - mouse modifier in the MouseEvent
    • cleanup

      public void cleanup()
      Specified by:
      cleanup in interface IContour
    • setVisible

      public void setVisible(boolean aFlag)
      Makes the component visible or invisible. Overrides Component.setVisible.
      Specified by:
      setVisible in interface IContour
      Overrides:
      setVisible in class JComponent
      Parameters:
      aFlag - true to make the component visible; false to make it invisible
    • isVisible

      public boolean isVisible()
      Determines whether this component should be visible when its parent is visible. Components are initially visible, with the exception of top level components such as Frame objects.
      Specified by:
      isVisible in interface IContour
      Overrides:
      isVisible in class Component
      Returns:
      true if the component is visible, false otherwise
      Since:
      JDK1.0
      See Also:
    • getOutlineMode

      public int getOutlineMode()
    • setOutlineMode

      public void setOutlineMode(int outlineMode)
    • getGlassPane

      public Component getGlassPane()
      Specified by:
      getGlassPane in interface IContour
    • setGlassPane

      public void setGlassPane(Component glassPane)
      Specified by:
      setGlassPane in interface IContour
    • isChangeCursor

      public boolean isChangeCursor()
    • setChangeCursor

      public void setChangeCursor(boolean changeCursor)
      Specified by:
      setChangeCursor in interface IContour