Package snap.view

Class CollapseView

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable, ViewHost

public class CollapseView extends ParentView implements ViewHost
This view subclass holds a header label and content view with support to collapse.
  • Field Details

    • LABEL_FONT

      public static Font LABEL_FONT
    • LABEL_FILL

      public static Color LABEL_FILL
    • LABEL_TEXT_FILL

      public static Color LABEL_TEXT_FILL
    • LABEL_BORDER

      public static Border LABEL_BORDER
  • Constructor Details

    • CollapseView

      public CollapseView()
      Constructor.
    • CollapseView

      public CollapseView(String aTitle, View aView)
      Constructor for given View.
  • Method Details

    • getTitle

      public String getTitle()
      Returns the title.
    • setTitle

      public void setTitle(String aValue)
      Sets the title.
    • getLabel

      public Label getLabel()
      Returns the label.
    • createLabel

      protected Label createLabel()
      Creates a label.
    • getContent

      public View getContent()
      Returns the content view.
    • setContent

      public void setContent(View aView)
      Sets the content view.
    • isCollapsed

      public boolean isCollapsed()
      Returns whether view is collapsed.
    • setCollapsed

      public void setCollapsed(boolean aValue)
      Sets whether view is collapsed.
    • isExpanded

      public boolean isExpanded()
      Returns whether title view is expanded.
    • setExpanded

      public void setExpanded(boolean aValue)
      Sets whether title view is expanded.
    • setExpandedAnimated

      public void setExpandedAnimated(boolean aValue)
      Sets the expanded animated.
    • toggleExpandedAnimated

      protected void toggleExpandedAnimated(ViewEvent anEvent)
      Called when Label receives a MousePress.
    • setFirstFocus

      public void setFirstFocus(View aView)
      Sets the first focus component.
    • setGroupForName

      public void setGroupForName(String aName)
      Sets a collapse group by name.
    • getCollapseGroupForName

      public CollapseView.CollapseGroup getCollapseGroupForName(String aName)
      Sets a collapse group by name.
    • labelWasPressed

      protected void labelWasPressed(ViewEvent anEvent)
      Called when Label is pressed.
    • getCollapseGraphic

      public View getCollapseGraphic()
      Returns an image of a down arrow.
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the preferred width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the preferred height.
      Overrides:
      getPrefHeightImpl in class View
    • layoutImpl

      protected void layoutImpl()
      Layout children.
      Overrides:
      layoutImpl in class ParentView
    • getGuestCount

      public int getGuestCount()
      ViewHost method: Override to return 1 if content is present.
      Specified by:
      getGuestCount in interface ViewHost
    • getGuest

      public View getGuest(int anIndex)
      ViewHost method: Override to return content (and complain if index beyond 0).
      Specified by:
      getGuest in interface ViewHost
    • addGuest

      public void addGuest(View aChild, int anIndex)
      ViewHost method: Override to set content.
      Specified by:
      addGuest in interface ViewHost
    • removeGuest

      public View removeGuest(int anIndex)
      ViewHost method: Override to clear content (and complain if index beyond 0).
      Specified by:
      removeGuest in interface ViewHost
    • getText

      public String getText()
      Override to forward to label.
      Overrides:
      getText in class View
    • setText

      public void setText(String aStr)
      Override to forward to label.
      Overrides:
      setText in class View
    • replaceViewWithCollapseView

      public static CollapseView replaceViewWithCollapseView(View aView, String aTitle)
      Replaces given view with CollapseView with given title.