本文整理汇总了Java中javax.swing.text.GlyphView类的典型用法代码示例。如果您正苦于以下问题:Java GlyphView类的具体用法?Java GlyphView怎么用?Java GlyphView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlyphView类属于javax.swing.text包,在下文中一共展示了GlyphView类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: breakView
import javax.swing.text.GlyphView; //导入依赖的package包/类
public View breakView(int axis, int p0, float pos, float len) {
if (axis == View.X_AXIS) {
checkPainter();
int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos,
len);
try {
// if the view contains line break char break the view
int index = getDocument().getText(p0, p1 - p0)
.indexOf(WrapHTMLFactory.SEPARATOR);
if (index >= 0) {
GlyphView v = (GlyphView) createFragment(p0,
p0 + index + 1);
return v;
}
} catch (BadLocationException ex) {
// should never happen
}
}
return super.breakView(axis, p0, pos, len);
}
示例2: bug6857057
import javax.swing.text.GlyphView; //导入依赖的package包/类
bug6857057() {
Element elem = new StubBranchElement(" G L Y P H V");
GlyphView view = new GlyphView(elem);
float pos = elem.getStartOffset();
float len = elem.getEndOffset() - pos;
int res = view.getBreakWeight(View.X_AXIS, pos, len);
if (res != View.ExcellentBreakWeight) {
throw new RuntimeException("breakWeight != ExcellentBreakWeight");
}
}
示例3: retrieveGlyphViews
import javax.swing.text.GlyphView; //导入依赖的package包/类
private static void retrieveGlyphViews(View root) {
for (int i=0; i<= root.getViewCount()-1; i++) {
View view = root.getView(i);
if (view instanceof GlyphView && view.isVisible()) {
if (!glyphViews.contains(view)) {
glyphViews.add((GlyphView)view);
}
} else {
retrieveGlyphViews(view);
}
}
}
示例4: breakView
import javax.swing.text.GlyphView; //导入依赖的package包/类
public View breakView(int axis, int p0, float pos, float len)
{
if(axis == View.X_AXIS)
{
checkPainter();
int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos, len);
int breakSpot = getBreakSpot(p0, p1);
if(breakSpot != -1)
{
p1 = breakSpot;
}
// else, no break in the region, return a fragment of the
// bounded region.
if(p0 == getStartOffset() && p1 == getEndOffset())
{
return this;
}
GlyphView v = (GlyphView)createFragment(p0, p1);
// FIX no setter
//v.x = (int)pos;
return v;
}
return this;
}
示例5: main
import javax.swing.text.GlyphView; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
glyphViews = new ArrayList<GlyphView>();
createAndShowGUI(text1);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
retrieveGlyphViews(editorPane.getUI().getRootView(editorPane));
}
});
GlyphView [] arr1 = glyphViews.toArray(new GlyphView[glyphViews.size()]);
frame.dispose();
glyphViews.clear();
createAndShowGUI(text2);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_HOME);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_N);
Util.hitKeys(robot, KeyEvent.VK_E);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
Util.hitKeys(robot, KeyEvent.VK_T);
Util.hitKeys(robot, KeyEvent.VK_W);
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
retrieveGlyphViews(editorPane.getUI().getRootView(editorPane));
}
});
GlyphView [] arr2 = glyphViews.toArray(new GlyphView[glyphViews.size()]);
if (arr1.length != arr2.length) {
throw new RuntimeException("Test Failed!");
}
for (int i=0; i<arr1.length; i++) {
GlyphView v1 = arr1[i];
GlyphView v2 = arr2[i];
Field field = GlyphView.class.getDeclaredField("breakSpots");
field.setAccessible(true);
int[] breakSpots1 = (int[])field.get(v1);
int[] breakSpots2 = (int[])field.get(v2);
if (!Arrays.equals(breakSpots1,breakSpots2)) {
throw new RuntimeException("Test Failed!");
}
}
frame.dispose();
}
示例6: main
import javax.swing.text.GlyphView; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
robot = new Robot();
robot.setAutoDelay(50);
glyphViews = new ArrayList<GlyphView>();
createAndShowGUI(text1);
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
retrieveGlyphViews(editorPane.getUI().getRootView(editorPane));
}
});
GlyphView [] arr1 = glyphViews.toArray(new GlyphView[glyphViews.size()]);
frame.dispose();
glyphViews.clear();
createAndShowGUI(text2);
robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_HOME);
robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_N);
Util.hitKeys(robot, KeyEvent.VK_E);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
Util.hitKeys(robot, KeyEvent.VK_T);
Util.hitKeys(robot, KeyEvent.VK_W);
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
retrieveGlyphViews(editorPane.getUI().getRootView(editorPane));
}
});
GlyphView [] arr2 = glyphViews.toArray(new GlyphView[glyphViews.size()]);
if (arr1.length != arr2.length) {
throw new RuntimeException("Test Failed!");
}
for (int i=0; i<arr1.length; i++) {
GlyphView v1 = arr1[i];
GlyphView v2 = arr2[i];
Field field = GlyphView.class.getDeclaredField("breakSpots");
field.setAccessible(true);
int[] breakSpots1 = (int[])field.get(v1);
int[] breakSpots2 = (int[])field.get(v2);
if (!Arrays.equals(breakSpots1,breakSpots2)) {
throw new RuntimeException("Test Failed!");
}
}
frame.dispose();
}
示例7: getSpan
import javax.swing.text.GlyphView; //导入依赖的package包/类
public float getSpan(GlyphView v, int startOffset, int endOffset,
TabExpander tabExpander, float x) {
return CHAR_WIDTH * (endOffset - startOffset);
}
示例8: getBoundedPosition
import javax.swing.text.GlyphView; //导入依赖的package包/类
public int getBoundedPosition(GlyphView v, int startOffset,
float x, float len) {
int result = (int)len / CHAR_WIDTH + startOffset;
return result <= v.getEndOffset() ? result : v.getEndOffset();
}
示例9: getHeight
import javax.swing.text.GlyphView; //导入依赖的package包/类
public float getHeight(GlyphView v) {
return 0;
}
示例10: getAscent
import javax.swing.text.GlyphView; //导入依赖的package包/类
public float getAscent(GlyphView v) {
return 0;
}
示例11: getDescent
import javax.swing.text.GlyphView; //导入依赖的package包/类
public float getDescent(GlyphView v) {
return 0;
}
示例12: paint
import javax.swing.text.GlyphView; //导入依赖的package包/类
public void paint(GlyphView v, Graphics g, Shape alloc,
int startOffset, int endOffset) {
}
示例13: modelToView
import javax.swing.text.GlyphView; //导入依赖的package包/类
public Shape modelToView(GlyphView v, int offset, Bias bias,
Shape alloc) throws BadLocationException {
return null;
}
示例14: viewToModel
import javax.swing.text.GlyphView; //导入依赖的package包/类
public int viewToModel(GlyphView v, float x, float y,
Shape alloc, Bias[] biasReturn) {
return -1;
}