Class TagView

All Implemented Interfaces:
SwingConstants

public class TagView extends BoxView
View of an XML tag: its rows are laid out vertically, indented by the collapse area. Tags with children show a box to collapse them to their first row.
Author:
Stanislav Lapitsky
  • Field Details

    • AREA_SHIFT

      public static final int AREA_SHIFT
      size of the collapse box and left indent of the content in pixels
      See Also:
  • Constructor Details

    • TagView

      public TagView(Element elem)
      Parameters:
      elem - the tag element of the document
  • Method Details

    • getAlignment

      public float getAlignment(int axis)
      Overrides:
      getAlignment in class BoxView
      Parameters:
      axis - the axis
      Returns:
      always 0 (left/top aligned)
    • paint

      public void paint(Graphics g, Shape alloc)
      Paints the tag (clipped to its allocation if collapsed) and, if it has more than one row, the collapse box with a plus or minus sign and the line to the end tag.
      Overrides:
      paint in class BoxView
      Parameters:
      g - the graphics
      alloc - the allocated area
    • getPreferredSpan

      public float getPreferredSpan(int axis)
      Overrides:
      getPreferredSpan in class BoxView
      Parameters:
      axis - the axis
      Returns:
      the preferred span; if collapsed, the height of the first row only
    • getMinimumSpan

      public float getMinimumSpan(int axis)
      Overrides:
      getMinimumSpan in class BoxView
      Parameters:
      axis - the axis
      Returns:
      the minimum span; if collapsed, the height of the first row only
    • getMaximumSpan

      public float getMaximumSpan(int axis)
      Overrides:
      getMaximumSpan in class BoxView
      Parameters:
      axis - the axis
      Returns:
      the preferred span
    • isExpanded

      public boolean isExpanded()
      Returns:
      true if the children of the tag are shown
    • setExpanded

      public void setExpanded(boolean expanded)
      Parameters:
      expanded - true to show the children, false to collapse the tag
    • getNextEastWestVisualPositionFrom

      protected int getNextEastWestVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException
      Moves the caret horizontally; in a collapsed tag the caret skips the hidden rows (to the end of the tag or back to the first row).
      Overrides:
      getNextEastWestVisualPositionFrom in class CompositeView
      Parameters:
      pos - the current position
      b - the bias of the position
      a - the allocated area
      direction - SwingConstants.EAST or WEST
      biasRet - returns the bias of the new position
      Returns:
      the new position
      Throws:
      BadLocationException - if the position is invalid