com.realtime.crossfire.jxclient.gui.log
Class RenderState

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.log.RenderState

public class RenderState
extends java.lang.Object

Encapsulates the state for a scroll bar. The first line shown is the line index topIndex. If topOffset is non-zero, it should be shifted by this number of pixels. The current scrolling position is scrollPos.


Field Summary
private  boolean canScrollDown
          Whether scrolling down is possible.
private  boolean canScrollUp
          Whether scrolling up is possible.
private  int height
          The height of the viewable area.
private  boolean mustRepaint
          Whether the view has to be repainted even if no other value has changed.
private  int scrollPos
          The location of the view area relative to the buffer's total height.
private  java.lang.Object sync
          Synchronization object for accesses to all fields.
private  int topIndex
          The first line to display in the viewable area.
private  int topOffset
          The number of pixels to shift the first displayed line (topIndex.
 
Constructor Summary
RenderState()
           
 
Method Summary
 boolean canScrollDown()
          Returns whether scrolling down is possible.
 boolean canScrollUp()
          Returns whether scrolling up is possible.
 int getScrollPos()
          Returns the location of the view area in pixels.
 int getTopIndex()
          Returns the index of the first line to display.
 int getTopOffset()
          Returns the number of pixels to shift the first displayed line.
 void linesAdded(Buffer buffer)
          Some lines have been added to the buffer.
 void linesRemoved(Buffer buffer, java.util.Collection<Line> lines)
          Some lines have been removed from the buffer.
 void linesReplaced(Buffer buffer)
          Some lines have been replaced at the end of the buffer.
 boolean mustRepaint()
          Returns whether the view should be repainted even if no other values have changed.
 void scrollTo(Buffer buffer, int y)
          Scrolls to the given pixel location.
 void scrollToBottom(Buffer buffer)
          Sets the view area to the bottom-most value.
 void setHeight(Buffer buffer, int h)
          Sets the the viewable height in pixel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canScrollDown

private boolean canScrollDown
Whether scrolling down is possible.


canScrollUp

private boolean canScrollUp
Whether scrolling up is possible.


height

private int height
The height of the viewable area.


mustRepaint

private boolean mustRepaint
Whether the view has to be repainted even if no other value has changed.


scrollPos

private int scrollPos
The location of the view area relative to the buffer's total height.


sync

@NotNull
private final java.lang.Object sync
Synchronization object for accesses to all fields.


topIndex

private int topIndex
The first line to display in the viewable area. It is shifted by topOffset pixels.


topOffset

private int topOffset
The number of pixels to shift the first displayed line (topIndex. Positive values shift up, negative shift down. It's value is either between zero and less than the height of line topIndex, or it is negative if the rendered buffer does not contain enough lines to fill the view area.

Constructor Detail

RenderState

public RenderState()
Method Detail

canScrollDown

public boolean canScrollDown()
Returns whether scrolling down is possible.

Returns:
whether scrolling down is possible

canScrollUp

public boolean canScrollUp()
Returns whether scrolling up is possible.

Returns:
whether scrolling up is possible

getScrollPos

public int getScrollPos()
Returns the location of the view area in pixels.

Returns:
the location

getTopIndex

public int getTopIndex()
Returns the index of the first line to display.

Returns:
the line index

getTopOffset

public int getTopOffset()
Returns the number of pixels to shift the first displayed line.

Returns:
the pixel offset

linesAdded

public void linesAdded(@NotNull
                       Buffer buffer)
Some lines have been added to the buffer.

Parameters:
buffer - the displayed buffer

linesRemoved

public void linesRemoved(@NotNull
                         Buffer buffer,
                         @NotNull
                         java.util.Collection<Line> lines)
Some lines have been removed from the buffer.

Parameters:
buffer - the displayed buffer
lines - the number of lines that have been remove

linesReplaced

public void linesReplaced(@NotNull
                          Buffer buffer)
Some lines have been replaced at the end of the buffer.

Parameters:
buffer - the displayed buffer

mustRepaint

public boolean mustRepaint()
Returns whether the view should be repainted even if no other values have changed. This function resets the flag; calling the function twice returns false in the second call (if no other changes happen concurrently).

Returns:
whether the view should be repainted

scrollTo

public void scrollTo(@NotNull
                     Buffer buffer,
                     int y)
Scrolls to the given pixel location.

Parameters:
buffer - the displayed buffer
y - the new location

scrollToBottom

public void scrollToBottom(@NotNull
                           Buffer buffer)
Sets the view area to the bottom-most value.

Parameters:
buffer - the displayed buffer

setHeight

public void setHeight(@NotNull
                      Buffer buffer,
                      int h)
Sets the the viewable height in pixel.

Parameters:
buffer - the displayed buffer
h - the viewable height