本文整理汇总了Java中javax.swing.text.View.X_AXIS属性的典型用法代码示例。如果您正苦于以下问题:Java View.X_AXIS属性的具体用法?Java View.X_AXIS怎么用?Java View.X_AXIS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.text.View
的用法示例。
在下文中一共展示了View.X_AXIS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredSpan
@Override
public float getPreferredSpan(int axis) {
if (axis == View.X_AXIS) {
String desc = fold.getDescription(); // For empty desc a single-space text layout is returned
float advance = 0;
if (desc.length() > 0) {
TextLayout textLayout = getTextLayout();
if (textLayout == null) {
return 0f;
}
advance = textLayout.getAdvance();
}
return advance + (2 * EXTRA_MARGIN_WIDTH);
} else {
EditorView.Parent parent = (EditorView.Parent) getParent();
return (parent != null) ? parent.getViewRenderContext().getDefaultRowHeight() : 0f;
}
}
示例2: getBreakWeight
@Override
public int getBreakWeight(int axis, float pos, float len) {
// return GoodBreakWeight;
if (axis == View.X_AXIS) {
checkPainter();
int p0 = getStartOffset();
int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos,
len);
if (p1 == p0) {
// can't even fit a single character
return View.BadBreakWeight;
}
try {
// if the view contains line break char return forced break
if (getDocument().getText(p0, p1 - p0)
.indexOf(WrapHTMLFactory.SEPARATOR) >= 0) {
return View.ForcedBreakWeight;
}
} catch (BadLocationException ex) {
// should never happen
}
}
return super.getBreakWeight(axis, pos, len);
}
示例3: breakView
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);
}
示例4: selectLayoutMajorAxis
public ViewLayoutState selectLayoutMajorAxis(int majorAxis) {
// assert ViewUtilities.isAxisValid(majorAxis);
if (majorAxis == View.X_AXIS) {
setStatusBits(X_MAJOR_AXIS_BIT);
} else { // y axis
clearStatusBits(X_MAJOR_AXIS_BIT);
}
return this;
}
示例5: getPreferredSpan
@Override
public float getPreferredSpan(int axis) {
EditorView.Parent parent = (EditorView.Parent) getParent();
if (axis == View.X_AXIS) {
float advance = 0;
TextLayout textLayout = getTextLayout();
if (textLayout == null) {
return 0f;
}
return textLayout.getAdvance();
} else {
return (parent != null) ? parent.getViewRenderContext().getDefaultRowHeight() : 0f;
}
}
示例6: axisToString
public static String axisToString(int axis) {
switch (axis) {
case View.X_AXIS:
return "x"; // NOI18N
case View.Y_AXIS:
return "y"; // NOI18N
default:
return "<invalid-axis-value=" + axis + ">"; // NOI18N
}
}
示例7: GapBoxView
/**
* Construct a composite box view over the given element.
*
* @param elem the element of the model to represent.
* @param majorAxis the axis to tile along. This can be
* either X_AXIS or Y_AXIS.
*/
public GapBoxView(Element elem, int majorAxis) {
super(elem);
if (majorAxis == View.X_AXIS) {
setStatusBits(X_MAJOR_AXIS_BIT);
} // by default there should be no bits set
}
示例8: selectLayoutMajorAxis
public ViewLayoutState selectLayoutMajorAxis(int axis) {
// assert ViewUtilities.isAxisValid(axis);
if (axis == View.X_AXIS) {
setStatusBits(X_MAJOR_AXIS_BIT);
} else { // y axis
clearStatusBits(X_MAJOR_AXIS_BIT);
}
return this;
}
示例9: isAxisValid
/**
* Test whether the axis is valid.
*
* @param axis integer axis
* @return true if the axis is either <code>View.X_AXIS</code>
* or <code>View.Y_AXIS</code>. False is returned otherwise.
*/
public static boolean isAxisValid(int axis) {
switch (axis) {
case View.X_AXIS:
case View.Y_AXIS:
return true;
}
return false;
}
示例10: getPreferredSpan
@Override
public float getPreferredSpan(int axis) {
// Since this may be called e.g. from BasicTextUI.getPreferredSize()
// this method needs to acquire mutex
if (lock()) {
try {
checkDocumentLockedIfLogging(); // Should only be called with read-locked document
op.checkViewsInited();
// Ensure the width and height are updated before unlock() gets called (which is too late)
op.checkRealSpanChange();
if (!op.isChildrenValid()) {
return 1f; // Return 1f until parent and etc. gets initialized
}
float span;
if (axis == View.X_AXIS) {
span = preferredWidth;
} else { // Y_AXIS
span = preferredHeight + op.getExtraVirtualHeight();
}
return span;
} finally {
unlock();
}
} else {
return 1f;
}
}
示例11: getPreferredSpan
@Override
public float getPreferredSpan(int axis) {
TextLayout textLayout = getTextLayout();
if (textLayout == null) {
return 0f;
}
float span = (axis == View.X_AXIS)
? textLayout.getAdvance()
: TextLayoutUtils.getHeight(textLayout);
return span;
}
示例12: getPreferredSpan
@Override
public float getPreferredSpan(int axis) {
DocumentView docView = getDocumentView();
return (axis == View.X_AXIS)
? width // Return last width computed by getTabbedSpan()
: ((docView != null) ? docView.op.getDefaultRowHeight() : 0f);
}
示例13: getMajorAxis
protected final int getMajorAxis() {
return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}
示例14: getMinorAxis
protected final int getMinorAxis() {
return isXMajorAxis() ? View.Y_AXIS : View.X_AXIS;
}
示例15: getLayoutStateMajorAxis
protected final int getLayoutStateMajorAxis() {
return (isStatusBitsNonZero(LAYOUT_STATE_X_MAJOR_AXIS_BIT))
? View.X_AXIS
: View.Y_AXIS;
}