edu.princeton.swing
Class PHighlightedTextArea.InternalTextArea

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by edu.princeton.swing.PHighlightedTextArea.InternalTextArea
All Implemented Interfaces:
ClipboardTarget, HighlightedDocumentRenderer, ImageObserver, MenuContainer, Serializable, Runnable, Scrollable
Enclosing class:
PHighlightedTextArea

protected class PHighlightedTextArea.InternalTextArea
extends JComponent
implements Runnable, HighlightedDocumentRenderer, Scrollable, ClipboardTarget

InternalTextArea is the subcomponent of PHighlightedTextArea which shows the editable program code.

See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
protected PHighlightedTextArea.InternalTextArea()
           
 
Method Summary
 boolean canCopy()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 boolean canCut()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 boolean canPaste()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 boolean canSelectAll()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 void copy()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 void cut()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 void doRender(char[] chars, byte[] charStyles, int charCount, short[] lineOffsets, int lineCount, Object extraInfo)
          Paints the TextArea using the protected data of the document.
 Dimension getPreferredScrollableViewportSize()
          Implement scrollable to make the viewport's preferred size that of the InternalTextArea's.
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
          Implement scrollable to make the block increment a full page.
 boolean getScrollableTracksViewportHeight()
          Implement scrollable to make the InternalTextArea's size the greater of its own size and its viewport's size.
 boolean getScrollableTracksViewportWidth()
          Implement scrollable to make the InternalTextArea's size the greater of its own size and its viewport's size.
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
          Implement scrollable to make the unit increment a tenth of a page.
 boolean isFocusTraversable()
           
 boolean isManagingFocus()
           
 void paintComponent(Graphics g)
          Override the paintComponent() function of JComponent.
 void paste()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
protected  void processFocusEvent(FocusEvent e)
          Intercept FocusEvents to notify the ClipboardTargetManager of the event.
protected  void processKeyEvent(KeyEvent e)
          Intercept KeyEvents to perform the usual action.
protected  void processMouseEvent(MouseEvent e)
          Intercept mouse clicks to perform the usual action.
protected  void processMouseMotionEvent(MouseEvent e)
          Intercept mouse dragging to perform the usual action.
 void run()
          Implement runnable to blink the caret.
 void selectAll()
          Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, 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, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, 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
 

Constructor Detail

PHighlightedTextArea.InternalTextArea

protected PHighlightedTextArea.InternalTextArea()
Method Detail

isManagingFocus

public boolean isManagingFocus()
Overrides:
isManagingFocus in class JComponent
See Also:
JComponent.isManagingFocus()

isFocusTraversable

public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class Component
See Also:
Component.isFocusTraversable()

paintComponent

public void paintComponent(Graphics g)
Override the paintComponent() function of JComponent.

Overrides:
paintComponent in class JComponent

canCut

public boolean canCut()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
canCut in interface ClipboardTarget
Returns:
True iff a call to cut() should be permitted.

cut

public void cut()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
cut in interface ClipboardTarget

canCopy

public boolean canCopy()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
canCopy in interface ClipboardTarget
Returns:
True iff a call to copy() should be permitted.

copy

public void copy()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
copy in interface ClipboardTarget

canPaste

public boolean canPaste()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
canPaste in interface ClipboardTarget
Returns:
True iff a call to paste() should be permitted.

paste

public void paste()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
paste in interface ClipboardTarget

canSelectAll

public boolean canSelectAll()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
canSelectAll in interface ClipboardTarget
Returns:
True iff a call to selectAll() should be permitted.

selectAll

public void selectAll()
Implement ClipboardTarget to pass clipboard requests to the JHighlghtedTextArea.

Specified by:
selectAll in interface ClipboardTarget

doRender

public void doRender(char[] chars,
                     byte[] charStyles,
                     int charCount,
                     short[] lineOffsets,
                     int lineCount,
                     Object extraInfo)
Paints the TextArea using the protected data of the document.

Specified by:
doRender in interface HighlightedDocumentRenderer
Parameters:
chars - The characters in the document.
charStyles - The style index of each character in the document.
charCount - The number of characters in the document.
lineOffsets - The offsets of the first character of each line.
lineCount - The number of lines in the document.
extraInfo - The graphics object on which to paint.
See Also:
HighlightedDocument.allowRender(HighlightedDocumentRenderer, Object)

run

public void run()
Implement runnable to blink the caret.

Specified by:
run in interface Runnable

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Implement scrollable to make the viewport's preferred size that of the InternalTextArea's.

Specified by:
getPreferredScrollableViewportSize in interface Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Implement scrollable to make the unit increment a tenth of a page.

Specified by:
getScrollableUnitIncrement in interface Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Implement scrollable to make the block increment a full page.

Specified by:
getScrollableBlockIncrement in interface Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Implement scrollable to make the InternalTextArea's size the greater of its own size and its viewport's size.

Specified by:
getScrollableTracksViewportWidth in interface Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Implement scrollable to make the InternalTextArea's size the greater of its own size and its viewport's size.

Specified by:
getScrollableTracksViewportHeight in interface Scrollable

processFocusEvent

protected void processFocusEvent(FocusEvent e)
Intercept FocusEvents to notify the ClipboardTargetManager of the event.

Overrides:
processFocusEvent in class Component

processKeyEvent

protected void processKeyEvent(KeyEvent e)
Intercept KeyEvents to perform the usual action.

Overrides:
processKeyEvent in class JComponent

processMouseEvent

protected void processMouseEvent(MouseEvent e)
Intercept mouse clicks to perform the usual action.

Overrides:
processMouseEvent in class JComponent

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent e)
Intercept mouse dragging to perform the usual action.

Overrides:
processMouseMotionEvent in class JComponent