edu.washington.cs.supple.wlib.java2
Class SwingView

java.lang.Object
  extended byedu.washington.cs.supple.render.AbstractRenderedView
      extended byedu.washington.cs.supple.wlib.java2.SwingView
All Implemented Interfaces:
java.util.EventListener, RenderedView, SolverListener

public class SwingView
extends AbstractRenderedView
implements SolverListener

Author:
kgajos This class is used to contain and represent UI windows rendered in Swing. It can be used both for the main application windows and for dialog boxes.

Field Summary
protected  boolean allowExpand
          Expand the available size if ui can't be solved.
protected  java.awt.Dimension availableSize
          How much space is available to display ui
protected  java.awt.Container container
          Ui container.
protected  Solution currentSolution
           
protected  boolean freeze
          If false, re-render ui on parent window resize.
protected  java.util.List listeners
          Listeners
protected  java.awt.Dimension maxAvailableSize
          How much space can be used if available space is not enough.
protected  java.awt.Dimension minAvailableSize
          How much space should be used if container is too small.
protected  boolean rendering
           
protected  java.awt.Dimension solutionSize
          Current solution size.
protected  Solver solverOverride
           
protected  WidgetFactory widgetFactory
           
protected  java.awt.Window window
          Window created to view ui (may be null - meaning container was provided).
 
Constructor Summary
SwingView(SwingRenderer renderer, SwingView parent, UiObject object, java.awt.Container container)
          Construct a Swing view.
 
Method Summary
 void addSwingViewListener(SwingViewListener l)
          Add a listener.
protected  void availableScreenSizeChanged(java.awt.Dimension newSize)
           
protected  javax.swing.JMenuBar buildMenuBar()
          Create a menu bar for the SwingView window (if any).
 boolean dismiss()
          Dismisses the view
protected  void displaySolution(Solution soln)
          Called when solutions are made available.
protected  void ensureContainer()
          Make sure the ui container exists
protected  void ensureMinimumAvailableSize()
          Make sure available size is greater than or equal to the minimum available size.
 boolean expand(double horizontal, double vertical)
          Expand availableSize along given dimen
 boolean getAllowExpand()
           
 boolean getFreeze()
           
 java.awt.Dimension getMaxAvailableSize()
           
 java.awt.Dimension getMinAvailableSize()
           
 Solver getSolverOverride()
           
 WidgetFactory getWidgetFactory()
          Returns the widget factory override set for this view
protected  java.awt.Window getWindow()
          Get the contained window (if it exists).
 boolean isVisible()
           
 void removeSwingViewListener(SwingViewListener l)
          Remove a listener.
protected  void render()
          Override to implement rendering
 void rerender()
          Re-render the ui, possibly adapting the frame size.
 void setAllowExpand(boolean value, java.awt.Dimension maxSize)
           
 void setFreeze(boolean value)
          Change the value of freeze.
 void setMinAvailableSize(java.awt.Dimension minSize)
           
 void setSolverOverride(Solver solverOverride)
           
 void setWidgetFactory(WidgetFactory factory)
          Allows you to override the default widget factory used on this device
 void solutionAvailable(Solution solution)
          This method is called when the search comes up with an improvement to the interface -- allows the listener to use the partial results
 
Methods inherited from class edu.washington.cs.supple.render.AbstractRenderedView
closed, getParentView, getRenderer, getUiObject, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

availableSize

protected java.awt.Dimension availableSize
How much space is available to display ui


solutionSize

protected java.awt.Dimension solutionSize
Current solution size.


allowExpand

protected boolean allowExpand
Expand the available size if ui can't be solved.


minAvailableSize

protected java.awt.Dimension minAvailableSize
How much space should be used if container is too small.


maxAvailableSize

protected java.awt.Dimension maxAvailableSize
How much space can be used if available space is not enough.


freeze

protected boolean freeze
If false, re-render ui on parent window resize.


window

protected java.awt.Window window
Window created to view ui (may be null - meaning container was provided).


container

protected java.awt.Container container
Ui container.


listeners

protected java.util.List listeners
Listeners


solverOverride

protected Solver solverOverride

widgetFactory

protected WidgetFactory widgetFactory

rendering

protected volatile boolean rendering

currentSolution

protected Solution currentSolution
Constructor Detail

SwingView

public SwingView(SwingRenderer renderer,
                 SwingView parent,
                 UiObject object,
                 java.awt.Container container)
Construct a Swing view.

Method Detail

dismiss

public boolean dismiss()
Description copied from interface: RenderedView
Dismisses the view

Specified by:
dismiss in interface RenderedView
Overrides:
dismiss in class AbstractRenderedView

isVisible

public boolean isVisible()

getWindow

protected java.awt.Window getWindow()
Get the contained window (if it exists).

Returns:

render

protected void render()
Description copied from class: AbstractRenderedView
Override to implement rendering

Specified by:
render in class AbstractRenderedView

expand

public boolean expand(double horizontal,
                      double vertical)
Expand availableSize along given dimen

Returns:
true if expansion succeeded.

rerender

public void rerender()
Re-render the ui, possibly adapting the frame size.


solutionAvailable

public void solutionAvailable(Solution solution)
Description copied from interface: SolverListener
This method is called when the search comes up with an improvement to the interface -- allows the listener to use the partial results

Specified by:
solutionAvailable in interface SolverListener

displaySolution

protected void displaySolution(Solution soln)
Called when solutions are made available.


ensureContainer

protected void ensureContainer()
Make sure the ui container exists


ensureMinimumAvailableSize

protected void ensureMinimumAvailableSize()
Make sure available size is greater than or equal to the minimum available size.


buildMenuBar

protected javax.swing.JMenuBar buildMenuBar()
Create a menu bar for the SwingView window (if any).


availableScreenSizeChanged

protected void availableScreenSizeChanged(java.awt.Dimension newSize)

getWidgetFactory

public WidgetFactory getWidgetFactory()
Returns the widget factory override set for this view

Returns:
the widget factory override

setWidgetFactory

public void setWidgetFactory(WidgetFactory factory)
Allows you to override the default widget factory used on this device

Parameters:
factory - a widget factory override

getSolverOverride

public Solver getSolverOverride()
Returns:
Returns the solverOverride.

setSolverOverride

public void setSolverOverride(Solver solverOverride)
Parameters:
solverOverride - The solverOverride to set.

getFreeze

public boolean getFreeze()
Returns:
Returns the value of freeze.

setFreeze

public void setFreeze(boolean value)
Change the value of freeze. Will not force a re-render.

Parameters:
value - The value to set.

getMinAvailableSize

public java.awt.Dimension getMinAvailableSize()
Returns:
returns the minimum size.

setMinAvailableSize

public void setMinAvailableSize(java.awt.Dimension minSize)
Parameters:
minSize -

getAllowExpand

public boolean getAllowExpand()
Returns:
returns whether expansion is allowed when rendering.

getMaxAvailableSize

public java.awt.Dimension getMaxAvailableSize()
Returns:
returns max size for expansion.

setAllowExpand

public void setAllowExpand(boolean value,
                           java.awt.Dimension maxSize)
Parameters:
value -
maxSize -

addSwingViewListener

public void addSwingViewListener(SwingViewListener l)
Add a listener.

Parameters:
l -

removeSwingViewListener

public void removeSwingViewListener(SwingViewListener l)
Remove a listener.

Parameters:
l -