|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent edu.northwestern.at.wordhoard.swing.text.WrappedTextComponent
public class WrappedTextComponent
A wrapped text component.
A wrapped text component displays word-wrapped multilingual styled text with support for optional text selection and scrolling.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.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 | |
---|---|
WrappedTextComponent()
Creates a new empty wrapped text component. |
|
WrappedTextComponent(java.lang.String str,
java.awt.Font font,
int rightMargin)
Creates a new plain (unstyled) wrapped text component. |
|
WrappedTextComponent(Text text,
int rightMargin)
Creates a new wrapped text component. |
Method Summary | |
---|---|
void |
addSelectionObserver(java.util.Observer o)
Adds a selection observer. |
void |
clear()
Clears the text. |
void |
copy()
Copies the selected text to the system clipboard. |
TextLocation |
getLocationOfPoint(java.awt.Point p,
boolean round)
Gets the location of a point. |
java.awt.Dimension |
getMaximumSize()
Gets the maximum size of the component. |
java.awt.Dimension |
getMinimumSize()
Gets the minimum size of the component. |
java.awt.Dimension |
getPreferredScrollableViewportSize()
Gets the preferred size of the viewport. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of the component. |
PrintableComponent |
getPrintableComponent(java.lang.String title,
java.awt.print.PageFormat pageFormat)
Return printable component. |
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Gets the block increment for scrolling. |
boolean |
getScrollableTracksViewportHeight()
Returns true if a viewport should always force the height of this component to match the height of the viewport. |
boolean |
getScrollableTracksViewportWidth()
Returns true if a viewport should always force the width of this component to match the width of the viewport. |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Gets the unit increment for scrolling. |
TextRange |
getSelection()
Gets the selection. |
javax.swing.JViewport |
getViewport()
Gets the parent viewport. |
void |
handleMarkerClick(TextRange range)
Handles a marker click. |
void |
paint(java.awt.Graphics graphics)
Paints the component. |
protected void |
paintComponent(java.awt.Graphics graphics)
Paints the component. |
void |
printContents(java.lang.String title,
java.awt.print.PrinterJob printerJob,
java.awt.print.PageFormat pageFormat)
Prints the text, |
void |
scrollTo(TextRange range,
boolean center)
Scrolls to and selects a range of text. |
void |
selectAll()
Selects all the text. |
void |
setLineNumberInterval(int lineNumberInterval)
Sets the line number interval. |
void |
setMarkers(TextLocation[] markerLocations)
Sets or clears markers. |
void |
setSelectable(boolean selectable)
Sets the selectable option. |
void |
setSelection(TextRange selection)
Sets the selection. |
void |
setText(Text text,
DrawingContext context)
Sets the text. |
void |
setText(Text text,
DrawingContext context,
TextLocation[] markerLocations)
Sets the text. |
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, 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, 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, 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 |
---|
public WrappedTextComponent()
public WrappedTextComponent(Text text, int rightMargin)
Font information for the runs and line widths must be set on entry for the unwrapped text.
text
- Unwrapped text.rightMargin
- Right margin in pixels. public WrappedTextComponent(java.lang.String str, java.awt.Font font, int rightMargin)
str
- Text.font
- Font.rightMargin
- Right margin. Method Detail |
---|
public void setText(Text text, DrawingContext context, TextLocation[] markerLocations)
Font information for the runs and line widths must be set on entry for the unwrapped text.
text
- Unwrapped text.context
- Drawing context.markerLocations
- Marker locations in base coordinates,
or null if none. public void setText(Text text, DrawingContext context)
Font information for the runs and line widths must be set on entry for the unwrapped text.
No lines are marked.
text
- Unwrapped text.context
- Drawing context. public void setSelectable(boolean selectable)
selectable
- True if text selection is permitted. The
default value is false. public void clear()
public TextRange getSelection()
public void setSelection(TextRange selection)
selection
- The selection in base coordinates,
or null if none. public void selectAll()
java.lang.Exception
public void copy()
public void scrollTo(TextRange range, boolean center)
range
- The text range in base coordinates.center
- If true, center the range in
the view, even if it is already visible.
If false, center the range only if it is
not already visible. public void addSelectionObserver(java.util.Observer o)
The observer is notified whenever the selection changes.
o
- Observer. public void setLineNumberInterval(int lineNumberInterval)
The line number interval controls the display of line numbers. 0 = no line numbers, 1 = every line numbered, n = every n'th line numbered, -1 = stanza numbers.
lineNumberInterval
- The new line number interval. public void setMarkers(TextLocation[] markerLocations)
markerLocations
- Marker locations in base coordinates,
or null to clear markers. public TextLocation getLocationOfPoint(java.awt.Point p, boolean round)
p
- Point.round
- If true, location is rounded to nearest location
in the text.
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getMaximumSize()
getMaximumSize
in class javax.swing.JComponent
protected void paintComponent(java.awt.Graphics graphics)
paintComponent
in class javax.swing.JComponent
graphics
- Graphics environment. public void paint(java.awt.Graphics graphics)
paint
in class javax.swing.JComponent
graphics
- Graphics environment. public void handleMarkerClick(TextRange range) throws java.lang.Exception
Subclasses may override this method to handle clicks on markers. The default action is to do nothing.
range
- Text range of line containing marker clicked,
in base coordinates.
java.lang.Exception
public javax.swing.JViewport getViewport()
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
visibleRect
- The view area visible within the
viewport.orientation
- SwingConstants.VERTICAL or
SwingConstants.HORIZONTAL.direction
- Less than zero to scroll up/left,
greater than zero for down/right.
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
visibleRect
- The view area visible within the
viewport.orientation
- SwingConstants.VERTICAL or
SwingConstants.HORIZONTAL.direction
- Less than zero to scroll up/left,
greater than zero for down/right.
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public void printContents(java.lang.String title, java.awt.print.PrinterJob printerJob, java.awt.print.PageFormat pageFormat)
title
- Title for output.printerJob
- The printer job.pageFormat
- The printer page format. public PrintableComponent getPrintableComponent(java.lang.String title, java.awt.print.PageFormat pageFormat)
getPrintableComponent
in interface PrintableContents
title
- Title for printing.pageFormat
- Page format for printing.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |