HTML Parser Home Page

org.htmlparser.lexerapplications.thumbelina
Class Thumbelina

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.htmlparser.lexerapplications.thumbelina.Thumbelina
All Implemented Interfaces:
ItemListener, ImageObserver, MenuContainer, Serializable, Runnable, EventListener, Accessible, ChangeListener, ListSelectionListener, PictureListener

public class Thumbelina
extends JPanel
implements Runnable, ItemListener, ChangeListener, ListSelectionListener, PictureListener

View images behind thumbnails.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean mActive
          Activity state.
protected  JCheckBox mBackgroundToggle
          Background thread checkbox in status bar.
protected  String mCurrentURL
          The URL being currently being examined.
protected  boolean mDiscardCGI
          If true, does not follow links containing cgi calls.
protected  boolean mDiscardQueries
          If true, does not follow links containing queries (?).
protected  JList mHistory
          History list.
protected  JScrollPane mHistoryScroller
          Scroller for the history list.
protected  JSplitPane mMainArea
          Main panel in central area.
protected  PicturePanel mPicturePanel
          The central area for pictures.
protected  JScrollPane mPicturePanelScroller
          Scroller for the picture panel.
protected  JPanel mPowerBar
          Status bar.
protected  PropertyChangeSupport mPropertySupport
          Bound property support.
protected  JProgressBar mQueueProgress
          Image request queue monitor in status bar.
protected  JLabel mQueueSize
          URL queue size display in status bar.
protected  JProgressBar mReadyProgress
          Image ready queue monitor in status bar.
protected  HashMap<String,URL> mRequested
          Images requested.
protected  JCheckBox mRunToggle
          Sequencer thread toggle in status bar.
protected  Sequencer mSequencer
          The picture sequencer.
protected  JSlider mSpeedSlider
          Sequencer speed slider in status bar.
protected  Thread mThread
          Background thread.
protected  HashMap<String,URL> mTracked
          Images being tracked currently.
protected  JTextField mUrlText
          URL report in status bar.
protected  HashMap<String,URL> mVisited
          URL's visited.
protected  JLabel mVisitedSize
          URL visited count display in status bar.
protected static URL[][] NONE
          Value returned when no links are discovered.
static String PROP_CURRENT_URL_PROPERTY
          Property name for current URL binding.
static String PROP_URL_QUEUE_PROPERTY
          Property name for queue size binding.
static String PROP_URL_VISITED_PROPERTY
          Property name for visited URL size binding.
 
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
Thumbelina()
          Creates a new instance of Thumbelina.
Thumbelina(String url)
          Creates a new instance of Thumbelina.
Thumbelina(URL url)
          Creates a new instance of Thumbelina.
 
Method Summary
 void addHistory(String url)
          Adds the given url to the history list.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void append(ArrayList list)
          Append the given URLs to the queue.
 void append(URL url)
          Append the given URL to the queue.
protected  URL[][] extractImageLinks(Lexer lexer, URL docbase)
          Get the links of an element of a document.
protected  void fetch(URL[] images)
          Fetch images.
protected  ArrayList<URL> filter(URL[] urls)
          Filter URLs and add to queue.
 boolean getBackgroundThreadActive()
          Gets the state of the background thread.
 String getCurrentURL()
          Return the URL currently being examined.
 boolean getHistoryListVisible()
          Gets the state of history list visibility.
protected  URL[][] getImageLinks(URL url)
          Get the image links from the current URL.
 PicturePanel getPicturePanel()
          Get the picture panel object encapsulated by this Thumbelina.
 ArrayList<URL> getQueue()
          Getter for property queue.
 int getQueueSize()
          Getter for property queue.
 boolean getSequencerActive()
          Gets the state of the sequencer thread.
 int getSpeed()
          Get the sequencer delay time.
 boolean getStatusBarVisible()
          Gets the state of status bar visibility.
protected static void help()
          Provide command line help.
 boolean isDiscardCGI()
          Getter for property discardCGI.
 boolean isDiscardQueries()
          Getter for property discardQueries.
protected  boolean isImage(String url)
          Check if the url looks like an image.
 void itemStateChanged(ItemEvent event)
          Handle checkbox events from the status bar.
static void main(String[] args)
          Mainline.
protected  void memCheck()
          Check for low memory situation.
 void open(String ref)
          Open a URL.
 void pictureReady(Picture picture)
          Notification for a picture ready for use (loaded into memory).
 void pictureReceived(Picture picture)
          Notification for a download completed.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void reset()
          Reset this Thumbelina.
 void run()
          The main processing loop.
 void setBackgroundThreadActive(boolean active)
          Sets the state of the background thread activity.
