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

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

public class RenderStateManager
extends java.lang.Object

Encapsulates the state for rendering a Buffer instance.


Field Summary
private  Buffer buffer
          The rendered buffer.
private  BufferListener bufferListener
          The listener to re-render the window contents after changes.
private  boolean lastCanScrollDown
           
private  boolean lastCanScrollUp
           
private  int lastScrollPos
          The position in pixels of the viewable window.
private  int lastTopIndex
          The first line of buffer to display.
private  int lastTopOffset
          The number of pixels to shift the first displayed line.
private  RenderState renderState
           
private  RenderStateListener renderStateListener
          The listener to notify about state changes.
 
Constructor Summary
RenderStateManager(RenderStateListener renderStateListener, Buffer buffer)
          Create a new instance.
 
Method Summary
 boolean canScrollDown()
          Whether scrolling down is possible.
 boolean canScrollUp()
          Whether scrolling up is possible.
 void dispose()
           
private  void fireChanges()
           
 int getScrollPos()
           
 int getTopIndex()
          Return the first line to render.
 int getTopOffset()
          Return the pixel offset for the first line to render.
 void resetScroll()
          Reset the scrolling range to default values.
 void scrollDown(int dy)
          Scroll down by pixels.
 void scrollTo(int y)
          Scroll to a location.
 void scrollUp(int dy)
          Scroll up by pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

@NotNull
private final Buffer buffer
The rendered buffer.


bufferListener

@NotNull
private final BufferListener bufferListener
The listener to re-render the window contents after changes.


lastCanScrollDown

private boolean lastCanScrollDown

lastCanScrollUp

private boolean lastCanScrollUp

lastScrollPos

private int lastScrollPos
The position in pixels of the viewable window. May be negative if not enough lines are present to fill the whole window.


lastTopIndex

private int lastTopIndex
The first line of buffer to display.


lastTopOffset

private int lastTopOffset
The number of pixels to shift the first displayed line.


renderState

@NotNull
private final RenderState renderState

renderStateListener

@NotNull
private final RenderStateListener renderStateListener
The listener to notify about state changes.

Constructor Detail

RenderStateManager

public RenderStateManager(@NotNull
                          RenderStateListener renderStateListener,
                          @NotNull
                          Buffer buffer)
Create a new instance.

Parameters:
renderStateListener - The listener to notify about state changes.
buffer - The rendered buffer.
Method Detail

canScrollDown

public boolean canScrollDown()
Whether scrolling down is possible.

Returns:
whether scrolling down is possible

canScrollUp

public boolean canScrollUp()
Whether scrolling up is possible.

Returns:
whether scrolling up is possible

dispose

public void dispose()

fireChanges

private void fireChanges()

getScrollPos

public int getScrollPos()

getTopIndex

public int getTopIndex()
Return the first line to render.

Returns:
The line index.

getTopOffset

public int getTopOffset()
Return the pixel offset for the first line to render.

Returns:
The pixel offset.

resetScroll

public void resetScroll()
Reset the scrolling range to default values.


scrollDown

public void scrollDown(int dy)
Scroll down by pixels.

Parameters:
dy - The number of pixels to scroll.

scrollTo

public void scrollTo(int y)
Scroll to a location.

Parameters:
y - The location.

scrollUp

public void scrollUp(int dy)
Scroll up by pixels.

Parameters:
dy - The number of pixels to scroll.