|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.View
javax.swing.text.AsyncBoxView
public class AsyncBoxView
非同步執行佈局處理的框。此類別很有用,因為它可通過不在 GUI 事件執行緒中執行任何佈局處理來保持該執行緒的持續活動。佈局是在子視圖的操作粒度上完成的。存取某部分佈局的每個子視圖後(可能是耗時的操作),可放棄剩餘的任務,或者可執行新的、具有更高優先級的任務(如回應一個同步請求或對一個可見區域進行操作)。
存取子視圖的同時,要獲得關聯文檔上的讀取鎖定,這樣該模型在被存取時是穩定的。
| 巢狀類別摘要 | |
|---|---|
class |
AsyncBoxView.ChildLocator
該類別在本地化區域發生更改時,管理該本地化區域中子視圖的有效位置。 |
class |
AsyncBoxView.ChildState
表示子視圖佈局狀態的記錄。 |
| 欄位摘要 | |
|---|---|
protected AsyncBoxView.ChildLocator |
locator
這是管理子視圖偏移量的物件。 |
| 從類別 javax.swing.text.View 繼承的欄位 |
|---|
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS |
| 從介面 javax.swing.SwingConstants 繼承的欄位 |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| 建構子摘要 | |
|---|---|
AsyncBoxView(Element elem,
int axis)
建構執行非同步佈局處理的 BoxView。 |
|
| 方法摘要 | |
|---|---|
protected AsyncBoxView.ChildState |
createChildState(View v)
通過此方法創建新的 ChildState 記錄,以允許擴展 ChildState 記錄的子類別執行/保存更多狀態。 |
protected void |
flushRequirementChanges()
將首選項中的更改向上發佈到父視圖。 |
float |
getBottomInset()
獲得視圖四周底部的空白部分。 |
Shape |
getChildAllocation(int index,
Shape a)
獲取給定子視圖的分派區域。 |
protected AsyncBoxView.ChildState |
getChildState(int index)
獲取物件,該物件表示在給定索引位置的子視圖的佈局狀態。 |
protected boolean |
getEstimatedMajorSpan()
主跨距當前是估計值嗎? |
protected float |
getInsetSpan(int axis)
獲取 insets 所佔據的沿某個軸的跨距。 |
protected LayoutQueue |
getLayoutQueue()
獲取用於佈局處理的佇列。 |
float |
getLeftInset()
獲得視圖四周左側的空白部分。 |
int |
getMajorAxis()
獲取主軸(即子級平鋪時沿用的軸)。 |
float |
getMaximumSpan(int axis)
確定此視圖沿某軸的最大跨距。 |
float |
getMinimumSpan(int axis)
確定此視圖沿某軸的最小跨距。 |
int |
getMinorAxis()
獲取輔軸(與平鋪軸垂直的軸)。 |
int |
getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
提供確定下一個以可視化形式表示的模型位置的方法,使用者可以在此位置放置一個插入符。 |
float |
getPreferredSpan(int axis)
確定此視圖沿某軸的首選跨距。 |
float |
getRightInset()
獲得視圖四周右側的空白部分。 |
float |
getTopInset()
獲得視圖四周頂部的空白部分。 |
View |
getView(int n)
獲得第 n 個子視圖。 |
int |
getViewCount()
返回此視圖中的視圖數。 |
int |
getViewIndex(int pos,
Position.Bias b)
返回該模型中表示給定位置的子視圖索引。 |
protected int |
getViewIndexAtPosition(int pos,
Position.Bias b)
獲取此模型中表示給定位置的子視圖索引。 |
protected void |
loadChildren(ViewFactory f)
載入初始化該視圖的所有子級。 |
protected void |
majorRequirementChange(AsyncBoxView.ChildState cs,
float delta)
沿主軸上的要求更改。 |
protected void |
minorRequirementChange(AsyncBoxView.ChildState cs)
沿輔軸上的要求更改。 |
Shape |
modelToView(int pos,
Shape a,
Position.Bias b)
提供從文檔模型坐標空間到所映射的視圖坐標空間的映射。 |
void |
paint(Graphics g,
Shape alloc)
使用給定的分派和呈現表面呈現該視圖。 |
void |
preferenceChanged(View child,
boolean width,
boolean height)
子視圖可以在父級上調用此方法,以指示首選項已更改並且應該重新考慮佈局。 |
void |
replace(int offset,
int length,
View[] views)
調用父級類別以更新子視圖,並且更新子視圖的狀態記錄。 |
void |
setBottomInset(float i)
設置視圖四周底部的空白部分。 |
protected void |
setEstimatedMajorSpan(boolean isEstimated)
設置 estimatedMajorSpan 屬性,它確定是否應該將主跨距視為估計值。 |
void |
setLeftInset(float i)
設置視圖四周左側的空白部分。 |
void |
setParent(View parent)
設置視圖的父級。 |
void |
setRightInset(float i)
設置視圖四周右側的空白部分。 |
void |
setSize(float width,
float height)
設置視圖的大小。 |
void |
setTopInset(float i)
設置視圖四周頂部的空白部分。 |
protected void |
updateLayout(DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a)
更新佈局,以回應從模型接收的更改通知。 |
int |
viewToModel(float x,
float y,
Shape a,
Position.Bias[] biasReturn)
提供從視圖坐標空間到模型邏輯坐標空間的映射。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 欄位詳細資訊 |
|---|
protected AsyncBoxView.ChildLocator locator
| 建構子詳細資訊 |
|---|
public AsyncBoxView(Element elem,
int axis)
elem - 要表示的模型元素axis - 平鋪時沿用的軸。這可以是 X_AXIS 或 Y_AXIS 之一。| 方法詳細資訊 |
|---|
public int getMajorAxis()
public int getMinorAxis()
public float getTopInset()
public void setTopInset(float i)
i - inset 值public float getBottomInset()
public void setBottomInset(float i)
i - inset 值public float getLeftInset()
public void setLeftInset(float i)
i - inset 值public float getRightInset()
public void setRightInset(float i)
i - inset 值protected float getInsetSpan(int axis)
axis - 確定總的 insets 所沿用的軸,為 X_AXIS 或 Y_AXIS 之一。protected void setEstimatedMajorSpan(boolean isEstimated)
protected boolean getEstimatedMajorSpan()
protected AsyncBoxView.ChildState getChildState(int index)
index - 子視圖索引。這應該是一個 >= 0 且 < getViewCount() 的值。protected LayoutQueue getLayoutQueue()
protected AsyncBoxView.ChildState createChildState(View v)
protected void majorRequirementChange(AsyncBoxView.ChildState cs,
float delta)
實作此方法以便將主軸標記為已更改,所以如果需要將要求發佈到父視圖,後續的檢查可查看是否將主軸考慮在內。如果沿主軸的跨距不是估計值,則通過給定的 delta 更新它,以反映遞增量。如果主跨距是估計值,則忽略 delta。
protected void minorRequirementChange(AsyncBoxView.ChildState cs)
protected void flushRequirementChanges()
public void replace(int offset,
int length,
View[] views)
View 中的 replaceoffset - 子視圖中的起始偏移量,該值 >= 0length - 要替換的現有視圖數,該值 >= 0views - 要插入的子視圖protected void loadChildren(ViewFactory f)
通常在更改子元素時 Document 上會持有寫入鎖定,這可保持呈現和佈局執行緒的安全。例外情況是初始化視圖以表示現有的元素時(通過此方法),所以在進行初始化的時候它是同步的,以將 preferenceChanged 排除在外。
f - 視圖處理器setParent(javax.swing.text.View)
protected int getViewIndexAtPosition(int pos,
Position.Bias b)
pos - 位置,該值 >= 0
protected void updateLayout(DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a)
View 中的 updateLayoutec - 對此視圖所負責的元素的更改(如果沒有更改則可能為 null)。e - 來自相關文檔的更改資訊a - 該視圖的當前分派區域View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory),
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory),
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)public void setParent(View parent)
loadChildren 方法。子級不應在建構子中載入,因為設置父級的操作可能會導致其嘗試向上搜尋層次結構(例如獲得宿主 Container)。如果此視圖具有子視圖(將該視圖從視圖層次結構中的一個位置移到另一個位置),則不調用 loadChildren 方法。
View 中的 setParentparent - 視圖的父級,如果沒有,則為 null
public void preferenceChanged(View child,
boolean width,
boolean height)
View 中的 preferenceChangedchild - 子視圖width - 如果已更改寬度首選項,則為 trueheight - 如果已更改高度首選項,則為 trueJComponent.revalidate()
public void setSize(float width,
float height)
由於主軸是非同步更新的,並且應該是已平鋪子級的和,所以對於主軸應忽略該調用。由於輔軸是很靈活的,所以如果輔跨距更改了,則將工作放入佇列以調整子視圖的大小。
View 中的 setSizewidth - 寬度,該值 >= 0height - 高度,該值 >= 0
public void paint(Graphics g,
Shape alloc)
實作此方法可確定要呈現的所需區域(如非剪貼區域)是否為最新的。如果是最新的,則呈現子視圖。如果不是最新的,則將建構所需區域的任務作為最高優先級的任務放入佈局佇列中。在準備就緒時,此方法通過事件執行緒和渲染來持續運行,在尚未準備就緒時推遲一段時間(因為可以重新安排繪製請求)。
View 中的 paintg - 要使用的呈現表面alloc - 要在其中進行呈現的已分派區域View.paint(java.awt.Graphics, java.awt.Shape)public float getPreferredSpan(int axis)
View 中的 getPreferredSpanaxis - 可以為 View.X_AXIS 或 View.Y_AXIS
IllegalArgumentException - 如果軸型別無效View.getPreferredSpan(int)public float getMinimumSpan(int axis)
View 中的 getMinimumSpanaxis - 可以為 View.X_AXIS 或 View.Y_AXIS
IllegalArgumentException - 如果軸型別無效View.getPreferredSpan(int)public float getMaximumSpan(int axis)
View 中的 getMaximumSpanaxis - 可以為 View.X_AXIS 或 View.Y_AXIS
IllegalArgumentException - 如果軸型別無效View.getPreferredSpan(int)public int getViewCount()
View 中的 getViewCountView.getViewCount()public View getView(int n)
View 中的 getViewn - 要獲得的視圖編號,該值 >= 0 && < getViewCount()
public Shape getChildAllocation(int index,
Shape a)
View 中的 getChildAllocationindex - 子視圖的索引,該值 >= 0 && < getViewCount()a - 此視圖的分派區域。
public int getViewIndex(int pos,
Position.Bias b)
View 中的 getViewIndexpos - 位置,該值 >= 0
public Shape modelToView(int pos,
Shape a,
Position.Bias b)
throws BadLocationException
View 中的 modelToViewpos - 要轉換的位置,該值 >= 0a - 要呈現於其中的已分派區域b - 在該位置是兩個視圖的邊界時,為偏向前一個字元或下一個字元的偏差,由偏移量表示。
BadLocationException - 如果給定的位置不表示關聯文檔內的有效位置
IllegalArgumentException - 如果 bias 參數無效View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] biasReturn)
預計由 GUI 執行緒調用此方法,在關聯的模型上保持讀取鎖定。實作此方法可定位子視圖,並通過對 ChildLocator 物件執行鎖定來確定其分派,以及通過對 ChildLocator 物件執行鎖定對子視圖調用 viewToModel,以避免與佈局執行緒相互干擾。
View 中的 viewToModelx - X 坐標,該值 >= 0y - Y 坐標,該值 >= 0a - 要在其中進行呈現的已分派區域
public int getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
View 中的 getNextVisualPositionFrompos - 要轉換的位置,該值 >= 0a - 要在其中進行呈現的已分派區域direction - 從當前位置開始的方向,可以將它們設想為通常可在鍵盤上找到的箭頭鍵;可為下列值:
SwingConstants.WEST SwingConstants.EAST SwingConstants.NORTH SwingConstants.SOUTH
biasRet - 套件含要檢查的偏差的陣列
BadLocationException
IllegalArgumentException - 如果 direction 無效
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。