protected  void setCurrentURL(String url)
          Set the current URL being examined.
 void setDiscardCGI(boolean discard)
          Setter for property discardCGI.
 void setDiscardQueries(boolean discard)
          Setter for property discardQueries.
 void setHistoryListVisible(boolean visible)
          Sets the history list visibility.
 void setSequencerActive(boolean active)
          Sets the sequencer activity state.
 void setSpeed(int speed)
          Set the sequencer delay time.
 void setStatusBarVisible(boolean visible)
          Sets the status bar visibility.
 void stateChanged(ChangeEvent event)
          Handles the speed slider events.
protected  void updateQueueSize(int original, int current)
          Apply a change in 'to be examined' URL list size.
protected  void updateVisitedSize(int original, int current)
          Apply a change in 'visited' URL list size.
 void valueChanged(ListSelectionEvent event)
          Handles the history list events.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, 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

PROP_CURRENT_URL_PROPERTY

public static final String PROP_CURRENT_URL_PROPERTY
Property name for current URL binding.

See Also:
Constant Field Values

PROP_URL_QUEUE_PROPERTY

public static final String PROP_URL_QUEUE_PROPERTY
Property name for queue size binding.

See Also:
Constant Field Values

PROP_URL_VISITED_PROPERTY

public static final String PROP_URL_VISITED_PROPERTY
Property name for visited URL size binding.

See Also:
Constant Field Values

mVisited

protected HashMap<String,URL> mVisited
URL's visited.


mRequested

protected HashMap<String,URL> mRequested
Images requested.


mTracked

protected HashMap<String,URL> mTracked
Images being tracked currently.


mThread

protected Thread mThread
Background thread.


mActive

protected boolean mActive
Activity state. true means processing URLS, false not.


mSequencer

protected Sequencer mSequencer
The picture sequencer.


mPicturePanel

protected PicturePanel mPicturePanel
The central area for pictures.


NONE

protected static final URL[][] NONE
Value returned when no links are discovered.


mPropertySupport

protected PropertyChangeSupport mPropertySupport
Bound property support.


mCurrentURL

protected String mCurrentURL
The URL being currently being examined.


mDiscardCGI

protected boolean mDiscardCGI
If true, does not follow links containing cgi calls.


mDiscardQueries

protected boolean mDiscardQueries
If true, does not follow links containing queries (?).


mBackgroundToggle

protected JCheckBox mBackgroundToggle
Background thread checkbox in status bar.


mHistory

protected JList mHistory
History list.


mPicturePanelScroller

protected JScrollPane mPicturePanelScroller
Scroller for the picture panel.


mHistoryScroller

protected JScrollPane mHistoryScroller
Scroller for the history list.


mMainArea

protected JSplitPane mMainArea
Main panel in central area.


mPowerBar

protected JPanel mPowerBar
Status bar.


mQueueProgress

protected JProgressBar mQueueProgress
Image request queue monitor in status bar.


mReadyProgress

protected JProgressBar mReadyProgress
Image ready queue monitor in status bar.


mRunToggle

protected JCheckBox mRunToggle
Sequencer thread toggle in status bar.


mSpeedSlider

protected JSlider mSpeedSlider
Sequencer speed slider in status bar.


mUrlText

protected JTextField mUrlText
URL report in status bar.


mQueueSize

protected JLabel mQueueSize
URL queue size display in status bar.


mVisitedSize

protected JLabel mVisitedSize
URL visited count display in status bar.

Constructor Detail

Thumbelina

public Thumbelina()
Creates a new instance of Thumbelina.


Thumbelina

public Thumbelina(String url)
           throws MalformedURLException
Creates a new instance of Thumbelina.

Parameters:
url - Single URL to enter into the 'to follow' list.
Throws:
MalformedURLException - If the url is malformed.

Thumbelina

public Thumbelina(URL url)
Creates a new instance of Thumbelina.

Parameters:
url - URL to enter into the 'to follow' list.
Method Detail

memCheck

protected void memCheck()
Check for low memory situation. Report to the user a bad situation.


reset

public void reset()
Reset this Thumbelina. Clears the sequencer of pending images, resets the picture panel, emptiies the 'to be examined' list of URLs.


append

public void append(URL url)
Append the given URL to the queue. Adds the url only if it isn't already in the queue, and notifys listeners about the addition.

Parameters:
url - The url to add.

append

public void append(ArrayList list)
Append the given URLs to the queue.

Parameters:
list - The list of URL objects to add.

filter

protected ArrayList<URL> filter(URL[] urls)
Filter URLs and add to queue. Removes already visited links and appends the rest (if any) to the visit pending list.

Parameters:
urls - The list of URL's to add to the 'to visit' list.
Returns:
Returns the filered list.

getStatusBarVisible

public boolean getStatusBarVisible()
Gets the state of status bar visibility.

Returns:
true if the status bar is visible.

setStatusBarVisible

public void setStatusBarVisible(boolean visible)
Sets the status bar visibility.

Parameters:
visible - The new visibility state. If true, the status bar will be unhidden.

getHistoryListVisible

public boolean getHistoryListVisible()
Gets the state of history list visibility.

Returns