Example usage for javax.swing.text View Y_AXIS

List of usage examples for javax.swing.text View Y_AXIS

Introduction

In this page you can find the example usage for javax.swing.text View Y_AXIS.

Prototype

int Y_AXIS

To view the source code for javax.swing.text View Y_AXIS.

Click Source Link

Document

Axis for format/break operations.

Usage

From source file:Main.java

public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }//from  w w w.  j a  v  a2 s  .c  o m
    }
    return new LabelView(elem);
}

From source file:Main.java

@Override
public View create(Element elem) {
    View result = null;//from   w  w w .  ja  va  2s . c  o  m
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            result = new MyLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            result = new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            result = new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            result = new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            result = new IconView(elem);
        } else {
            result = new LabelView(elem);
        }
    } else {
        result = super.create(elem);
    }
    return result;
}

From source file:Main.java

public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new MyLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }/*  ww w.  j av  a2 s .  co  m*/
    }
    return new LabelView(elem);
}

From source file:Main.java

public float getMinimumSpan(int axis) {
    switch (axis) {
    case View.X_AXIS:
        return 0;
    case View.Y_AXIS:
        return super.getMinimumSpan(axis);
    default://from   w ww  .  j  av a  2s  .  c o m
        throw new IllegalArgumentException("Invalid axis: " + axis);
    }
}

From source file:FormattedTextFieldExample.java

public float getPreferredSpan(int axis) {
    int widthFormat;
    int widthContent;

    if (formatSize == 0 || axis == View.Y_AXIS) {
        return super.getPreferredSpan(axis);
    }/*  ww w.  j a v a  2  s  .c  o m*/

    widthFormat = Utilities.getTabbedTextWidth(measureBuff, getFontMetrics(), 0, this, 0);
    widthContent = Utilities.getTabbedTextWidth(contentBuff, getFontMetrics(), 0, this, 0);

    return Math.max(widthFormat, widthContent);
}

From source file:com.hexidec.ekit.component.RelativeImageView.java

/** Determines the preferred span for this view along an axis.
  */*  ww  w .  j av a 2  s .  c o  m*/
  * @param axis may be either X_AXIS or Y_AXIS
  * @returns  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) {
    int extra = 2 * (getBorder() + getSpace(axis));
    switch (axis) {
    case View.X_AXIS:
        return fWidth + extra;
    case View.Y_AXIS:
        return fHeight + extra;
    default:
        throw new IllegalArgumentException("Invalid axis in getPreferredSpan() : " + axis);
    }
}

From source file:com.hexidec.ekit.component.RelativeImageView.java

/** Determines the desired alignment for this view along an
  * axis. This is implemented to give the alignment to the
  * bottom of the icon along the y axis, and the default
  * along the x axis./* www .j  av a2 s. c o m*/
  *
  * @param axis may be either X_AXIS or Y_AXIS
  * @returns the desired alignment. This should be a value
  *   between 0.0 and 1.0 where 0 indicates alignment at the
  *   origin and 1.0 indicates alignment to the full span
  *   away from the origin. An alignment of 0.5 would be the
  *   center of the view.
  */
public float getAlignment(int axis) {
    switch (axis) {
    case View.Y_AXIS:
        return getVerticalAlignment();
    default:
        return super.getAlignment(axis);
    }
}

From source file:org.pmedv.core.components.RelativeImageView.java

/**
 * Determines the preferred span for this view along an axis.
 * //from  w ww. j  a va  2  s  .com
 * @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) {

    int extra = 2 * (getBorder() + getSpace(axis));
    switch (axis) {
    case View.X_AXIS:
        return fWidth + extra;
    case View.Y_AXIS:
        return fHeight + extra;
    default:
        throw new IllegalArgumentException("Invalid axis in getPreferredSpan() : " + axis);
    }
}

From source file:org.pmedv.core.components.RelativeImageView.java

/**
 * Determines the desired alignment for this view along an axis. This is
 * implemented to give the alignment to the bottom of the icon along the y
 * axis, and the default along the x axis.
 * /*  ww  w.j  av a 2s. c  o  m*/
 * @param axis
 *            may be either X_AXIS or Y_AXIS
 * @return the desired alignment. This should be a value between 0.0 and 1.0
 *         where 0 indicates alignment at the origin and 1.0 indicates
 *         alignment to the full span away from the origin. An alignment of
 *         0.5 would be the center of the view.
 */
public float getAlignment(int axis) {

    switch (axis) {
    case View.Y_AXIS:
        return getVerticalAlignment();
    default:
        return super.getAlignment(axis);
    }
}