public abstract class EmulatedWindowState<F,I>
extends java.lang.Object
There should not be any Swing/AWT-specific or Web-specific code in this class.
The actual GUI processing does not heavily utilize the pluggable OutputPrimitives
interface. In other words, the interactive UI processing GUI is not switched in and out like
in ChUI. For this reason, the core output processing in ChUI is driven using the primitives
approach, but in GUI we simply honor the minimum implementation in this class. The majority
of this class is really about providing access to and management of the core window structure.
The primitives implementation is secondary, but the functionality is best implemented here.
Modifier and Type | Field and Description |
---|---|
private ScreenBitmap |
bitmap
The bitmap associated with this simulator.
|
private int |
clips
Track clipping operations.
|
private java.util.Deque<PaintStructure<F,I>> |
graphicPool
Draw operations pools
|
private boolean |
iconified
Track the window's iconified state (which can be set at the OS or P2J level).
|
protected static java.util.logging.Logger |
LOG
Logger.
|
protected MouseHandler |
mouseHandler
The registered mouse handler.
|
private int |
trans
Track translate operations.
|
protected int |
windowId
The window ID associated with this emulated window.
|
Constructor and Description |
---|
EmulatedWindowState(MouseHandler mouseHandler)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
deiconifyWindow(int sourceId)
De-iconify the window.
|
abstract void |
draw(PaintStructure<F,I> ps)
Render the given paint operation.
|
protected void |
drawOnScreenBitmap()
Update screen by iterating over the pool and render each pending operation.
|
abstract void |
enableEvents(boolean capture)
Enable or Disable OS-level events for the specified windows.
|
void |
endBatch()
End a batch drawing routine.
|
abstract void |
flush()
Render the given paint operation.
|
abstract BufferedImageDrawHelper |
getBufferedImageDrawHelper()
Gets the instanve of the helper to work with buffered images.
|
abstract NativeRectangle |
getDisplayBounds()
Returns bounds of a physical screen the top-level window this instance
represents is positioned on.
|
abstract NativeRectangle |
getDisplayWorkArea()
Returns an application-usable display area.
|
abstract FontMetricsHelper |
getFontMetrics(FontDetails<F> font)
Get the metrics of the given font.
|
abstract int |
getHeight()
Get the window height.
|
MouseHandler |
getMouseHandler()
Get the window's mouse handler.
|
abstract int |
getParagraphHeight(java.lang.String text,
FontDetails<F> font,
int maxWidth)
The method performs a layout operation on the supplied text and
returns the resulting paragraph height while maintaining the
supplied maximum width.
|
ScreenBitmap |
getScreenBitmap()
Get the screen bitmap for the current window.
|
abstract int |
getTextHeight(java.lang.String text,
FontDetails<F> font)
Get the height of the specified text, using the given font.
|
abstract int |
getWidth()
Get the window width.
|
int |
getWindowId()
Get the window ID for this simulator.
|
abstract NativePoint |
getWindowLocation()
Get the window location on screen.
|
void |
iconifyWindow(int sourceId,
boolean postEvent)
Iconify the window.
|
boolean |
isIconified()
Check if this window is iconified or not.
|
abstract boolean |
isWindowVisible()
Check if the simulated window is visible.
|
protected abstract java.lang.Object |
lock()
Obtain the lock object that can be used to synchronize drawing operations.
|
void |
offer(PaintStructure<F,I> ps)
Add a new
PaintStructure to the drawing pool. |
abstract void |
quit()
Release resources as the window is being terminated.
|
abstract void |
repaint()
Cause repaint processing to occur.
|
void |
resizeWindow(int width,
int height)
Resize window.
|
int |
screenHeight()
Get the screen height, in character units.
|
int |
screenWidth()
Get the screen width, in character units.
|
void |
setIconificationState(boolean iconify)
Manage any window state related to iconification.
|
void |
setScreenBitmap(ScreenBitmap bitmap)
Set the active screen bitmap for the current window.
|
void |
setWindowBounds(int left,
int top,
int width,
int height)
Resize window.
|
abstract void |
setWindowEnabled(boolean enable)
Set the window' sensitive state, depending on the
enable flag. |
void |
setWindowId(int windowId)
Set the window ID for this simulator.
|
void |
setWindowLocation(int left,
int top)
Set window location.
|
abstract void |
setWindowVisible(boolean visible)
Hide or show the window, depending on the
visible flag. |
protected static final java.util.logging.Logger LOG
protected int windowId
protected MouseHandler mouseHandler
private boolean iconified
private java.util.Deque<PaintStructure<F,I>> graphicPool
private ScreenBitmap bitmap
private int clips
private int trans
public EmulatedWindowState(MouseHandler mouseHandler)
public MouseHandler getMouseHandler()
mouseHandler
.public int screenWidth()
public int screenHeight()
public void setScreenBitmap(ScreenBitmap bitmap)
bitmap
- The screen bitmap.public ScreenBitmap getScreenBitmap()
public void setWindowId(int windowId)
windowId
- The window ID.public int getWindowId()
public void offer(PaintStructure<F,I> ps)
PaintStructure
to the drawing pool.
The item is enqueued at the end of the pool.ps
- A new PaintStructure instance.public void resizeWindow(int width, int height)
width
- new width.height
- new heightpublic void setWindowBounds(int left, int top, int width, int height)
width
- new width.height
- new heightpublic void setWindowLocation(int left, int top)
left
- left coordinatetop
- top coordinatepublic void setIconificationState(boolean iconify)
iconify
- true
if this window is being iconified, false
for
de-iconified.public void iconifyWindow(int sourceId, boolean postEvent)
sourceId
- The root ID of the sub-tree which was iconified, and triggered iconification of
this window.postEvent
- When true
the method posts the WINDOW-MINIMIZED legacy event,
false
means no event is posted.public void deiconifyWindow(int sourceId)
sourceId
- The root ID of the sub-tree which was deiconified, and triggered restoration of
this window.public boolean isIconified()
public void endBatch()
public abstract void enableEvents(boolean capture)
capture
- Flag indicating OS level events are captured (when true
).public abstract NativeRectangle getDisplayBounds()
TopLevelWindow
.
For single-display setups the top-left corner of the returned rectangle is always 0,0. For multiple-display setups it can be 0,0 or positive.
public abstract NativeRectangle getDisplayWorkArea()
public abstract NativePoint getWindowLocation()
public abstract FontMetricsHelper getFontMetrics(FontDetails<F> font)
font
- The font for which the font metrics are to be obtained.public abstract int getTextHeight(java.lang.String text, FontDetails<F> font)
text
- The text.font
- The font used to draw and measure the text.public abstract int getParagraphHeight(java.lang.String text, FontDetails<F> font, int maxWidth)
Note that the algorithm for text layout is compatible with
PaintPrimitives.DRAW_PARAGRAPH
and so
can be used in conjunction with this method.
text
- The text to measure.font
- The font to use during layout.maxWidth
- The maximum paragraph width.public abstract int getHeight()
public abstract int getWidth()
public abstract void draw(PaintStructure<F,I> ps)
ps
- Paint operation details.public abstract void repaint()
public abstract void setWindowVisible(boolean visible)
visible
flag.visible
- The window visibility state.public abstract void setWindowEnabled(boolean enable)
enable
flag.enable
- The window sensitive state.public abstract boolean isWindowVisible()
public abstract void flush()
public abstract void quit()
public abstract BufferedImageDrawHelper getBufferedImageDrawHelper()
protected abstract java.lang.Object lock()
protected void drawOnScreenBitmap()