Class RowLayout

  • All Implemented Interfaces:
    Layout
    Direct Known Subclasses:
    SingleRowLayout

    public class RowLayout
    extends java.lang.Object
    implements Layout
    RowLayout handles a single row layout that may be part of a multiple row layout that is generic enough to be used by the SingleRowLayout or the MultiRowLayout.
    • Constructor Summary

      Constructors 
      Constructor Description
      RowLayout​(Field[] fields, int rowID)
      Constructs a RowLayout from an array of fields
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(int yPos)
      Returns true if the the given yPos lies within this layout.
      int cursorBeginning​(FieldLocation cursorLoc)
      Sets the given FieldLocation as far to the left as possible.
      boolean cursorDown​(FieldLocation cursorLoc, int lastX)
      Moves the cursor up down row from its current position.
      int cursorEnd​(FieldLocation cursorLoc)
      Sets the given FieldLocation as far to the right as possible.
      int cursorLeft​(FieldLocation cursorLoc)
      Sets the given FieldLocation one position to the left.
      int cursorRight​(FieldLocation cursorLoc)
      Sets the given FieldLocation one position to the right.
      boolean cursorUp​(FieldLocation cursorLoc, int lastX)
      Moves the cursor up one row from its current position.
      boolean enterLayout​(FieldLocation cursorLoc, int lastX, boolean fromTop)
      Tries to move the cursor into this layout.
      int getBeginRowFieldNum​(int field1)  
      int getCompressableWidth()
      Returns the smallest possible width of this layout that can display its full contents
      java.awt.Rectangle getCursorRect​(int fieldNum, int row, int col)
      Returns a rectangle which bounds the given cursor position.
      int getEndRowFieldNum​(int field2)  
      Field getField​(int index)
      Returns the i'th Field in this Layout.
      java.awt.Rectangle getFieldBounds​(int index)
      Returns the bounds of the given field (in coordinates relative to the layout)
      int getHeight()
      Returns the total height of this layout.
      int getHeightAbove()
      Returns the height above the baseline.
      int getHeightBelow()
      Returns the height below the baseline.
      int getIndexSize()
      Returns the number of indexes consumed by this layout.
      int getNumFields()
      Returns the number of Fields in this Layout.
      int getPrimaryOffset()
      Returns the vertical offset (in pixels) of the start of the primary field in the layout.
      int getRowID()
      Returns the row number of this layout with respect to its containing layout.
      int getScrollableUnitIncrement​(int topOfScreen, int direction)
      Returns the amount to scroll to reveal the line of text.
      void insertSpaceAbove​(int size)
      Inserts empty space above the layout
      void insertSpaceBelow​(int size)
      Inserts empty space below the layout
      void paint​(javax.swing.JComponent c, java.awt.Graphics g, PaintContext context, java.awt.Rectangle rect, LayoutBackgroundColorManager colorManager, FieldLocation cursorLocation)
      Paints this layout on the screen.
      int setCursor​(FieldLocation cursorLoc, int x, int y)
      Sets the cursor to the given point location.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RowLayout

        public RowLayout​(Field[] fields,
                         int rowID)
        Constructs a RowLayout from an array of fields
        Parameters:
        fields - the set of fields that make up the entire layout
        rowID - the rowID of this row layout in the overall layout.
    • Method Detail

      • getHeight

        public int getHeight()
        Description copied from interface: Layout
        Returns the total height of this layout.
        Specified by:
        getHeight in interface Layout
        See Also:
        Layout.getHeight()
      • getCompressableWidth

        public int getCompressableWidth()
        Description copied from interface: Layout
        Returns the smallest possible width of this layout that can display its full contents
        Specified by:
        getCompressableWidth in interface Layout
        Returns:
        the smallest possible width of this layout that can display its full contents
      • getHeightAbove

        public int getHeightAbove()
        Returns the height above the baseline.
      • getHeightBelow

        public int getHeightBelow()
        Returns the height below the baseline.
      • getRowID

        public int getRowID()
        Returns the row number of this layout with respect to its containing layout.
      • insertSpaceAbove

        public void insertSpaceAbove​(int size)
        Description copied from interface: Layout
        Inserts empty space above the layout
        Specified by:
        insertSpaceAbove in interface Layout
        Parameters:
        size - the amount of space to insert above the layout
        See Also:
        Layout.insertSpaceAbove(int)
      • insertSpaceBelow

        public void insertSpaceBelow​(int size)
        Description copied from interface: Layout
        Inserts empty space below the layout
        Specified by:
        insertSpaceBelow in interface Layout
        Parameters:
        size - the amount of space to insert below the layout
        See Also:
        Layout.insertSpaceBelow(int)
      • getField

        public Field getField​(int index)
        Description copied from interface: Layout
        Returns the i'th Field in this Layout.
        Specified by:
        getField in interface Layout
        Parameters:
        index - the index of the field to retrieve.
        See Also:
        Layout.getField(int)
      • paint

        public void paint​(javax.swing.JComponent c,
                          java.awt.Graphics g,
                          PaintContext context,
                          java.awt.Rectangle rect,
                          LayoutBackgroundColorManager colorManager,
                          FieldLocation cursorLocation)
        Description copied from interface: Layout
        Paints this layout on the screen.
        Specified by:
        paint in interface Layout
        g - The graphics context with which to paint.
        context - contains various information needed to do the paint
        rect - the screen area that needs to be painted.
        colorManager - indicates where the selection exists
        cursorLocation - the location of the cursor or null if the cursor is not in this layout
        See Also:
        docking.widgets.fieldpanel.Layout#paint(java.awt.Graphics, docking.widgets.fieldpanel.internal.PaintContext, java.awt.Rectangle, docking.widgets.fieldpanel.support.field.LayoutSelection, docking.widgets.fieldpanel.support.field.LayoutSelection, int, int, int)
      • setCursor

        public int setCursor​(FieldLocation cursorLoc,
                             int x,
                             int y)
        Description copied from interface: Layout
        Sets the cursor to the given point location. The cursor will be positioned to the row column position that is closest to the given point.
        Specified by:
        setCursor in interface Layout
        Parameters:
        cursorLoc - the location that is to be filled in.
        x - the x coordinate of the point to be translated into a cursor location.
        y - the y coordinate of the point to be translated into a cursor location.
        Returns:
        the x coordinated of the computed cursor location.
        See Also:
        Layout.setCursor(docking.widgets.fieldpanel.support.FieldLocation, int, int)
      • getCursorRect

        public java.awt.Rectangle getCursorRect​(int fieldNum,
                                                int row,
                                                int col)
        Description copied from interface: Layout
        Returns a rectangle which bounds the given cursor position.
        Specified by:
        getCursorRect in interface Layout
        Parameters:
        fieldNum - the index of the field containing the cursor position.
        row - the the text row in the field containing the cursor position.
        col - the character position in the row containing the cursor position.
        See Also:
        Layout.getCursorRect(int, int, int)
      • cursorLeft

        public int cursorLeft​(FieldLocation cursorLoc)
        Description copied from interface: Layout
        Sets the given FieldLocation one position to the left. If already at the left most position, it tries to move to the end of the previous row.
        Specified by:
        cursorLeft in interface Layout
        Parameters:
        cursorLoc - the cursor location object to be modified.
        Returns:
        the x coordinate of the cursor after the operation. Returns -1 if it was already at the top, left most position.
        See Also:
        Layout.cursorLeft(docking.widgets.fieldpanel.support.FieldLocation)
      • cursorRight

        public int cursorRight​(FieldLocation cursorLoc)
        Description copied from interface: Layout
        Sets the given FieldLocation one position to the right. If already at the right most position, it tries to move to the beginning of the next row.
        Specified by:
        cursorRight in interface Layout
        Parameters:
        cursorLoc - the cursor location object to be modified.
        Returns:
        the x coordinate of the cursor after the operation. Returns -1 if it was already at the bottom, right most position.
        See Also:
        Layout.cursorRight(docking.widgets.fieldpanel.support.FieldLocation)
      • getScrollableUnitIncrement

        public int getScrollableUnitIncrement​(int topOfScreen,
                                              int direction)
        Description copied from interface: Layout
        Returns the amount to scroll to reveal the line of text.
        Specified by:
        getScrollableUnitIncrement in interface Layout
        Parameters:
        topOfScreen - the y coordinate that represents the top or bottom of the screen
        direction - the direction to scroll
        See Also:
        Layout.getScrollableUnitIncrement(int, int)
      • contains

        public boolean contains​(int yPos)
        Description copied from interface: Layout
        Returns true if the the given yPos lies within this layout.
        Specified by:
        contains in interface Layout
        Parameters:
        yPos - the vertical coordinate to check if in this layout.
        See Also:
        Layout.contains(int)
      • getPrimaryOffset

        public int getPrimaryOffset()
        Description copied from interface: Layout
        Returns the vertical offset (in pixels) of the start of the primary field in the layout.
        Specified by:
        getPrimaryOffset in interface Layout
        Returns:
        -1 if layout does not have a primary field.
        See Also:
        Layout.getPrimaryOffset()
      • getFieldBounds

        public java.awt.Rectangle getFieldBounds​(int index)
        Description copied from interface: Layout
        Returns the bounds of the given field (in coordinates relative to the layout)
        Specified by:
        getFieldBounds in interface Layout
        Parameters:
        index - the field id for the field for which to get bounds
        See Also:
        Layout.getFieldBounds(int)
      • getBeginRowFieldNum

        public int getBeginRowFieldNum​(int field1)
        Specified by:
        getBeginRowFieldNum in interface Layout
      • getEndRowFieldNum

        public int getEndRowFieldNum​(int field2)
        Specified by:
        getEndRowFieldNum in interface Layout