Class FlowView.FlowStrategy

java.lang.Object
javax.swing.text.FlowView.FlowStrategy
Enclosing class:
FlowView

public static class FlowView.FlowStrategy extends Object
Strategy for maintaining the physical form of the flow. The default implementation is completely stateless, and recalculates the entire flow if the layout is invalid on the given FlowView. Alternative strategies can be implemented by subclassing, and might perform incremental repair to the layout or alternative breaking behavior.
Since:
1.3
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a FlowStrategy.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    adjustRow(FlowView fv, int rowIndex, int desiredSpan, int x)
    Adjusts the given row if possible to fit within the layout span.
    void
    Gives notification from the document that attributes were changed in a location that this view is responsible for.
    protected View
    createView(FlowView fv, int startOffset, int spanLeft, int rowIndex)
    Creates a view that can be used to represent the current piece of the flow.
    protected View
    This method gives flow strategies access to the logical view of the FlowView.
    void
    Gives notification that something was inserted into the document in a location that the given flow view is responsible for.
    void
    Update the flow on the given FlowView.
    protected int
    layoutRow(FlowView fv, int rowIndex, int pos)
    Creates a row of views that will fit within the layout span of the row.
    void
    Gives notification that something was removed from the document in a location that the given flow view is responsible for.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    Answers a string containing a concise, human-readable description of the receiver.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Constructor Details

    • FlowStrategy

      public FlowStrategy()
      Constructs a FlowStrategy.
  • Method Details

    • insertUpdate

      public void insertUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
      Gives notification that something was inserted into the document in a location that the given flow view is responsible for. The strategy should update the appropriate changed region (which depends upon the strategy used for repair).
      Parameters:
      fv - the flow view
      e - the change information from the associated document
      alloc - the current allocation of the view inside of the insets. This value will be null if the view has not yet been displayed.
      See Also:
    • removeUpdate

      public void removeUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
      Gives notification that something was removed from the document in a location that the given flow view is responsible for.
      Parameters:
      fv - the flow view
      e - the change information from the associated document
      alloc - the current allocation of the view inside of the insets.
      See Also:
    • changedUpdate

      public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
      Gives notification from the document that attributes were changed in a location that this view is responsible for.
      Parameters:
      fv - the FlowView containing the changes
      e - the DocumentEvent describing the changes done to the Document
      alloc - Bounds of the View
      See Also:
    • getLogicalView

      protected View getLogicalView(FlowView fv)
      This method gives flow strategies access to the logical view of the FlowView.
      Parameters:
      fv - the FlowView
      Returns:
      the logical view of the FlowView
    • layout

      public void layout(FlowView fv)
      Update the flow on the given FlowView. By default, this causes all of the rows (child views) to be rebuilt to match the given constraints for each row. This is called by a FlowView.layout to update the child views in the flow.
      Parameters:
      fv - the view to reflow
    • layoutRow

      protected int layoutRow(FlowView fv, int rowIndex, int pos)
      Creates a row of views that will fit within the layout span of the row. This is called by the layout method. This is implemented to fill the row by repeatedly calling the createView method until the available span has been exhausted, a forced break was encountered, or the createView method returned null. If the remaining span was exhausted, the adjustRow method will be called to perform adjustments to the row to try and make it fit into the given span.
      Parameters:
      fv - the flow view
      rowIndex - the index of the row to fill in with views. The row is assumed to be empty on entry.
      pos - The current position in the children of this views element from which to start.
      Returns:
      the position to start the next row
    • adjustRow

      protected void adjustRow(FlowView fv, int rowIndex, int desiredSpan, int x)
      Adjusts the given row if possible to fit within the layout span. By default this will try to find the highest break weight possible nearest the end of the row. If a forced break is encountered, the break will be positioned there.
      Parameters:
      fv - the flow view
      rowIndex - the row to adjust to the current layout span.
      desiredSpan - the current layout span >= 0
      x - the location r starts at.
    • createView

      protected View createView(FlowView fv, int startOffset, int spanLeft, int rowIndex)
      Creates a view that can be used to represent the current piece of the flow. This can be either an entire view from the logical view, or a fragment of the logical view.
      Parameters:
      fv - the view holding the flow
      startOffset - the start location for the view being created
      spanLeft - the about of span left to fill in the row
      rowIndex - the row the view will be placed into
      Returns:
      a view that can be used to represent the current piece of the flow