public class HTMLEditorKit extends StyledEditorKit implements Accessible
HTML EditorKitはいくつかの目標を持って提供されており、これはHTMLをモデル化する手法に反映されています。そうした目標が、クラスの設計に実質的な影響を与えています。
HTMLのモデル化は、HTMLDocumentクラスで提供されています。HTMLのモデル化については、そのドキュメントに詳しく記載されています。編集のサポートは、主にtextパッケージで提供されます。
HTMLFactoryクラスによって提供されます。ビューのセットを変更するには、HTMLFactoryをサブクラス化または置き換えた上で、getViewFactoryメソッドを実装し直して別のファクトリを返すようにします。
JEditorPane.setPageを使ってロードする場合に非同期でロードされるドキュメントを生成します。これは、ドキュメントのプロパティによって制御されます。createDefaultDocumentメソッドをオーバーライドすれば、プロパティを変更できます。作業のバッチ処理は、HTMLDocument.HTMLReaderクラスによって行われます。実際の作業は、textパッケージ内のDefaultStyledDocumentおよびAbstractDocumentクラスによって行われます。
この機能のサポートは、StyleSheetクラスによって提供されます。HTMLの表現は、EditorKitのStyleSheetプロパティの設定によって、自由に変えることができます。
| 修飾子と型 | クラスと説明 |
|---|---|
static class |
HTMLEditorKit.HTMLFactory
HTML用のビューを作成するファクトリです。
|
static class |
HTMLEditorKit.HTMLTextAction
HTMLを既存のドキュメントに挿入するのに便利ないくつかの簡易メソッドを提供するabstractアクションです。
|
static class |
HTMLEditorKit.InsertHTMLTextAction
InsertHTMLTextActionは、既存のHTMLドキュメントに任意のHTML文字列を挿入するために使用できます。
|
static class |
HTMLEditorKit.LinkController
関連付けられたコンポーネントを監視し、必要に応じてその上でハイパーリンク・イベントを発生させるクラスです。
|
static class |
HTMLEditorKit.Parser
パーサーがサポートするインタフェースです。
|
static class |
HTMLEditorKit.ParserCallback
構文解析の結果が、これらのコールバック・メソッドを呼び出します。
|
StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineActionDefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction| 修飾子と型 | フィールドと説明 |
|---|---|
static String |
BOLD_ACTION
ボールド処理識別子です。
|
static String |
COLOR_ACTION
色選択処理識別子です。色は引数として渡されます。
|
static String |
DEFAULT_CSS
タグ表示を設定するデフォルトのCSS (Cascading Style Sheet)ファイルです。
|
static String |
FONT_CHANGE_BIGGER
次サイズへのフォント拡大識別子です。
|
static String |
FONT_CHANGE_SMALLER
次サイズへのフォント縮小識別子です。
|
static String |
IMG_ALIGN_BOTTOM
イメージを下端にそろえます。
|
static String |
IMG_ALIGN_MIDDLE
イメージを中央にそろえます。
|
static String |
IMG_ALIGN_TOP
イメージを上端にそろえます。
|
static String |
IMG_BORDER
イメージを境界にそろえます。
|
static String |
ITALIC_ACTION
イタリック処理識別子です。
|
static String |
LOGICAL_STYLE_ACTION
論理スタイル選択処理識別子です。論理スタイルは引数として渡されます。
|
static String |
PARA_INDENT_LEFT
段落の左インデント処理識別子です。
|
static String |
PARA_INDENT_RIGHT
段落の右インデント処理識別子です。
|
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction| コンストラクタと説明 |
|---|
HTMLEditorKit()
HTMLEditorKitを構築し、StyleContextを作成して、スタイル・シートをロードします。
|
| 修飾子と型 | メソッドと説明 |
|---|---|
Object |
clone()
編集キットのコピーを作成します。
|
Document |
createDefaultDocument()
この型のエディタに適している未初期化テキスト・ストレージ・モデルを作成します。
|
protected void |
createInputAttributes(Element element, MutableAttributeSet set)
elementのAttributeSet内のキーと値のペアをsetにコピーします。 |
void |
deinstall(JEditorPane c)
キットがJEditorPaneから削除されているときに呼び出されます。
|
AccessibleContext |
getAccessibleContext()
このエディタ・キットに関連付けられたAccessibleContextを返します
|
Action[] |
getActions()
エディタのコマンド・リストを取り出します。
|
String |
getContentType()
このキットがサポートするデータのMIMEタイプを返します。
|
Cursor |
getDefaultCursor()
デフォルトのカーソルを返します。
|
MutableAttributeSet |
getInputAttributes()
書式付き編集アクションに使用される入力属性を返します。
|
Cursor |
getLinkCursor()
ハイパーリンク上で使用するカーソルを返します。
|
protected HTMLEditorKit.Parser |
getParser()
HTMLストリームの読込みに使用するパーサーを取得します。
|
StyleSheet |
getStyleSheet()
HTML要素の描画に使用されているスタイル・セットを返します。
|
ViewFactory |
getViewFactory()
このキットが作成した任意のモデルのビューを作成するのに適したファクトリを取得します。
|
void |
insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag)
既存のドキュメントにHTMLを挿入します。
|
void |
install(JEditorPane c)
キットがJEditorPaneにインストールされるときに呼び出されます。
|
boolean |
isAutoFormSubmission()
htmlフォームの送信が自動的に処理されるか、
FormSubmitEventがトリガーされるだけかを示します。 |
void |
read(Reader in, Document doc, int pos)
指定されたストリームからコンテンツを挿入します。
|
void |
setAutoFormSubmission(boolean isAuto)
htmlフォームの送信が自動的に処理されるか、
FormSubmitEventがトリガーされるだけかを示します。 |
void |
setDefaultCursor(Cursor cursor)
デフォルトのカーソルを設定します。
|
void |
setLinkCursor(Cursor cursor)
リンク上で使用するカーソルを設定します。
|
void |
setStyleSheet(StyleSheet s)
各種のHTML要素の描画に使用されるスタイル・セットを設定します。
|
void |
write(Writer out, Document doc, int pos, int len)
このタイプのコンテンツ・ハンドラに適した形式で、ドキュメントからストリームへコンテンツを書き込みます。
|
getCharacterAttributeRuncreateCaret, read, writepublic static final String DEFAULT_CSS
public static final String FONT_CHANGE_SMALLER
public static final String LOGICAL_STYLE_ACTION
public HTMLEditorKit()
public String getContentType()
text/htmlタイプをサポートします。getContentType、クラス: DefaultEditorKitpublic ViewFactory getViewFactory()
getViewFactory、クラス: StyledEditorKitpublic Document createDefaultDocument()
createDefaultDocument、クラス: StyledEditorKitpublic void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
docがHTMLDocumentのインスタンスである場合は、HTML 3.2テキストが読み取られます。空でないドキュメントへのHTMLの挿入は、body要素の内側にする必要があります。本文に挿入しない場合、例外がスローされます。空でないドキュメントへの挿入時は、bodyの外側のタグ(head、title)がすべて削除されます。read、クラス: DefaultEditorKitin - 読込み元のストリームdoc - 挿入先pos - コンテンツを配置するドキュメント内の位置IOException - 入出力エラーが発生した場合BadLocationException - posがドキュメント内の無効な位置を表す場合RuntimeException - posが無効な場合(結果的にBadLocationExceptionになる)public void insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag) throws BadLocationException, IOException
doc - 挿入先のドキュメントoffset - HTMLの挿入位置のオフセットpopDepth - 挿入の前に生成されるElementSpec.EndTagTypesタグの数pushDepth - 終了タグの生成後、挿入前に生成されるElementSpec.JoinNextDirectionの方向を持つElementSpec.StartTagTypeタグの数insertTag - ドキュメントへの挿入を開始する最初のタグRuntimeException - posが無効な場合(結果的にBadLocationExceptionになる)BadLocationExceptionIOExceptionpublic void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
write、クラス: DefaultEditorKitout - 書込み先のストリームdoc - 書込み元pos - コンテンツを取得するドキュメント内の位置len - 書き出す量IOException - 入出力エラーが発生した場合BadLocationException - posがドキュメント内の無効な位置を表す場合public void install(JEditorPane c)
install、クラス: StyledEditorKitc - JEditorPanepublic void deinstall(JEditorPane c)
deinstall、クラス: StyledEditorKitc - JEditorPanepublic void setStyleSheet(StyleSheet s)
public StyleSheet getStyleSheet()
public Action[] getActions()
getActions、クラス: StyledEditorKitprotected void createInputAttributes(Element element, MutableAttributeSet set)
elementのAttributeSet内のキーと値のペアをsetにコピーします。このメソッドは、コンポーネント、アイコン、要素名の各属性はコピーしません。サブクラスでは、どの属性をコピーしてどの属性をコピーしないかを変更することもできます。ただし、最初にset内のすべての属性を必ず削除してください。このメソッドは、キャレットが別の位置に移動するたびに呼び出されます。
createInputAttributes、クラス: StyledEditorKitpublic MutableAttributeSet getInputAttributes()
getInputAttributes、クラス: StyledEditorKitpublic void setDefaultCursor(Cursor cursor)
public Cursor getDefaultCursor()
public void setLinkCursor(Cursor cursor)
public Cursor getLinkCursor()
public boolean isAutoFormSubmission()
FormSubmitEventがトリガーされるだけかを示します。setAutoFormSubmission(boolean)public void setAutoFormSubmission(boolean isAuto)
FormSubmitEventがトリガーされるだけかを示します。デフォルトでは、trueに設定されます。isAutoFormSubmission(), FormSubmitEventpublic Object clone()
clone、クラス: StyledEditorKitCloneableprotected HTMLEditorKit.Parser getParser()
public AccessibleContext getAccessibleContext()
getAccessibleContext、インタフェース: Accessible バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright© 1993, 2014, Oracle and/or its affiliates. All rights reserved.