javax.swing.text.View#X_AXIS源码实例Demo

下面列出了javax.swing.text.View#X_AXIS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SmartIM   文件: WrapHTMLFactory.java
@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
            String text = getDocument().getText(p0, p1 - p0);
            if (text.indexOf(WrapHTMLFactory.SEPARATOR) >= 0) {
                return View.ForcedBreakWeight;
            }
        } catch (BadLocationException ex) {
            // should never happen
        }

    }
    return super.getBreakWeight(axis, pos, len);
}
 
源代码2 项目: SmartIM   文件: WrapHTMLFactory.java
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);
}
 
源代码3 项目: netbeans   文件: NewlineView.java
@Override
public float getPreferredSpan(int axis) {
    // Although the width could be e.g. 1 return a default width of a character
    // since if caret is blinking over the newline character and the caret
    // is in overwrite mode then this will make the caret fully visible.
    DocumentView documentView = getDocumentView();
    if (axis == View.X_AXIS) {
        return (documentView != null)
                ? (documentView.op.isNonPrintableCharactersVisible()
                    ? documentView.op.getNewlineCharTextLayout().getAdvance()
                    : documentView.op.getDefaultCharWidth())
                : 1; // Only return one if not connected to view hierarchy
    } else {
        return (documentView != null) ? documentView.op.getDefaultRowHeight() : 1;
    }
}
 
源代码4 项目: SwingBox   文件: ElementBoxView.java
/**
 * Determines if a point falls before an allocated region.
 * 
 * @param x
 *            the X coordinate >= 0
 * @param y
 *            the Y coordinate >= 0
 * @param innerAlloc
 *            the allocated region; this is the area inside of the insets
 * @return true if the point lies before the region else false
 */
@Override
protected boolean isBefore(int x, int y, Rectangle innerAlloc)
{
    // System.err.println("isBefore: " + innerAlloc + " my bounds " +
    // box.getAbsoluteBounds());
    // System.err.println("XY: " + x + " : " + y);
    innerAlloc.setBounds(box.getAbsoluteBounds());
    if (majorAxis == View.X_AXIS)
    {
        return (x < innerAlloc.x);
    }
    else
    {
        return (y < innerAlloc.y);
    }
}
 
源代码5 项目: oim-fx   文件: JIMSendTextPane.java
@Override
public float getMinimumSpan(int axis) {
	switch (axis) {
		case View.X_AXIS:
			return 0;
		case View.Y_AXIS:
			return super.getMinimumSpan(axis);
		default:
			throw new IllegalArgumentException("Invalid axis: " + axis);
	}
}
 
源代码6 项目: xyTalk-pc   文件: JIMSendTextPane.java
@Override
public float getMinimumSpan(int axis)
{
    switch (axis)
    {
        case View.X_AXIS:
            return 0;
        case View.Y_AXIS:
            return super.getMinimumSpan(axis);
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
    }
}
 
源代码7 项目: xyTalk-pc   文件: JIMSendTextPane.java
@Override
public float getMinimumSpan(int axis)
{
    switch (axis)
    {
        case View.X_AXIS:
            return 0;
        case View.Y_AXIS:
            return super.getMinimumSpan(axis);
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
    }
}
 
源代码8 项目: netbeans   文件: TabView.java
@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);
}
 
源代码9 项目: netbeans   文件: DrawEngineLineView.java
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;
    }
 
源代码10 项目: netbeans   文件: ViewUtilitiesImpl.java
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
    }
}
 
源代码11 项目: netbeans   文件: GapBoxView.java
/**
 * 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
}
 
源代码12 项目: Spark   文件: WrapLabelView.java
@Override
public float getMinimumSpan( int axis )
   {
       switch ( axis )
       {
           case View.X_AXIS:
               return 0;
           case View.Y_AXIS:
               return super.getMinimumSpan( axis );
           default:
               throw new IllegalArgumentException( "Invalid axis: " + axis );
       }
   }
 
源代码13 项目: netbeans   文件: SimpleViewLayoutState.java
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;
    }
 
源代码14 项目: netbeans   文件: ParagraphView.java
@Override
public float getPreferredSpan(int axis) {
    return (axis == View.X_AXIS) ? width : height;
}
 
源代码15 项目: Bytecoder   文件: ImageView.java
/**
 * Determines the preferred span for this view along an
 * axis.
 *
 * @param axis may be either X_AXIS or Y_AXIS
 * @return   the span the view would like to be rendered into;
 *           typically the view is told to render into the span
 *           that is returned, although there is no guarantee;
 *           the parent may choose to resize or break the view
 */
