本文整理汇总了Java中javax.swing.text.View.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java View.setSize方法的具体用法?Java View.setSize怎么用?Java View.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.View
的用法示例。
在下文中一共展示了View.setSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modelToView
import javax.swing.text.View; //导入方法依赖的package包/类
static Rectangle2D modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException {
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readLock();
}
try {
Rectangle alloc = getVisibleEditorRect(tc);
if (alloc != null) {
View rootView = tc.getUI().getRootView(tc);
rootView.setSize(alloc.width, alloc.height);
Shape s = rootView.modelToView(pos, alloc, bias);
if (s != null) {
return s.getBounds2D();
}
}
} finally {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readUnlock();
}
}
return null;
}
示例2: viewToModel
import javax.swing.text.View; //导入方法依赖的package包/类
static int viewToModel(JTextComponent tc, double x, double y, Position.Bias[] biasReturn) {
int offs = -1;
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readLock();
}
try {
Rectangle alloc = getVisibleEditorRect(tc);
if (alloc != null) {
View rootView = tc.getUI().getRootView(tc);
View documentView = rootView.getView(0);
if (documentView instanceof EditorView) {
documentView.setSize(alloc.width, alloc.height);
offs = ((EditorView) documentView).viewToModelChecked(x, y, alloc, biasReturn);
} else {
rootView.setSize(alloc.width, alloc.height);
offs = rootView.viewToModel((float) x, (float) y, alloc, biasReturn);
}
}
} finally {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readUnlock();
}
}
return offs;
}
示例3: setTipText
import javax.swing.text.View; //导入方法依赖的package包/类
@Override
public void setTipText(String tipText) {
super.setTipText(tipText);
if( getPreferredSize().width > 400 ) {
View v = (View) getClientProperty("html"); //NOI18N
if( null != v )
v.setSize(300.0f, 300.0f);
}
}
示例4: getPreferredSize
import javax.swing.text.View; //导入方法依赖的package包/类
/**
* Returns the preferred size to set a component at in order to render an
* html string. You can specify the size of one dimension.
*/
private static Dimension getPreferredSize(String html, boolean width, int prefSize) {
RESIZER.setText(html);
View view = (View) RESIZER.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width ? prefSize : 0, width ? 0 : prefSize);
float w = view.getPreferredSpan(View.X_AXIS);
float h = view.getPreferredSpan(View.Y_AXIS);
return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}
示例5: getPreferredSize
import javax.swing.text.View; //导入方法依赖的package包/类
public static java.awt.Dimension getPreferredSize(String text,
boolean width, int prefSize) {
JLabel resizer = new JLabel(text);
View view = (View) resizer
.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width ? prefSize : 0, width ? 0 : prefSize);
float w = view.getPreferredSpan(View.X_AXIS);
float h = view.getPreferredSpan(View.Y_AXIS) + 2;
return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}