Package games.stendhal.client.gui
Class KHtmlEdit
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
games.stendhal.client.gui.KHtmlEdit
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable
A HTML implementation of a KTextEdit component.
TODO: Many of the general HTML functions can be moved to a common utility
class.
TODO: Move the message formatting (and setup) code to a common class so that
the in-game text bubbles can use the same code for rendering.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ColorColor of the time stamp written before the lines.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHandle hypertext link activation.protected voidappendHTML(StringBuilder sbuf, char ch) Append a character to a buffer, escaping HTML meta-characters when needed.protected voidappendHTML(StringBuilder sbuf, String text) Escape text as HTML, escaping meta-characters.protected voidappendString(String text) Append HTML text to the end of the content.protected voidbuildLink(StringBuilder sbuf, String text) Convert a text "link" to an HTML link.protected StringcolorToRGB(Color color) Convert a color to a CSS color attribute value.protected StringExtract link content from a character iterator.protected voidinitStylesForTextPane(JTextPane textPane, int mainTextSize) Initializes the basic styles.protected voidinsertHeader(String text) Insert a header.protected voidStart a new line.protected voidinsertText(String text, NotificationType type) Insert the text portion of the line using a specified notification type for style.protected voidinsertTimestamp(String text) Insert time stamp.protected booleanisWordDelim(char ch) Determine is a character is a word delimiter when followed by a space or end-of-line.voidprotected StringtranslateToHTML(String text) Translate a standard Stendhal encoded to HTML encoded.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, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
HEADER_COLOR
Color of the time stamp written before the lines.
-
-
Method Details
-
activateLink
Handle hypertext link activation.- Parameters:
ev- The link event data.
-
appendString
Append HTML text to the end of the content. Note: Currently elements must be complete to be added correctly.- Parameters:
text- The HTML text to add.
-
appendHTML
Append a character to a buffer, escaping HTML meta-characters when needed.- Parameters:
sbuf-ch-
-
appendHTML
Escape text as HTML, escaping meta-characters.- Parameters:
sbuf-text- Raw text.
-
translateToHTML
Translate a standard Stendhal encoded to HTML encoded.- Parameters:
text- The text to encode.- Returns:
- HTML encoded text.
-
extractLink
Extract link content from a character iterator. It is assumed that the '#' has already been eaten. It leaves the character iterator at the first character after the link text.- Parameters:
ci- The character iterator.- Returns:
- Link text (or an empty string).
-
isWordDelim
protected boolean isWordDelim(char ch) Determine is a character is a word delimiter when followed by a space or end-of-line. Care should be taken to avoid matching characters that are typically at the end of valid URL's.- Parameters:
ch- A character;- Returns:
trueif a word delimiter.
-
buildLink
Convert a text "link" to an HTML link. For well-known URL's, the link is taken literally, otherwise asay:URL will be generated.- Parameters:
sbuf- The string buffer to append to.text- The text to convert.
-
colorToRGB
Convert a color to a CSS color attribute value.- Parameters:
color- An AWT color.- Returns:
- A
color:CSS attribute value.
-
initStylesForTextPane
Initializes the basic styles.- Parameters:
textPane- the active text componentmainTextSize- size of regular text
-
insertHeader
Insert a header.- Parameters:
text- header string
-
insertNewline
protected void insertNewline()Start a new line. -
insertText
Insert the text portion of the line using a specified notification type for style.- Parameters:
text- The text to insert.type- The notification type.
-
insertTimestamp
Insert time stamp.- Parameters:
text- time stamp
-
setFont
- Overrides:
setFontin classJComponent
-