public float getPreferredSpan(int axis) {
    sync();

    // If the attributes specified a width/height, always use it!
    if (axis == View.X_AXIS && (state & WIDTH_FLAG) == WIDTH_FLAG) {
        getPreferredSpanFromAltView(axis);
        return width + leftInset + rightInset;
    }
    if (axis == View.Y_AXIS && (state & HEIGHT_FLAG) == HEIGHT_FLAG) {
        getPreferredSpanFromAltView(axis);
        return height + topInset + bottomInset;
    }

    Image image = getImage();

    if (image != null) {
        switch (axis) {
        case View.X_AXIS:
            return width + leftInset + rightInset;
        case View.Y_AXIS:
            return height + topInset + bottomInset;
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
        }
    }
    else {
        View view = getAltView();
        float retValue = 0f;

        if (view != null) {
            retValue = view.getPreferredSpan(axis);
        }
        switch (axis) {
        case View.X_AXIS:
            return retValue + (float)(width + leftInset + rightInset);
        case View.Y_AXIS:
            return retValue + (float)(height + topInset + bottomInset);
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
        }
    }
}
 
源代码16 项目: netbeans   文件: DrawEngineLineView.java
protected final int getMajorAxis() {
    return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}
 
源代码17 项目: netbeans   文件: SimpleViewLayoutState.java
protected final int getMajorAxis() {
    return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}
 
源代码18 项目: jdk8u_jdk   文件: ImageView.java
/**
 * Determines the preferred span for this view along an
 * axis.
 *
 * @param axis may be either X_AXIS or Y_AXIS
 * @return   the span the view would like to be rendered into;
 *           typically the view is told to render into the span
 *           that is returned, although there is no guarantee;
 *           the parent may choose to resize or break the view
 */
public float getPreferredSpan(int axis) {
    sync();

    // If the attributes specified a width/height, always use it!
    if (axis == View.X_AXIS && (state & WIDTH_FLAG) == WIDTH_FLAG) {
        getPreferredSpanFromAltView(axis);
        return width + leftInset + rightInset;
    }
    if (axis == View.Y_AXIS && (state & HEIGHT_FLAG) == HEIGHT_FLAG) {
        getPreferredSpanFromAltView(axis);
        return height + topInset + bottomInset;
    }

    Image image = getImage();

    if (image != null) {
        switch (axis) {
        case View.X_AXIS:
            return width + leftInset + rightInset;
        case View.Y_AXIS:
            return height + topInset + bottomInset;
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
        }
    }
    else {
        View view = getAltView();
        float retValue = 0f;

        if (view != null) {
            retValue = view.getPreferredSpan(axis);
        }
        switch (axis) {
        case View.X_AXIS:
            return retValue + (float)(width + leftInset + rightInset);
        case View.Y_AXIS:
            return retValue + (float)(height + topInset + bottomInset);
        default:
            throw new IllegalArgumentException("Invalid axis: " + axis);
        }
    }
}
 
源代码19 项目: netbeans   文件: GapBoxView.java
protected final int getLayoutStateMajorAxis() {
    return (isStatusBitsNonZero(LAYOUT_STATE_X_MAJOR_AXIS_BIT))
        ? View.X_AXIS 
        : View.Y_AXIS;
}
 
源代码20 项目: netbeans   文件: GapBoxView.java
/**
 * Fetch the major axis (the axis the children
 * are tiled along).  This will have a value of
 * either X_AXIS or Y_AXIS.
 */
public final int getMajorAxis() {
    return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}