Java Code Examples for javax.swing.text.View#X_AXIS

The following examples show how to use javax.swing.text.View#X_AXIS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementBoxView.java    From SwingBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: WrapHTMLFactory.java    From SmartIM with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: WrapHTMLFactory.java    From SmartIM with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: NewlineView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 5
Source File: SimpleViewLayoutState.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
    }
 
Example 6
Source File: WrapLabelView.java    From Spark with Apache License 2.0 5 votes vote down vote up
@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 );
       }
   }
 
Example 7
Source File: GapBoxView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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
}
 
Example 8
Source File: ViewUtilitiesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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
    }
}
 
Example 9
Source File: DrawEngineLineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
    }
 
Example 10
Source File: TabView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 11
Source File: JIMSendTextPane.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 12
Source File: JIMSendTextPane.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 13
Source File: JIMSendTextPane.java    From oim-fx with MIT License 5 votes vote down vote up
@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);
	}
}
 
Example 14
Source File: DrawEngineLineView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final int getMajorAxis() {
    return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}
 
Example 15
Source File: SimpleViewLayoutState.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final int getMajorAxis() {
    return isXMajorAxis() ? View.X_AXIS : View.Y_AXIS;
}
 
Example 16
Source File: ImageView.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 17
Source File: GapBoxView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final int getLayoutStateMajorAxis() {
    return (isStatusBitsNonZero(LAYOUT_STATE_X_MAJOR_AXIS_BIT))
        ? View.X_AXIS 
        : View.Y_AXIS;
}
 
Example 18
Source File: ImageView.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 19
Source File: ParagraphView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public float getPreferredSpan(int axis) {
    return (axis == View.X_AXIS) ? width : height;
}
 
Example 20
Source File: GapBoxView.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}