de.uni_paderborn.fujaba.app
Class ScrollPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
de.uni_paderborn.fujaba.app.ScrollPanel
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable
- public class ScrollPanel
- extends javax.swing.JPanel
- implements java.lang.Runnable
The ScrollPanel class implements a Panel that scrolls text blocks defined in a script from
bottom to the top of the panel. It extends from JPanel and implements Runnable for the scrolling
purposes. ScrollPanel uses the class Container to read a script. A script contains descriptions
of text blocks, a block starts with and ends with in the script. Every
block can hold an unlimited number of text lines which will be formated automatically during
the parsing of the script. The user can start a new line using the command, define
a Title with ... and set a subtitle line with ...
.
- Version:
- $Revision: 1.27 $
- Author:
- $Author: lowende $
- See Also:
- Serialized Form
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 |
private java.awt.Color |
backgrCol
Contains the background color |
private BlockContainer |
cont
Contains a BlockContainer that reads the script and holds all blocks of text |
private java.lang.Thread |
cthread
The thread to scroll the text |
private int |
currBlock
Contains the current block that's scrolled through the panel |
private int |
delay
Contains the delay (in ms) for the scrolling (scrolling speed, 20-30 ms is a good value) |
private java.lang.String |
file
No comment provided by developer, please add a comment to improve documentation. |
private boolean |
initialize
Flag for initialisation purposes of mainImg and mainMap |
(package private) boolean |
inpanel
Flag for the status symbol display (play, pause symbol) true if the mouse is in the panel
(and the status is displayed) |
private java.awt.Image |
mainImg
The Image of the scrolling area. |
private java.awt.Graphics |
mainMap
The Graphics object of mainImg |
(package private) boolean |
pause
Flag for pause function |
private int |
scrollHeight
The size of the scrolling area in the panel |
private int |
scrollWidth
The size of the scrolling area in the panel |
private java.awt.Color |
shadowCol
Contains the text shadow color |
(package private) int |
startPos
Contains the starting point of the displayed block in pixel. startPos = 0 the top of
the block is at the top of the Panel startPos = this.getHeight the top of the block is
at the bottom of the panel (and so nothing is displayed) startPos = - getBlockHeight()
the bottom of the block is at the top of the panel (and so nothing is displayed) |
private java.awt.Font |
subtitleF
No comment provided by developer, please add a comment to improve documentation. |
private java.awt.Color |
symbolCol
Contains the symbol color |
private java.awt.Font |
textF
No comment provided by developer, please add a comment to improve documentation. |
private java.awt.Font |
titleF
Hard coded font styles for title, text and subtitle |
(package private) int |
xmouse
Absolute and relative mouse coordinates for the mouseScroller [TM] |
(package private) int |
ydiff
Absolute and relative mouse coordinates for the mouseScroller [TM] |
(package private) int |
ymouse
Absolute and relative mouse coordinates for the mouseScroller [TM] |
Fields inherited from class javax.swing.JPanel |
|
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.Container |
|
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 |
ScrollPanel(int width,
int height,
int delay,
java.lang.String file)
Constructs a new ScrollPanel with the specified parameters |
Method Summary |
private void |
clearimg(java.awt.Graphics g)
Clears the provided Graphics area |
private void |
displayBlock(java.awt.Graphics g,
Block block,
int startYPos)
Displays a block with the provided position in the ScrollPanel |
private boolean |
isParentVisible()
Checks if the parent components of ScrollPanel are visible |
void |
paintComponent(java.awt.Graphics g)
Paints the ScrollPanel |
void |
run()
Starts the scroll thread |
private void |
scrollCont(java.awt.Graphics g)
Scrolls all blocks in the Container in a loop |
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, 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 |
startPos
int startPos
- Contains the starting point of the displayed block in pixel. startPos = 0 the top of
the block is at the top of the Panel startPos = this.getHeight the top of the block is
at the bottom of the panel (and so nothing is displayed) startPos = - getBlockHeight()
the bottom of the block is at the top of the panel (and so nothing is displayed)
currBlock
private int currBlock
- Contains the current block that's scrolled through the panel
delay
private int delay
- Contains the delay (in ms) for the scrolling (scrolling speed, 20-30 ms is a good value)
scrollWidth
private int scrollWidth
- The size of the scrolling area in the panel
scrollHeight
private int scrollHeight
- The size of the scrolling area in the panel
xmouse
int xmouse
- Absolute and relative mouse coordinates for the mouseScroller [TM]
ymouse
int ymouse
- Absolute and relative mouse coordinates for the mouseScroller [TM]
ydiff
int ydiff
- Absolute and relative mouse coordinates for the mouseScroller [TM]
pause
boolean pause
- Flag for pause function
inpanel
boolean inpanel
- Flag for the status symbol display (play, pause symbol) true if the mouse is in the panel
(and the status is displayed)
initialize
private boolean initialize
- Flag for initialisation purposes of mainImg and mainMap
shadowCol
private java.awt.Color shadowCol
- Contains the text shadow color
symbolCol
private java.awt.Color symbolCol
- Contains the symbol color
backgrCol
private java.awt.Color backgrCol
- Contains the background color
mainImg
private java.awt.Image mainImg
- The Image of the scrolling area. JPanel supports DoubleBuffering, so we don't need to
DoubleBuffer the scroll area
mainMap
private java.awt.Graphics mainMap
- The Graphics object of mainImg
titleF
private java.awt.Font titleF
- Hard coded font styles for title, text and subtitle
textF
private java.awt.Font textF
- No comment provided by developer, please add a comment to improve documentation.
subtitleF
private java.awt.Font subtitleF
- No comment provided by developer, please add a comment to improve documentation.
cthread
private java.lang.Thread cthread
- The thread to scroll the text
cont
private BlockContainer cont
- Contains a BlockContainer that reads the script and holds all blocks of text
file
private java.lang.String file
- No comment provided by developer, please add a comment to improve documentation.
ScrollPanel
public ScrollPanel(int width,
int height,
int delay,
java.lang.String file)
- Constructs a new ScrollPanel with the specified parameters
- Parameters:
width
- the width of the ScrollPanelheight
- the height of the ScrollPaneldelay
- the scroll delay of the ScrollPanel in ms (20 - 35 ms is a good value)file
- the script file
run
public void run()
- Starts the scroll thread
- Specified by:
run
in interface java.lang.Runnable
isParentVisible
private boolean isParentVisible()
- Checks if the parent components of ScrollPanel are visible
- Returns:
- True if parent components are visible
clearimg
private void clearimg(java.awt.Graphics g)
- Clears the provided Graphics area
- Parameters:
g
- Graphics object
displayBlock
private void displayBlock(java.awt.Graphics g,
Block block,
int startYPos)
- Displays a block with the provided position in the ScrollPanel
- Parameters:
g
- No description providedblock
- No description providedstartYPos
- No description provided
scrollCont
private void scrollCont(java.awt.Graphics g)
- Scrolls all blocks in the Container in a loop
- Parameters:
g
- Graphics object of the mainImg
paintComponent
public void paintComponent(java.awt.Graphics g)
- Paints the ScrollPanel
- Parameters:
g
- No description provided