public class Document extends ScrollContainer
// Extends Document so that we can provide another way to load images, from our internal database class ArticleDocument extends Document { PDBFile cat; DataStream ds; /** The cat parameter should be an already open PDBFile which contains all the images. * Note that the image is in the form "And here's a sample on how to call it:.gif" or " .jpeg". * / public ArticleDocument(XmlReadable doc, PDBFile cat) { this.cat = cat; ds = new DataStream(cat); renderDoc(doc); } protected Image loadImage(String src, URI base) { int dot = src.indexOf('.'); if (dot == -1) throw new RuntimeException("src image not in expected format: "+src); int idx = Convert.toInt(src.substring(0,dot)); String ext = src.substring(dot+1).toLowerCase(); if (cat.setRecordPos(idx)) { int size = cat.getRecordSize(); byte []data = new byte[size]; ds.readBytes(data); return new Image(new ByteArrayStream(data)); } } }
String s = ...; // get the html from somewhere and store in a String if (!s.substring(0,10).toLowerCase().startsWith(""; // Displays the xml hcView.setDocument(new ArticleDocument(new XmlReadableString(s),cat)); // cat must be already instantiatedTo change the font size, you must change Style.defaultFontSize. To change the default colors, change UIColors.htmlXXX fields, and don't forget to call htmlContainer.setBackForeColors with these colors.
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
URI |
baseURI
Base URL for this document
|
byte |
passwordMode
The password mode for the Edits.
|
java.lang.String |
title
Title associated with this document.
|
Vector |
vForms
All forms in this document.
|
autoScroll, bag, bag0, disabledFlick, flick, hsIgnoreAutoScroll, lastH, lastV, sbH, sbV, shrink2size
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Modifier | Constructor and Description |
---|---|
protected |
Document()
Default Constructor.
|
|
Document(XmlReadable doc)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
initUI()
Layout the controls of this document.
|
protected Image |
loadImage(java.lang.String src,
URI baseURI)
Can be overridden by the caller in order to load an image from a different place.
|
protected void |
renderDoc(XmlReadable doc)
Renders the document.
|
void |
reposition()
Reposition this control, calling again setRect with the original parameters.
|
void |
scroll(int dir) |
add, addScrollEventHandler, bagSetRect, canScrollContent, canShowScrollBars, disableFlick, enableFlick, flickEnded, flickStarted, getBagChildren, getBagInitialHeight, getBagInitialWidth, getClientRect, getFlick, getPreferredHeight, getPreferredWidth, getRealClientRect, getScrollDistance, getScrollPosition, moveFocusToNextControl, onBoundsChanged, onColorsChanged, onEvent, onFontChanged, onPaint, remove, removeAll, removeScrollEventHandler, resize, resize, scrollContent, scrollPage, scrollToControl, scrollToOrigin, scrollToPage, setBorderStyle, setHandlersVisibility, setHandlersVisibility, setHValue, setScrollBars, setVValue, updateListenerTriggered, wasScrolled
add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, isPressed, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resizeHeight, resizeWidth, setBorderRadius, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
public URI baseURI
public java.lang.String title
public Vector vForms
public byte passwordMode
Edit.PASSWORD
,
Edit.PASSWORD_ALL
public Document(XmlReadable doc) throws IOException, SyntaxException
doc
- XmlReadable to be readIOException
SyntaxException
protected Document()
renderDoc
.protected Image loadImage(java.lang.String src, URI baseURI)
src
- The image namebaseURI
- The base URIprotected void renderDoc(XmlReadable doc) throws IOException, SyntaxException
doc
- XmlReadable to be readIOException
SyntaxException
public void initUI()
public void scroll(int dir)
public void reposition()
Control
reposition
in class ScrollContainer