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

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.washington.cs.supple.wlib.java2.AdaptivePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, SolverListener

public class AdaptivePanel
extends javax.swing.JPanel
implements SolverListener

Author:
kgajos
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Component curComponent
           
protected  Solution currentSolution
           
protected  long defaultDelay
           
protected  boolean freeze
           
protected  java.awt.Dimension lastSize
           
protected  UiObject object
           
protected  javax.swing.JScrollPane scroll
           
protected  java.lang.Thread searchThread
          The current search thread
protected  Solver solver
           
protected  java.util.Timer timer
           
protected  AdaptivePanelVisitor visitor
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AdaptivePanel(UiObject object2)
           
 
Method Summary
 UiObject getUiObject()
           
 boolean redraw(java.awt.Dimension size)
          Recomputes the layout and redraws the panel immediatelly
protected  void renderSolution(Widget root, Solution solution)
           
protected  void setComponent(java.awt.Component c, Solution solution)
          Sets the content of this panel
 void setFreeze(boolean f)
           
 void setUiObject(UiObject object)
          Let's you set the object to be rendered
 void setVisitor(AdaptivePanelVisitor visitor)
           
 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
 void stopCurrentSearch()
          Stops current search thread if one is currently running
 void triggerRedraw()
           
protected  void triggerRedraw(java.awt.Dimension size, long delay)
          A call to this function will cause the panel to be redesigned and redrawn within the amount specified by the delay.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

solver

protected Solver solver

object

protected UiObject object

lastSize

protected java.awt.Dimension lastSize

defaultDelay

protected long defaultDelay

freeze

protected boolean freeze

currentSolution

protected Solution currentSolution

curComponent

protected java.awt.Component curComponent

visitor

protected AdaptivePanelVisitor visitor

searchThread

protected java.lang.Thread searchThread
The current search thread


timer

protected java.util.Timer timer

scroll

protected javax.swing.JScrollPane scroll
Constructor Detail

AdaptivePanel

public AdaptivePanel(UiObject object2)
Method Detail

setFreeze

public void setFreeze(boolean f)

stopCurrentSearch

public void stopCurrentSearch()
Stops current search thread if one is currently running


setUiObject

public void setUiObject(UiObject object)
Let's you set the object to be rendered

Parameters:
object - the new UI description

getUiObject

public UiObject getUiObject()
Returns:
the current UI object

triggerRedraw

public void triggerRedraw()

triggerRedraw

protected void triggerRedraw(java.awt.Dimension size,
                             long delay)
A call to this function will cause the panel to be redesigned and redrawn within the amount specified by the delay. If this method is called again before the delay elapses, the redrawing is postponed. This method is here to make sure that when the panel is being interactively resized, we wait for the end of the operation before we act. Redrawing happens in a separate thread so it is safe to call this method from inside a Swing event processing thread.

Parameters:
size - the new size of the panel
delay - time, in milliseconds, to wait before redrawing the panel

redraw

public boolean redraw(java.awt.Dimension size)
Recomputes the layout and redraws the panel immediatelly

Returns:
true if a rendition was found, false otherwise

renderSolution

protected void renderSolution(Widget root,
                              Solution solution)

setComponent

protected void setComponent(java.awt.Component c,
                            Solution solution)
Sets the content of this panel


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

setVisitor

public void setVisitor(AdaptivePanelVisitor visitor)